fix(json_parser): remove the tab character that can be present in the generated json. It makes the json.loads function throw an Invalid JSON error

This commit is contained in:
Fabrice Hong
2023-04-05 20:16:28 +02:00
parent 62dfd84599
commit ffb95eb031

View File

@@ -24,6 +24,7 @@ def fix_and_parse_json(json_str: str, try_to_fix_with_gpt: bool = True):
"""
try:
json_str = json_str.replace('\t', '')
return json.loads(json_str)
except Exception as e:
# Let's do something manually - sometimes GPT responds with something BEFORE the braces: