autogen
autogen copied to clipboard
Fixes “The model produced invalid content” error when calling functions
Why are these changes needed?
This fixes the issue related to the more strict checking of JSON parameters in function calling as described here:
https://community.openai.com/t/error-the-model-produced-invalid-content/747511
This PR removes the 'name' parameter from messages in OpenAI client. It also introduces an additional parameter in the tool JSON specification that was previously missing.
Related issue number
Closes #3247
Checks
- [ ] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
- [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [x] I've made sure all auto checks have passed.
Codecov Report
Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
Please upload report for BASE (
0.2@5ad2677). Learn more about missing BASE report.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| autogen/oai/client.py | 77.77% | 2 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## 0.2 #3429 +/- ##
======================================
Coverage ? 29.61%
======================================
Files ? 117
Lines ? 13022
Branches ? 2469
======================================
Hits ? 3856
Misses ? 8819
Partials ? 347
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 29.59% <80.00%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@davorrunje, thanks for creating this - interesting that OpenAI are also removing name. This is likely to affect group chat with speaker selection. May need to incorporate the recent name transforms as a simpler integration for that (but that's for another discussion/time :) ).
I'll give it a test...
More about this error: https://community.openai.com/t/bizarre-issue-preventing-response-from-gpt-4o-mini-the-model-produces-invalid-content/875432
@davorrunje, thanks again for working on a fix for the exception.
Would you have an example that I could use to replicate the exception?
Hi , I have the same error "The model produced invalid content” error when calling functions", how I can apply this fix, any idea ?
Hi , I have the same error "The model produced invalid content” error when calling functions", how I can apply this fix, any idea ?
Hi @lmcmahi, would you be able to provide a code sample that produces this error? It would help in testing out viable fixes.
Hi, I've encountered exactly the same error, having you find a good solution?
@davorrunje would you say the proposed fix is still necessary after gpt-4o-2024-08-06?
Looks like this is dormant, if you want to pick this up again please feel free to reopen. Thanks!