Introduce EXECUTE_SHELL_COMMANDS config var, default to False

This commit is contained in:
Bernhard Mueller
2023-04-10 11:01:48 +07:00
parent dd469bf2ae
commit 09d2f47e08
4 changed files with 8 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ FAST_LLM_MODEL="gpt-3.5-turbo"
GOOGLE_API_KEY=
CUSTOM_SEARCH_ENGINE_ID=
USE_AZURE=False
EXECUTE_LOCAL_COMMANDS=False
OPENAI_API_BASE=your-base-url-for-azure
OPENAI_API_VERSION=api-version-for-azure
OPENAI_DEPLOYMENT_ID=deployment-id-for-azure

File diff suppressed because one or more lines are too long

View File

@@ -104,8 +104,11 @@ def execute_command(command_name, arguments):
return ai.write_tests(arguments["code"], arguments.get("focus"))
elif command_name == "execute_python_file": # Add this command
return execute_python_file(arguments["file"])
elif command_name == "exec_shell": # Add this command
elif command_name == "exec_shell":
if cfg.execute_local_commands:
return exec_shell(arguments["command_line"])
else:
return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_SHELL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction."
elif command_name == "generate_image":
return generate_image(arguments["prompt"])
elif command_name == "task_complete":

View File

@@ -43,6 +43,8 @@ class Config(metaclass=Singleton):
self.openai_api_key = os.getenv("OPENAI_API_KEY")
self.use_azure = False
self.use_azure = os.getenv("USE_AZURE") == 'True'
self.execute_local_commands = os.getenv('EXECUTE_LOCAL_COMMANDS', 'False') == 'True'
if self.use_azure:
self.openai_api_base = os.getenv("OPENAI_API_BASE")
self.openai_api_version = os.getenv("OPENAI_API_VERSION")