AutoGPT
AutoGPT copied to clipboard
feat(autogpt): Implement tolerant `json_loads` function
OPEN-183
Background
OpenAI API tends to return broken json responses (such as trailing commas, extra newlines) which fail to be parsed by built-in json.loads
.
This change introduces relaxed parsing function json_loads
using demjson3
that handles minor syntax issues in json and is used where json.loads
was used previously to parse responses from llm.
It can deal with:
- Missing, extra and trailing commas
- Extraneous newlines and whitespace outside of string literals
- Inconsistent spacing after colons and commas
- Missing closing brackets or braces
- Numbers: binary, hex, octal, trailing and prefixed decimal points
- Different encodings
- Comments
Changes šļø
- Add dependency for
demjson3 ^3.0.0
(LGPLv3 license) -
json_loads
function - Swap
json.loads
withjson_loads
across multiple files - Tests
Deploy Preview for auto-gpt-docs ready!
Name | Link |
---|---|
Latest commit | 03df00be97e01d8fca7f9d07876bf93981382587 |
Latest deploy log | https://app.netlify.com/sites/auto-gpt-docs/deploys/65fb52da4f4bfa0007abe779 |
Deploy Preview | https://deploy-preview-7016--auto-gpt-docs.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Do you have benchmark stats for this? Iād like to see if it improves our score much
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! š A maintainer will review the pull request shortly.