Update block docs for: code_execution_block.md

This commit is contained in:
Bently
2025-01-12 11:07:29 +00:00
parent a40bb6f6d6
commit d4e5a48163

View File

@@ -0,0 +1,44 @@
## Code Execution Block
### What it is
A secure environment for executing code in various programming languages with internet access and customizable setup options.
### What it does
This block allows users to run code in multiple programming languages (Python, JavaScript, Bash, R, and Java) within an isolated sandbox environment. It supports custom setup commands, timeout settings, and provides detailed execution outputs.
### How it works
1. Creates a secure sandbox environment using E2B credentials
2. Runs any specified setup commands (like installing packages)
3. Executes the provided code in the chosen programming language
4. Collects and returns the execution results, including any output or errors
5. Automatically terminates if there are errors or timeout is reached
### Inputs
- **API Key Credentials**: Your E2B Sandbox API key for authentication
- **Setup Commands**: Optional shell commands to prepare the environment (e.g., installing packages)
- **Code**: The actual code you want to execute
- **Programming Language**: Choice of Python (default), JavaScript, Bash, R, or Java
- **Timeout**: Maximum execution time in seconds (default: 300 seconds)
- **Template ID**: Optional E2B sandbox template ID for custom configurations
### Outputs
- **Response**: The main output from your code execution
- **Standard Output Logs**: Detailed logs of what your code printed during execution
- **Standard Error Logs**: Any error messages or warnings generated during execution
- **Error**: Specific error messages if the execution failed
### Possible use cases
1. **Educational Platform**: Teachers can create interactive coding exercises where students can write and test code in various languages
2. **Code Testing Environment**: Developers can test potentially risky code in a safe, isolated environment
3. **API Testing**: Testing API integrations without affecting the main system
4. **Code Demonstrations**: Creating live code demonstrations for presentations or tutorials
5. **Package Compatibility Testing**: Testing software packages and their dependencies in an isolated environment
### Notes
- The sandbox includes pre-installed package managers like pip and npm
- Internet access is available within the sandbox
- The environment is Debian-based
- Each execution runs in isolation to ensure security
- CPU and memory customization is available through sandbox templates