Skip to content

Commit

Permalink
Only add execute shell scripts to prompt if AI is allowed to do it. (S…
Browse files Browse the repository at this point in the history
  • Loading branch information
richbeales authored Apr 15, 2023
1 parent 7a5e273 commit 3b17028
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions autogpt/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from autogpt.config.config import Config
from autogpt.logs import logger
from autogpt.promptgenerator import PromptGenerator
from autogpt.config import Config
from autogpt.setup import prompt_user
from autogpt.utils import clean_input

Expand All @@ -18,6 +19,9 @@ def get_prompt() -> str:
str: The generated prompt string.
"""

# Initialize the Config object
cfg = Config()

# Initialize the PromptGenerator object
prompt_generator = PromptGenerator()

Expand Down Expand Up @@ -73,16 +77,27 @@ def get_prompt() -> str:
{"code": "<full_code_string>", "focus": "<list_of_focus_areas>"},
),
("Execute Python File", "execute_python_file", {"file": "<file>"}),
(
"Execute Shell Command, non-interactive commands only",
"execute_shell",
{"command_line": "<command_line>"},
),
("Task Complete (Shutdown)", "task_complete", {"reason": "<reason>"}),
("Generate Image", "generate_image", {"prompt": "<prompt>"}),
("Do Nothing", "do_nothing", {}),
]

# Only add shell command to the prompt if the AI is allowed to execute it
if cfg.execute_local_commands:
commands.append(
(
"Execute Shell Command, non-interactive commands only",
"execute_shell",
{"command_line": "<command_line>"},
),
)

# Add these command last.
commands.append(
("Do Nothing", "do_nothing", {}),
)
commands.append(
("Task Complete (Shutdown)", "task_complete", {"reason": "<reason>"}),
)

# Add commands to the PromptGenerator object
for command_label, command_name, args in commands:
prompt_generator.add_command(command_label, command_name, args)
Expand Down

0 comments on commit 3b17028

Please sign in to comment.