Hey thank you very much for your reply. I’m sorry but I’m a bit new to these concepts, so I might have said something that doesn’t really make sense.
The point is the following, I am making a chatbot to collect orders from a restaurant, during the conversation I order the product X and Y , the product (and other parameters) are send to the function called order_summary. If I put a fixed string as return of the function, for example “You have order the product J and K”, when the bot replies to the user , the answer is “You have order the product X and Y” and not the product J and K of the fixed string.
The following are part of the code, maybe they can be useful for this.
if run_status.status == 'completed':
messages = client.beta.threads.messages.list(thread_id=thread_id)
print("messages:______", messages)
message_content = messages.data[0].content[0].text
# Remove annotations
annotations = message_content.annotations
for annotation in annotations:
message_content.value = message_content.value.replace(
annotation.text, '')
print("Run completed, returning response")
return jsonify({
"response": message_content.value,
"status": "completed"
})
if run_status.status == 'requires_action':
for tool_call in run_status.required_action.submit_tool_outputs.tool_calls:
if tool_call.function.name == "order_summary":
arguments = json.loads(tool_call.function.arguments)
output = functions.order_summary(arguments["prod"],
arguments["order_type"],
arguments["order_payment"],
arguments["address"])
client.beta.threads.runs.submit_tool_outputs(thread_id=thread_id,
run_id=run_id,
tool_outputs=[{
"tool_call_id":
tool_call.id,
"output":
json.dumps(output)
}])
#this is the assistant
assistant = client.beta.assistants.create(
# Change prompting in prompts.py file
instructions=assistant_instructions,
model="gpt-4-1106-preview",
tools=[{
"type": "function",
"function": {
"name": "order_summary",
"description":
"Used to summarize the order when the customer has provided all the necessary information. Never modify the output of this tool",
"parameters": {
"type":
"object",
"properties": {
"prod": {
"type":
"string",
"description":
"List of products ordered by the customer"
},
"order_type": {
"type":
"string",
"description":
"Type of order. Can be Delivery or Pickup"
},
"order_payment": {
"type":
"string",
"description":
"Payment method. Can be Satispay or Cash"
},
"address": {
"type":
"string",
"description":
"Possible delivery address. If not present it is False"
},
},
"required":
["prod", "order_type", "order_payment", "address"]
}
}
}],
#file_ids=[file.id]
)
```