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.

refactor: Modify instruction in prompt for increased JSON output reliability

Reinier van der Leer775a27eea0f9
diff --git a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
index 3680ee64a1..8b8a697065 100644
--- a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
+++ b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py
@@ -315,12 +315,9 @@ class OneShotAgentPromptStrategy(PromptStrategy):
)
instruction = (
- (
- "Respond strictly with a JSON object containing your thoughts, "
- "and a tool_call specifying the next command to use."
- )
+ "Respond with pure JSON containing your thoughts, " "and invoke a tool."
if use_functions_api
- else "Respond strictly with a JSON object."
+ else "Respond with pure JSON."
)
return (
diff --git a/autogpts/autogpt/autogpt/json_utils/utilities.py b/autogpts/autogpt/autogpt/json_utils/utilities.py
index b967a41fcb..80ef8cee36 100644
--- a/autogpts/autogpt/autogpt/json_utils/utilities.py
+++ b/autogpts/autogpt/autogpt/json_utils/utilities.py
@@ -30,6 +30,6 @@ def extract_dict_from_response(response_content: str) -> dict[str, Any]:
return ast.literal_eval(response_content)
except BaseException as e:
logger.info(f"Error parsing JSON response with literal_eval {e}")
- logger.debug(f"Invalid JSON received in response: {response_content}")
+ logger.debug(f"Invalid JSON received in response:\n{response_content}")
# TODO: How to raise an error here without causing the program to exit?
return {}