While it is a well-known fact that the chatgpt-3.5-turbo-1106 can call functions by parsing arguments extracted from the user input, I am curious how we can parse our desired variable by code, not from user input extracted by GPT model.
Assuming we have defined the following function while creating an GPT assistant
{
"type": "function",
"function": {
"name": "store_to_db",
"description": "store captured data to DB",
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the user."
},
"email": {
"type": "string",
"description": "Email of the user."
},
"postcode": {
"type": "string",
"description": "Postcode of the user."
},
"uuid": {
"type": "string",
"description": "current uuid of user session"
}
},
"required": []
}
}
}
the assistant model doesn't know what the uuid, because it can not be provided from the user's input, but only name, email, postcode.
In this case, i tried the following.
global uuid // uuid has been obtained somewhere in this code programmatically, not from GPT and user input.
if tool_call.function.name == "store_to_db":
try:
arguments = json.loads(tool_call.function.arguments)
name = arguments.get("name", None)
email = arguments.get("email", None)
postcode = arguments.get("postcode", None)
output = store_db(name=name, email=email, postcode=postcode, uuid=uuid)
client.beta.threads.runs.submit_tool_outputs(thread_id=thread_id,
run_id=run.id,
tool_outputs=[{
"tool_call_id": tool_call.id,
"output": output
}])
Of course, this outputs an error that the argument is no defined. Is there any workaround? Can not we go beyond the limitation of the current function call method of GPT model?