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: Tweak prompts & improve AutoGPT agent step output
Reinier van der Leer7a7a14469048
diff --git a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.pyindex d927d65ce9..304bd4a56c 100644--- a/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py+++ b/autogpts/autogpt/autogpt/agents/prompt_strategies/one_shot.py@@ -42,7 +42,8 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):"{resources}\n""\n""## Commands\n"- "You have access to the following commands:\n"+ "These are the ONLY commands you can use."+ " Any action you perform must be possible through one of these commands:\n""{commands}\n""\n""## Best practices\n"@@ -62,6 +63,13 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):type=JSONSchema.Type.OBJECT,required=True,properties={+ "observations": JSONSchema(+ description=(+ "Relevant observations from your last action (if any)"+ ),+ type=JSONSchema.Type.STRING,+ required=False,+ ),"text": JSONSchema(description="Thoughts",type=JSONSchema.Type.STRING,@@ -71,13 +79,13 @@ class OneShotAgentPromptConfiguration(SystemConfiguration):type=JSONSchema.Type.STRING,required=True,),- "plan": JSONSchema(- description="Short markdown-style bullet list that conveys the long-term plan",+ "self_criticism": JSONSchema(+ description="Constructive self-criticism",type=JSONSchema.Type.STRING,required=True,),- "criticism": JSONSchema(- description="Constructive self-criticism",+ "plan": JSONSchema(+ description="Short markdown-style bullet list that conveys the long-term plan",type=JSONSchema.Type.STRING,required=True,),diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.pyindex 1426178f37..d59b796287 100644--- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py+++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py@@ -264,7 +264,8 @@ class AgentProtocolServer:output = ((f"Command `{execute_command}({fmt_kwargs(execute_command_args)})` returned:"- f" {execute_result}\n\n"+ + ("\n\n" if "\n" in str(execute_result) else " ")+ + f"{execute_result}\n\n")if execute_command_args and execute_command != "ask_user"else ""diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.pyindex ff454e4d0a..683793a70b 100644--- a/autogpts/autogpt/autogpt/app/main.py+++ b/autogpts/autogpt/autogpt/app/main.py@@ -692,7 +692,7 @@ def print_assistant_thoughts()assistant_thoughts_plan = remove_ansi_escape(assistant_thoughts.get("plan", ""))assistant_thoughts_criticism = remove_ansi_escape(- assistant_thoughts.get("criticism", "")+ assistant_thoughts.get("self_criticism", ""))assistant_thoughts_speak = remove_ansi_escape(assistant_thoughts.get("speak", "")diff --git a/autogpts/autogpt/autogpt/commands/web_search.py b/autogpts/autogpt/autogpt/commands/web_search.pyindex 8c9a9334ce..c4411d9361 100644--- a/autogpts/autogpt/autogpt/commands/web_search.py+++ b/autogpts/autogpt/autogpt/commands/web_search.py@@ -61,12 +61,23 @@ def web_search(query: str, agent: Agent, num_results: int = 8) -> str:{"title": r["title"],"url": r["href"],- **({"description": r["body"]} if r.get("body") else {}),+ **({"exerpt": r["body"]} if r.get("body") else {}),}for r in search_results]- results = json.dumps(search_results, ensure_ascii=False, indent=4)+ results = (+ "## Search results\n"+ # "Read these results carefully."+ # " Extract the information you need for your task from the list of results"+ # " if possible. Otherwise, choose a webpage from the list to read entirely."+ # "\n\n"+ ) + "\n\n".join(+ f"### \"{r['title']}\"\n"+ f"**URL:** {r['url']} \n"+ "**Excerpt:** " + (f'"{exerpt}"' if (exerpt := r.get("exerpt")) else "N/A")+ for r in search_results+ )return safe_google_results(results)