mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
Add missing json_parser.py and add alternative requirements
This adds fix_and_parse_json Also, add requirements-alternative.txt to help install reqs in a different environment
This commit is contained in:
12
scripts/json_parser.py
Normal file
12
scripts/json_parser.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import dirtyjson
|
||||
from ai_functions import fix_json
|
||||
|
||||
def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
|
||||
try:
|
||||
return dirtyjson.loads(json_str)
|
||||
except Exception as e:
|
||||
if try_to_fix_with_gpt:
|
||||
# Now try to fix this up using the ai_functions
|
||||
return fix_json(json_str, None, True)
|
||||
else:
|
||||
raise e
|
||||
Reference in New Issue
Block a user