Function call that works with 4o gets errors with o1

I have a function I’ve been using without issue in combination with 4o. I recently got access to the new o1 and wanted to benchmark its performance against what I was seeing with 4o when using the specific function call.

I used the Playground to set up an identical prompt and function call to what I use with 4o and was able to successfully add the function without any issues. However when I hit run, I get an error like this:

Invalid schema for function 'myFunction': In context=('properties', 'foo', etc), schema must have a 'type' key.

To be clear, this function works perfectly with 4o in strict output mode, no less. The only difference is the model. Has anyone encountered this bug before? Any advice on how to work around it? I’m sure OpenAI will fix it eventually but I’d rather just move forward, even if that requires refactoring the function around o1’s peccadillos.

I know that initial version of the backend userinterface were more lenient on the schema (there was not proper validation and or error messaging). I had several functions (that did work) - that I could not paste in other Assistant (I use mostly Assistants, not completions) - unless changing them.

Thanks, I don’t think that’s it. I’m able to use this function with every model – and both Assistant and Chat playgrounds – with no problem. The only change is I select o1 from the model dropdown instead of 4o. It’s very odd.

I’ve also run the function through ChatGPT – which reliably has helped me find issues with functions I’ve written – and it’s saying it’s valid JSON. I’m really just curious if anyone else has encountered that error code. Usually when there was an issue with one of my functions, it was caught at the the time I tried to “Add” the function to the Chat or Assistant prompt via the Playground. But this error only displays at run time, which is the real oddity to me. I would expect invalid JSON to always be caught at the “Add” step like usual.

1 Like

Actually I spoke to soon haha. You were onto something. I used o1 pro to troubleshoot my JSON and this was the issue:

In a nutshell, the O1 model’s function-schema validation is stricter about how type is defined, and it does not allow an array of types in the format:

“type”: [“string”, “null”]

Instead I needed to do this:

“type”: “string”,
“nullable”: true

And viola. Thanks!

3 Likes

I’m glad to see that o1 pro actually seems to be having up to date information about the OpenaAI api - because that has been a problem in the past. Glad you solved it!

1 Like