Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(json_parser): fixing the "TypeError('the JSON object must be str, bytes or bytearray, not dict')" after a json_fix is successful

Fabrice Hong051be4df1007
diff --git a/scripts/json_parser.py b/scripts/json_parser.py
index 11ff9ed22e..763a4789f9 100644
--- a/scripts/json_parser.py
+++ b/scripts/json_parser.py
@@ -67,7 +67,8 @@ def fix_json(json_str: str, schema: str, debug=False) -> str:
print(f"Fixed JSON: {result_string}")
print("----------- END OF FIX ATTEMPT ----------------")
try:
- return json.loads(result_string)
+ json.loads(result_string) # just check the validity
+ return result_string
except:
# Get the call stack:
# import traceback