Skip to content

Commit

Permalink
Args update to work with str and list
Browse files Browse the repository at this point in the history
  • Loading branch information
MauroDruwel committed Aug 29, 2023
1 parent be10446 commit 68bdf06
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autogpt/commands/execute_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
from autogpt.logs import logger
from autogpt.setup import CFG
from autogpt.workspace.workspace import Workspace
from typing import Union


@command(
"execute_python_file",
"Execute Python File",
'"filename": "<filename>", "(optional) args": ["<arg>", ...]',
)
def execute_python_file(filename: str, config: Config, args: list = []) -> str:
def execute_python_file(filename: str, config: Config, args: Union[list, str] = []) -> str:
"""Execute a Python file in a Docker container and return the output
Args:
Expand All @@ -31,6 +32,9 @@ def execute_python_file(filename: str, config: Config, args: list = []) -> str:
logger.info(
f"Executing python file '{filename}' in working directory '{CFG.workspace_path}'"
)

if isinstance(args, str):
args = args.split() # Convert space-separated string to a list

if not filename.endswith(".py"):
return "Error: Invalid file type. Only .py files are allowed."
Expand Down

0 comments on commit 68bdf06

Please sign in to comment.