Skip to main content

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


Download files

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

Source Distribution

dspy_monty_interpreter-0.1.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

dspy_monty_interpreter-0.1.5-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file dspy_monty_interpreter-0.1.5.tar.gz.

File metadata

  • Download URL: dspy_monty_interpreter-0.1.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for dspy_monty_interpreter-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c8fdfe3649b3ba29cd697fd2db2c11df928af92b77b475342ec48584aada3341
MD5 93e8f9e9fce6b4025d6e42f4a232a6ea
BLAKE2b-256 c01b29ddab0a8b96c6bb74298210efdf15cdf8bedb0bbdcc3c60048d41dd8309

See more details on using hashes here.

File details

Details for the file dspy_monty_interpreter-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for dspy_monty_interpreter-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 03b0bcd00b4b82c39af388ddb24d63bd19329b73efad1391cdd244758ac63b38
MD5 349f66ee8d5b0f1fa10e9fc4e762b770
BLAKE2b-256 97ba5687e54f17d5c174c732ed312b37cdbb813847406a526212b70e886ce0cd

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