Параметр Python langchain Tool()
Я хочу передать параметры в «функцию» инструмента в коде. Но модель чата имеет весь контроль над «функциями» (насколько я знаю). Поэтому я хочу напрямую передать информацию функции в Tool(). Есть ли способ пройти?
realistic_vision_tool = Tool(
name="realistic_vision_V1.4 image generating",
func=realistic_vision_v1_4, #would like to pass some params here
description="""Use when you want to generate an image of something with realistic_vision model. Input like "a dog standing on a rock" is decent for this tool so input not-so-detailed prompts to this tool. If an image is generated, tool will return "Successfully generated image.\". Say something like "Generated. Hope it helps.\" if you use this tool. Always input english prompts for the input, even if the user is not speaking english. Enter the inputs in english to this tool."""
)
Я хочу передать параметры здесь. Вотfunc()
:
def realistic_vision_v1_4(prompt, username, conversation_name):
API_URL = (
"https://api-inference.huggingface.co/models/SG161222/Realistic_Vision_V1.4"
)
headers = {"Authorization": "Bearer XXX"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query(
{
"inputs": prompt
+ ", (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3",
}
)
database.upload_current_img(username, conversation_name, image_bytes) #it wants username and conversation name to store the img_bin
return "Successfully generated image."