I am trying to use a function I wrote for an Assistant. The function has a date parameter, like this
{
"name": "get_games",
"parameters": {
"type": "object",
"properties": {
"date": {
"description": "Must be a date in the format of day month, for example 1 June, 23 July."
},
"team": {
"type": "string",
"description": "If the user only wants to see information about a specific team"
},
"round": {
"type": "integer",
"description": "The number of a specific round the user wants to see information about"
}
},
"required": []
},
"description": "Used to get information about one or more games happening on a given day. A user can also ask about a specific team."
}
When I run the thread, I use the additional_instructions option to set today’s date: additional_instructions: "Current date 2024-05-17T18:05:47.767+10:00
If I ask the assistant, for example, “What’s the date on Sunday” it gets the answer correct. However, when I ask it a question, for example, “Who is playing on Sunday”, it passes the day rather than the date to the function (I am logging function arguments to the console): {"date":"Sunday"}
Does anyone have a suggestion on how to solve this please?
You are missing that the AI doesn’t know what day of the week it is. How is it supposed to come up with an answer for Sunday if it doesn’t know it is Friday?
Also pertinent is to add “time of most recent user question” along with “session start time”, to prevent the chat breaking if continued on a prior day’s chat and function calls.
You can offer the AI a “get day of week” function for calculations it can’t intuit. However, your main function itself can operate on the optional inputs this would take.
OK so maybe that’s what I am missing. I can do a function to get the day of the week, but what I was trying to do was pass in a date to the existing function in order to filter the data it provides (which comes from an external API). Let me try adding the day in addition to the date. I think your suggestion of adding the time of the user’s question is also a good idea in a situation like this, thanks.
Edit: passing in (through additional_instructions) a string like Friday, 17 May 2024 at 10:07:18 pm Australian Eastern Standard Time still gives the same result
I tested your function and a simple get_weather function with date using Assistants API, added today’s date and time in the Additional Instructions and I can confirm that it is throwing very off result. I cannot recall this issue before.
I also tested the same thing on Chat completions API and get the expected results.