Add custom commands to execute_command via promptgenerator

pull/2531/head
BillSchumacher 2023-04-16 00:37:21 -05:00
parent 83403ad3ab
commit abb54df4d0
No known key found for this signature in database
GPG Key ID: 1133789BDD03E12A
2 changed files with 8 additions and 6 deletions

View File

@ -167,13 +167,11 @@ class Agent:
)
result = (
f"Command {command_name} returned: "
f"{execute_command(command_name, arguments)}"
f"{execute_command(command_name, arguments, self.config.prompt_generator)}"
)
for plugin in cfg.plugins:
result = plugin.post_command(
command_name, result
)
result = plugin.post_command(command_name, result)
if self.next_action_count > 0:
self.next_action_count -= 1

View File

@ -21,6 +21,7 @@ from autogpt.commands.file_operations import (
from autogpt.json_fixes.parsing import fix_and_parse_json
from autogpt.memory import get_memory
from autogpt.processing.text import summarize_text
from autogpt.prompts.generator import PromptGenerator
from autogpt.speech import say_text
from autogpt.commands.web_selenium import browse_website
from autogpt.commands.git_operations import clone_repository
@ -105,7 +106,7 @@ def map_command_synonyms(command_name: str):
return command_name
def execute_command(command_name: str, arguments):
def execute_command(command_name: str, arguments, prompt: PromptGenerator):
"""Execute the command and return the result
Args:
@ -192,6 +193,9 @@ def execute_command(command_name: str, arguments):
elif command_name == "task_complete":
shutdown()
else:
for command in prompt.commands:
if command_name == command["label"] or command_name == command["name"]:
return command["function"](*arguments.values())
return (
f"Unknown command '{command_name}'. Please refer to the 'COMMANDS'"
" list for available commands and only respond in the specified JSON"