llmexec: Execute LLM-Generated Python Code
llmexec is a Python library that allows you to automatically execute python code snippets generated by large language models (LLMs). It's useful for projects that require automated code generation and execution and is a drop-in replacement for the python exec() function.
Installation
pip install llmexec
Usage
from llmexec import llmexec
# LLM-generated code
llm_output = """
# Generate random data plot using matplotlib
import matplotlib.pyplot as plt
import numpy as np
x = np.random.rand(10) # 10 random x values
y = np.random.rand(10) # 10 random y values
fig, ax = plt.subplots()
ax.scatter(x, y)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_title('Random Data Plot')
plt.show()
"""
# Execute the LLM-generated code
llmexec(llm_output)
llmexec will automatically parse and execute the LLM-generated code snippet, displaying a random data plot using matplotlib.
Features
- Automatically execute LLM-generated code snippets
- Parses out code from LLM outputs
- Trusted execution environment using
restrictedpython - Detailed logs and execution status
- Timeout and memory limits to prevent abuse
License
Metadata
Release files for llmexec 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llmexec-0.1.1.tar.gz | 6.6 kB | Without provenance | Details for llmexec-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llmexec-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for llmexec-0.1.1-py3-none-any.whl |
Total release size: 12.1 kB
Release files / llmexec-0.1.1.tar.gz
| Download URL | llmexec-0.1.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf9c2835cff65f01d83e534c39e557d6b6e70d86788e3db55f9d8bf4f99ee44f
|
|
BLAKE2b-256 checksum How to use checksums |
7f318614c485bfec99951702e97d6155205cb36cfb907746e440728e77c2e96d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.10
|
Release files / llmexec-0.1.1-py3-none-any.whl
| Download URL | llmexec-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14f941f22ef4561115f085b24aba6326d3be3fd44e16861e6293b76c25ab0801
|
|
BLAKE2b-256 checksum How to use checksums |
ae3ce9c9d694b1720b570cdb48a862cea4c35e1c09615689cd58305bb7f3ffba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.10
|
Security for llmexec 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.