types accepted by call functions

Hello everyone, how are you doing?

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.

Thank you very much!

what do you mean? where are you getting the data from? using gpt-3.5 to convert dates is probably not the best idea.

can you give an example of a function you’d like to have called, and what date it should be called from?

It follows the JSON schema.

string, number, integer, object, array, and boolean

1 Like

Not integer, though.

You’ll get bounced by the API for that.

A JSON value can be an object, array, number, string, true, false, or null.

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” :grin:

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.

1 Like