Add E2B doc

This commit is contained in:
Aymeric 2024-12-20 16:50:27 +01:00
parent c18bc9037d
commit b11abbf27e
4 changed files with 14 additions and 12 deletions

13
.gitignore vendored
View File

@ -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/
savedir/
output/
tool_output/

View File

@ -34,7 +34,7 @@ agent = CodeAgent(
)
if LAUNCH_GRADIO:
from agents.gradio_ui import GradioUI
from agents import GradioUI
GradioUI(agent).launch()
else:

View File

@ -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)
)

View File

@ -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"]