mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-10 07:38:04 -05:00
refactor: Tweak prompts & improve AutoGPT agent step output
- Make minor adjustments to prompts in the OneShotAgentPromptConfiguration class - Enhance the output format of the execute_result in AgentProtocolServer - Update the key name from "criticism" to "self_criticism" in print_assistant_thoughts function - Modify the output format of the web search results in the web_search function
This commit is contained in:
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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", "")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user