Python sandbox for executing untrusted LLM-generated code
Top 94.5% on sourcepulse
Terrarium provides a secure, low-latency Python sandbox for executing untrusted LLM-generated code, targeting developers building data agents. It offers an economical solution for running Python scripts, generating visualizations, and processing data within a compartmentalized environment, with quick execution times and low hosting costs.
How It Works
Terrarium leverages Pyodide, a CPython distribution compiled to WebAssembly, to run Python code within a Node.js process. This approach isolates execution by providing a memory-only filesystem, preventing access to the host's memory or network. Each sandbox instance is completely recycled after every invocation, ensuring no state is carried over between calls.
Quick Start & Requirements
npm install
npm run dev
curl -X POST -H "Content-Type: application/json" --url http://localhost:8080 --data-raw '{"code": "1 + 1"}'
Highlighted Details
plt.savefig()
supported for Matplotlib; plt.show()
is not.Maintenance & Community
Licensing & Compatibility
Limitations & Caveats
Package installation, network access, and complex computations can be challenging. Pyodide may encounter "Maximum call stack size exceeded" errors with very high DPI settings or complex Pandas operations.
1 year ago
Inactive