DSPy CodeInterpreter implementation using Monty, a secure Python interpreter written in Rust
Project description
dspy-monty-interpreter (pre-release!)
This code interpreter has issues, some due to Monty coverage and some due to how state is being persisted across calls.
DSPy CodeInterpreter implementation using Monty, a secure Python interpreter written in Rust.
Installation
pip install dspy-monty-interpreter
Usage
import dspy
from dspy_monty_interpreter import MontyInterpreter
interpreter = MontyInterpreter()
rlm = dspy.RLM("context -> answer", interpreter=interpreter)
result = rlm(context="What is 2 + 2?")
Standalone usage
from dspy_monty_interpreter import MontyInterpreter
interp = MontyInterpreter()
# Basic execution
interp.execute("x = 42")
interp.execute("print(x + 8)") # returns "50"
# State persists across calls
interp.execute("def double(n):\n return n * 2")
interp.execute("double(21)") # returns "42"
# With tools
def lookup(key: str) -> str:
return "some value"
interp = MontyInterpreter(tools={"lookup": lookup})
interp.execute('result = lookup(key="foo")\nprint(result)')
Why Monty?
- Fast: Microsecond startup (no subprocess, no WASM bootstrap)
- Secure: No filesystem, network, or environment access by default
- Lightweight: Pure Rust, no Deno/Pyodide dependency
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dspy_monty_interpreter-0.1.1.tar.gz.
File metadata
- Download URL: dspy_monty_interpreter-0.1.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c896c415e14cf26cbc0bf611ad10a5750d7f952542f710403ac8aad828c0c85f
|
|
| MD5 |
3d7d5a0164cb805e60a449e97ac787ca
|
|
| BLAKE2b-256 |
2c023015655d9b53077f0e33314b3b1f3b1f2411c0640bc13aa60b16b5b6ad22
|
File details
Details for the file dspy_monty_interpreter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: dspy_monty_interpreter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e14b57cc8cfb543131738036eba1382d876b00ad4e367ad9d7d2b3c44bbf6fec
|
|
| MD5 |
83bdb5c9c84b34e3dfad8b291550aeba
|
|
| BLAKE2b-256 |
d866ca86b43a5c1c132f8b67807afdfa3532ab70818d172bed1bde72d71691c4
|