Interpreters
1. Concept
Interpreters are tools that empower agents to execute given code snippets on the local machine or in isolated environments. CAMEL supports several types of interpreters to cater to different needs and security considerations.
1.1. Internal Python Interpreter
The Internal Python Interpreter executes Python code directly within the same process as the agent. This is the simplest interpreter and is suitable for trusted code execution. In its default (safe) mode, it evaluates expressions and executes statements in a controlled environment; print()
is not directly available as a side effect, so code should evaluate to a string for output.
Example Usage:
1.2. Subprocess Interpreter
The Subprocess Interpreter runs code in a separate subprocess. This provides a degree of isolation from the main agent process. It can execute various shell commands and scripts in addition to Python code.
Example Usage:
1.3. Docker Interpreter
The Docker Interpreter executes code snippets within a Docker container. This offers a high level of isolation, ensuring that code runs in a controlled and sandboxed environment. This is particularly useful for running untrusted code or code with specific dependencies.
To utilize this interpreter, you need to have Docker installed on your system. For more information on Docker installation, visit Docker’s official website.
Example Usage:
1.4. IPython Interpreter
The IPython Interpreter (JupyterKernelInterpreter) leverages an IPython kernel to execute code. This allows for a rich, interactive execution environment, similar to using a Jupyter notebook. It supports features like state persistence across code executions within a session.
Example Usage:
1.5. E2B Interpreter
The E2B Interpreter utilizes the E2B cloud-based sandboxed environments for code execution. This provides a secure and managed environment for running code without requiring local setup of complex dependencies or risking local system integrity.
For more information, visit the E2B official documentation.
Example Usage: