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.0.tar.gz (28.5 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.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cillow-0.1.0.tar.gz
  • Upload date:
  • Size: 28.5 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.0.tar.gz
Algorithm Hash digest
SHA256 01c397ea8a81c26e0d4cbad7c940be9f1b3407623a37146fa4684436754d32bb
MD5 e56371643705f0b5829e98faabfefec1
BLAKE2b-256 c094522399da9f47dfb18c6a9faabc0d6399a7a18c43fc1e471abf2e582a4b9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cillow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ffd8bc1ef4c39042fd805025921bc5590c96a1d72ae8872110985840b120c0c
MD5 db30135449b29d1f705eb6bbf1815d2c
BLAKE2b-256 6a87d8e1d5d6b366b1136304c697cf7acb334724b455e10a48c237ae64ed2da3

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