trying to implement some call functions I found that a¿there are certain types that it does not accept as properties; e.g. datetime, decimal, float.
I would like to know what types exist, if in case of working with dates they use strings and then parse them to datetime, and if they work with numbers.
I think integer is okay. I double-checked my running function and it has integer type and I am not getting any problem. I also checked the cookbook and they also use integer as type.
{
"type": "function",
"function": {
"name": "get_n_day_weather_forecast",
"description": "Get an N-day weather forecast",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"format": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The temperature unit to use. Infer this from the users location.",
},
"num_days": {
"type": "integer",
"description": "The number of days to forecast",
}
},
"required": ["location", "format", "num_days"]
},
}
},
Would have saved me a few debugging minutes if you mentioned “tool”
It looks like they made the tool endpoint happy with “integer”, converting it to number for you.
I made the days function more ambiguous, describing fractions of days for its “integer”.
You can see the AI doesn’t know what-for about integer…
content=“The weather function’s ‘num_days’ parameter does not specifically mention the data type it expects. However, in JSON format, you can represent numbers as either integers or floats. Therefore, you should be able to provide either an integer or a float value for the ‘num_days’ parameter.”
And we can do creative asking to determine why:
>>> print(json.loads(c.http_response.text)['choices'][0]['message']['content'])
namespace functions {
// Get weather forecast
type get_weather_forecast = (_: {
// The city and state.
location: string,
// The temperature unit to use.
format: "celsius" | "fahrenheit",
// length in days or portions of day
time_period?: number,
}) => any;
} // namespace functions
You can see above the AI is still passed time_period?: number, not “integer”. Functions would have blocked.