https://github.com/synacktraa/cillow
Code Interpreter Library
https://github.com/synacktraa/cillow
ai code-interpreter llm python
Last synced: 7 months ago
JSON representation
Code Interpreter Library
- Host: GitHub
- URL: https://github.com/synacktraa/cillow
- Owner: synacktraa
- License: mit
- Created: 2025-01-11T08:20:26.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-26T21:06:46.000Z (8 months ago)
- Last Synced: 2025-06-26T22:45:21.452Z (8 months ago)
- Topics: ai, code-interpreter, llm, python
- Language: Python
- Homepage: https://synacktraa.github.io/cillow
- Size: 1020 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Support: docs/supported_languages.md
Awesome Lists containing this project
README
---
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**: Effortlessly switch between multiple Python environments.
- **Automated Package Installation**: Automatically install imported packages using `uv` or `pip`.
- **Functionality Patches**: Apply patches to restrict the scope of AI-generated code, capture outputs such as `stdout`, `stderr`, images, plots, and more.
### Check Documentation
Visit [synacktraa.github.io/cillow](https://synacktraa.github.io/cillow)
### Installation
```bash
pip install cillow
```
### Hosting a server
```python
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
```python
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, as it does not rely on Jupyter Kernel/Lab.
This project began as an exploration of [E2B](https://e2b.dev/)'s code interpreter. I implemented the Python interpreter from scratch, taking a different approach by adding features like environment switching and functionality patching. Recognizing the potential of the project, I expanded it into a client-server architecture using ZeroMQ, threading, and multiprocessing.