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.

Create a list of synonyms for commands when the AI hallucinates (#1526)

Richard Beales63936209a05c
diff --git a/autogpt/app.py b/autogpt/app.py
index 66986786a2..eca0e0b7a7 100644
--- a/autogpt/app.py
+++ b/autogpt/app.py
@@ -88,6 +88,21 @@ def get_command(response: str):
return "Error:", str(e)
+def map_command_synonyms(command_name: str):
+ """ Takes the original command name given by the AI, and checks if the
+ string matches a list of common/known hallucinations
+ """
+ synonyms = [
+ ('write_file', 'write_to_file'),
+ ('create_file', 'write_to_file'),
+ ('search', 'google')
+ ]
+ for seen_command, actual_command_name in synonyms:
+ if command_name == seen_command:
+ return actual_command_name
+ return command_name
+
+
def execute_command(command_name: str, arguments):
"""Execute the command and return the result
@@ -100,6 +115,7 @@ def execute_command(command_name: str, arguments):
memory = get_memory(CFG)
try:
+ command_name = map_command_synonyms(command_name)
if command_name == "google":
# Check if the Google API key is set and use the official search method
# If the API key is not set or has only whitespaces, use the unofficial