Important change in Function Calling!

Hey all!

So in my other post I discussed and showed some issues we’re having since yesterday regarding the function-calling feature. The issue is that, with certain parameters in your functions, openAI will ALWAYS respond with strings instead of numbers/integers. We didn’t change anything about the prompt or API call but still the results were different and made our app crash.

See this quick example below:

The ‘enum’ in ‘points’ made GPT-4 return only strings, whereas it was clearly stated in the prompt and functions that it should be a number. So if you want to return numbers/integers in a function call, make sure you don’t add any ENUMs to your functions as this will result in incorrect outputs!

Interested in the tool I used to test my prompts and functions? Check it here, it’s free!

“Same as it always was”.

I gave a reply to the other thread.

https://community.openai.com/t/function-calling-parameter-types/268564/8

functions = [
{
    "name": "data_demonstration",
    "description": "This is the main function description",
    "parameters": {
        "type": "object",
        "properties": {
"string_1": {"type": "string", "description": ""},
"number_2": {"type": "number", "description": ""},
"boolean_3": {"type": "boolean", "description": ""},
"empty_4": {"type": "null","description": "This is a description of the empty_4 null property"},
"string_5_enum": {"type": "string", "enum": ["Happy", "Sad"]},
        },
        "required": ["string_1","number_2","boolean_3", "empty_4", "string_5_enum"]
    }
}
]

Four types of variables you can have the AI output (one without much use except when you just want a “trigger” function. Only string will get the enum list you pass.

array and object are also troublesome to specify and employ without knowing the caveats.

Just one more reason to write a custom function parser for yourself ^^ and to petition openai to give us more control over their Json to Ts converter~ (or to write a proper parser themselves)

make sure you don’t add any ENUMs to your functions as this will result in incorrect outputs!

I think it’s probably good to just keep it as “enum” if that’s he functionality you need, but simply parse the string “100” to integer as you parse the arguments. If your enums are like [“100”, “200”, “300”] or whatever it will still always pick a number from those choices that you can rely to convert to integer, and not give you something strange

That could definitely be a good solution! In this case, we also explain in the prompt what the ‘allowed’ values are and our app won’t break if it will return other values outside of that list. Turning strings to numbers is a bit more complex though since we use Bubble.io and not ‘real’ code!

Hey, I just developed a python library that makes function calling easier. You won’t have to craft schema, validate and invoke the LLM output manually. This library will do it for you.

You can search for this repo: synacktraa/hypertion on github.