-
Notifications
You must be signed in to change notification settings - Fork 44.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correct and clean up JSON handling #4655
Correct and clean up JSON handling #4655
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
1 similar comment
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
6b090da
to
a27a066
Compare
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
1 similar comment
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4655 +/- ##
==========================================
+ Coverage 69.94% 70.61% +0.66%
==========================================
Files 72 70 -2
Lines 3590 3437 -153
Branches 569 547 -22
==========================================
- Hits 2511 2427 -84
+ Misses 895 842 -53
+ Partials 184 168 -16
☔ View full report in Codecov by Sentry. |
@erik-megarad ast.literal_eval doesn't work with booleans true or false. and also why use it ? |
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
Oh, it doesn't, does it. However, there aren't booleans allowed in our validation schema so it should never come up. I'm using |
Actually I think I do need to change this. |
d52c740
to
1fded82
Compare
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
✅ Deploy Preview for auto-gpt-docs canceled.
|
You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged. |
Update from discord: Using |
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
1 similar comment
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
50cb0d8
to
18c1373
Compare
18c1373
to
0c2bbeb
Compare
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged. |
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged. |
This PR exceeds the recommended size of 500 lines. Please make sure you are NOT addressing multiple issues with one PR. |
@erik-megarad ok I reran the benchmark for JSON errors and it's 0 error out of 50 so this is good. |
Nice! Nit: I see |
Exciting news: We can finally get rid of this JSON cleanup mess entirely!
https://openai.com/blog/function-calling-and-other-api-updates |
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
* Correct and clean up JSON handling * Use ast for message history too * Lint * Add comments explaining why we use literal_eval * Add descriptions to llm_response_format schema * Parse responses in code blocks * Be more careful when parsing in code blocks * Lint
Background
We had a bunch of hacks to get around JSON errors. Turns out there were two issues:
The JSON coming from OpenAI is actually not JSON. It's a Python Dict that's been stringified like
str(dict)
.The second issue is that we weren't correctly feeding the AI the JSON schema. It recognizes the same schema that we use to validate the response, so this works much better.
This may also fix the "no command given" errors but I will need to test more.
Changes
ast.literal_eval
to reverse thestr()
process that was done by OpenAIDocumentation
Test Plan
PR Quality Checklist