Skip to main content

Code Interpreter Library

Project description

cillow

Code Interpreter Library


cillow version cillow CI status cillow codecov cillow license

Cillow is an open-source library that enables you to execute AI-generated code in a controlled environment. The name "Cillow" follows the same naming convention as "Pillow" (Python Imaging Library), representing its role as a Code Interpreter Library.

It offers key features such as:

  • Environment Switching: Easily switch between multiple python environments.
  • Automated Package Management: Automatic installation of imported packages through uv or pip.
  • Functionality Patches: Apply patches to limit the scope of AI-generated code, capture outputs like stdout, stderr, images, plots, etc., and more.

Check Documentation

Visit synacktra.is-a.dev/cillow

Installation

pip install cillow

Hosting a server

import cillow

cillow.add_patches(
    cillow.prebuilt_patches.patch_stdout_stderr_write,
    cillow.prebuilt_patches.patch_matplotlib_pyplot_show,
    cillow.prebuilt_patches.patch_pillow_show,
)

if __name__ == "__main__":
    server = cillow.Server(
        port=5556, max_interpreters=2, interpreters_per_client=1
    )
    server.run()

Running code through a client

import cillow

client = cillow.Client.new(host="127.0.0.1", port=5556)

client.run_code("""
from PIL import Image, ImageDraw

img = Image.new('RGB', (400, 300), 'white')

draw = ImageDraw.Draw(img)
draw.rectangle([50, 50, 350, 250], outline='black', width=3)
draw.ellipse([100, 100, 300, 200], outline='purple', width=3)
draw.line([50, 250, 350, 250], fill='blue', width=3)

img.show()
""")

At the moment, Cillow only supports Python since it doesn't use Jupyter Kernel.

This project began as an exploration of E2B's code interpreter. I implemented the Python interpreter from scratch using ZeroMQ, taking a different approach by adding features like environment switching and functionality patching. Seeing the potential in this project, I evolved it into a client-server architecture using threading and multiprocessing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cillow-0.1.1.tar.gz (28.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cillow-0.1.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file cillow-0.1.1.tar.gz.

File metadata

  • Download URL: cillow-0.1.1.tar.gz
  • Upload date:
  • Size: 28.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cillow-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5a1e8718be81c652b7d692aab288da82e7964edb510c024cc800afae407b33ac
MD5 1781a3e3fc641309a68241ddcffb7de8
BLAKE2b-256 95ff54c14e3a0d97d55fcbc3131bf9ab4d69ad2e393a67d4334d2e5111598a9a

See more details on using hashes here.

File details

Details for the file cillow-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cillow-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cillow-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08ea5cf61e2522ee10c9452f2d34b218d88b9c2b73001f0ddcabee565bb0f083
MD5 62b73b58c9d4939e48c85a91e438a714
BLAKE2b-256 64058d977c27af4ee5d6fb490f3ba5bc2aecb05e96cf3001fc2639ebcb040a30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page