Fixed issue with 3.5 Models hallucinating a function called "python", causing empty returns #683
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the changes you have made:
I've found 3.5-turbo to be consistently hallucinating a function with the name "python", which causes an ugly UX of an empty return. Here's what it looks like:
It turns out this is reasonably well known: https://community.openai.com/t/function-calling-a-python-function-is-frequently-called-even-though-it-does-not-exist-in-the-functions-parameter/264481/1, and that there's not a ton to be done here, other than embrace it. I've added the ability to just process that function, if it's called.
When working on raycast open-interpreter, I test with 3.5 turbo for cost reasons (I'm running the same question like 100 times to check UI stuff). I've found the issue to be problematic both on the command line and from the library form.
I no longer get empty replies in any of the test cases I've found that once triggered this. My main test case is:
Check what python interpreter you have access to.
.I have tested the code on the following OS:
AI Language Model (if applicable)