I have a chatbot with various function calls. When the user asks gpt to perform a task without all the necessary parameters, the assistant will respond by asking to provide those parameters. The gpt knows which function call to perform, but the parameters in the response message are nil: “function_call=None, tool_calls=None”
Example:
{‘role’: ‘user’, ‘content’: ‘Add a student to a class’}
ChatCompletionMessage(content=“To add a student to a class, I’ll need the name of the class and the name of the student. Additionally, please provide the number of sessions the student is signing up for.”, role=‘assistant’, function_call=None, tool_calls=None)
How can I find out the intended function call? Is there even a way to do that?
I’m building an iOS application so I plan to present buttons on the screen based on the intended function call.
It is hard to diagnose the problem without seeing the description for your function and its parameters, but in the past, I’ve been able to solve this problem by adding the following prompt to the function description:
ALWAYS respond with values for all parameters in this tool.
However, if you share the description of your function and its parameters, I’ll be able to provide better feedback.
{
"name": "add_student_to_class",
"description": "Add a student to a given class.",
"parameters": {
"type": "object",
"properties": {
"classID": {
"type": "string",
"description": "Name of the class student will be added to.",
},
"studentName": {
"type": "string",
"description": "Name of the student",
},
"sessions": {
"type": "integer",
"description": "Number of sessions the student signed up for."
}
},
"required": ["classID", "studentName", "fees"],
},
}
If i ask the GPT “Add a student”, sometimes it will ask me to all the required properties in one message, or it will ask for them one by one getting responses for each.
I tested your function and it is working as intended. The assistant message:
To add a student to a class, I’ll need the name of the class and the name of the student. Additionally, please provide the number of sessions the student is signing up for.
will not yet invoke the function/tool. It will be invoked after you submit the info asked.
I also got the case when it first asked for the class id. Only after I gave the class Id that it asked for the name and sessions. It only invoked the function/tool after that.
However, my question is if there’s a way to get the intended function call after the first assistant message:
"To add a student to a class, I’ll need the name of the class and the name of the student. Additionally, please provide the number of sessions the student is signing up for."
It knows that it has to perform addStudentToClass, so is there any way I can get that information before it performs it.
The reason I’m asking is because I’m building a iOS application and I want to present the user with buttons, based on the intended function call. So in this case, when the user asks “Add a student student”, I want to populate the screen with a list of classes.
I hope I am being clear in what I am asking. Let me know if I need to clarify anymore.
It used to be able to be done, with better versions of gpt-3.5-turbo-0613 closer to the release date and before undisclosed changes.
Now it is very hard to get the AI to emit both content and then follow that with calling a function in the same response. Or get the AI to follow any kind of step-by-step directions by system message.