From cd0df40a4ff3dc88f8d527210a7dcc81de77da61 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Tue, 17 Oct 2023 19:47:25 -0700 Subject: [PATCH] AutoGPT: Make `core.prompting.utils:json_loads` slightly more robust --- autogpts/autogpt/autogpt/core/prompting/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autogpts/autogpt/autogpt/core/prompting/utils.py b/autogpts/autogpt/autogpt/core/prompting/utils.py index 5a725903..5a127da9 100644 --- a/autogpts/autogpt/autogpt/core/prompting/utils.py +++ b/autogpts/autogpt/autogpt/core/prompting/utils.py @@ -18,6 +18,7 @@ def json_loads(json_str: str): # Can hopefully just replace with a call to ast.literal_eval (the function api still # sometimes returns json strings with minor issues like trailing commas). try: + json_str = json_str[json_str.index("{"):json_str.rindex("}")] return ast.literal_eval(json_str) except json.decoder.JSONDecodeError as e: try: