llm-sandbox  by vndee

LLM code execution sandbox using Docker containers

created 1 year ago
415 stars

Top 71.7% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This library provides a lightweight and portable sandbox runtime for executing LLM-generated code securely using Docker containers. It's designed for developers and researchers who need to safely run code snippets from LLMs in isolated environments, supporting multiple programming languages and offering flexibility through custom Dockerfiles and integrations with AI frameworks like Langchain and LlamaIndex.

How It Works

The core of the library is the SandboxSession class, which manages the lifecycle of Docker containers for code execution. It leverages Docker to create isolated environments, allowing for the execution of code in various languages (Python, Java, JavaScript, C++, Go, Ruby) within a controlled setup. The approach emphasizes ease of use, portability via predefined or custom Docker images, and scalability with support for Kubernetes and remote Docker hosts.

Quick Start & Requirements

  • Install via pip: pip install llm-sandbox or with extras: pip install llm-sandbox[kubernetes], pip install llm-sandbox[podman], pip install llm-sandbox[docker].
  • Requires Docker or Podman to be installed and running.
  • Kubernetes support requires kubernetes Python package and a configured Kubernetes cluster.
  • See examples for detailed usage: README examples

Highlighted Details

  • Supports Python, Java, JavaScript, C++, Go, and Ruby.
  • Integrates with Langchain and LlamaIndex for AI agent code execution.
  • Offers Kubernetes and remote Docker host support.
  • Allows file copying between host and sandbox.

Maintenance & Community

  • Contributions are welcomed, with areas for improvement including more languages, security enhancements, and AI framework integrations.
  • Changelog available at CHANGELOG.md.

Licensing & Compatibility

  • Licensed under the MIT License.
  • Permissive license suitable for commercial use and integration into closed-source projects.

Limitations & Caveats

The project is actively seeking contributions for enhancements such as improved resource monitoring accuracy and container pooling for performance. Specific security scanning patterns and distributed execution capabilities are listed as areas for future development.

Health Check
Last commit

1 week ago

Responsiveness

1 day

Pull Requests (30d)
4
Issues (30d)
3
Star History
163 stars in the last 90 days

Explore Similar Projects

Starred by Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind), Tim J. Baek Tim J. Baek(Founder of Open WebUI), and
1 more.

harbor by av

0.3%
2k
CLI tool for local LLM stack orchestration
created 1 year ago
updated 3 weeks ago
Feedback? Help us improve.