diff --git a/.gitignore b/.gitignore index 33c003c..8c1b771 100644 --- a/.gitignore +++ b/.gitignore @@ -132,12 +132,6 @@ ENV/ env.bak/ venv.bak/ -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject # mkdocs documentation /site @@ -159,6 +153,11 @@ cython_debug/ # PyCharm #.idea/ +# Interpreter +interpreter_workspace/ + # Archive archive/ -savedir/ \ No newline at end of file +savedir/ +output/ +tool_output/ \ No newline at end of file diff --git a/examples/e2b_example.py b/examples/e2b_example.py index 74d219f..7a62e29 100644 --- a/examples/e2b_example.py +++ b/examples/e2b_example.py @@ -34,7 +34,7 @@ agent = CodeAgent( ) if LAUNCH_GRADIO: - from agents.gradio_ui import GradioUI + from agents import GradioUI GradioUI(agent).launch() else: diff --git a/src/agents/agents.py b/src/agents/agents.py index 0ec2a11..079444c 100644 --- a/src/agents/agents.py +++ b/src/agents/agents.py @@ -42,7 +42,7 @@ from .prompts import ( SYSTEM_PROMPT_PLAN_UPDATE, SYSTEM_PROMPT_PLAN, ) -from .local_python_executor import BASE_BUILTIN_MODULES, LocalPythonExecutor +from .local_python_executor import BASE_BUILTIN_MODULES, LocalPythonInterpreter from .e2b_executor import E2BExecutor from .tools import ( DEFAULT_TOOL_DESCRIPTION_TEMPLATE, @@ -892,11 +892,14 @@ class CodeAgent(ReactAgent): self.additional_authorized_imports = ( additional_authorized_imports if additional_authorized_imports else [] ) + if use_e2b_executor and len(self.managed_agents) > 0: + raise Exception(f"You passed both {use_e2b_executor=} and some managed agents. Managed agents is not yet supported with remote code execution.") + all_tools = {**self.toolbox.tools, **self.managed_agents} if use_e2b_executor: self.python_executor = E2BExecutor(self.additional_authorized_imports, list(all_tools.values())) else: - self.python_executor = LocalPythonExecutor(self.additional_authorized_imports, all_tools) + self.python_executor = LocalPythonInterpreter(self.additional_authorized_imports, all_tools) self.authorized_imports = list( set(BASE_BUILTIN_MODULES) | set(self.additional_authorized_imports) ) diff --git a/src/agents/local_python_executor.py b/src/agents/local_python_executor.py index f31b6d0..0546baf 100644 --- a/src/agents/local_python_executor.py +++ b/src/agents/local_python_executor.py @@ -1043,7 +1043,7 @@ def evaluate_python_code( raise InterpreterError(msg) -class LocalPythonExecutor(): +class LocalPythonInterpreter(): def __init__(self, additional_authorized_imports: List[str], tools: Dict): self.custom_tools = {} self.state = {} @@ -1069,4 +1069,4 @@ class LocalPythonExecutor(): logs = self.state["print_outputs"] return output, logs -__all__ = ["evaluate_python_code", "LocalPythonExecutor"] +__all__ = ["evaluate_python_code", "LocalPythonInterpreter"]