# 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
```bash
pip install llmexec
```
## Usage
```python
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
[MIT License](https://github.com/your-username/llmexec/blob/main/LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/Bam-Corp/llmexec",
"name": "llmexec",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "llmexec, code execution, ai-generated code",
"author": "Bam Corp",
"author_email": "spencer@bam.bot",
"download_url": "https://files.pythonhosted.org/packages/7f/31/8614c485bfec99951702e97d6155205cb36cfb907746e440728e77c2e96d/llmexec-0.1.1.tar.gz",
"platform": null,
"description": "# llmexec: Execute LLM-Generated Python Code\n\n`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.\n\n## Installation\n\n```bash\npip install llmexec\n```\n\n## Usage\n\n```python\nfrom llmexec import llmexec\n\n# LLM-generated code\nllm_output = \"\"\"\n# Generate random data plot using matplotlib\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nx = np.random.rand(10) # 10 random x values\ny = np.random.rand(10) # 10 random y values\n\nfig, ax = plt.subplots()\nax.scatter(x, y)\nax.set_xlabel('X')\nax.set_ylabel('Y')\nax.set_title('Random Data Plot')\nplt.show()\n\"\"\"\n\n# Execute the LLM-generated code\nllmexec(llm_output)\n```\n\n`llmexec` will automatically parse and execute the LLM-generated code snippet, displaying a random data plot using `matplotlib`.\n\n## Features\n\n- Automatically execute LLM-generated code snippets\n- Parses out code from LLM outputs\n- Trusted execution environment using `restrictedpython`\n- Detailed logs and execution status\n- Timeout and memory limits to prevent abuse\n\n## License\n\n[MIT License](https://github.com/your-username/llmexec/blob/main/LICENSE)\n",
"bugtrack_url": null,
"license": null,
"summary": "Execute LLM-Generated Python Code Automatically",
"version": "0.1.1",
"project_urls": {
"Bug Tracker": "https://github.com/Bam-Corp/llmexec/issues",
"Homepage": "https://github.com/Bam-Corp/llmexec",
"Source Code": "https://github.com/Bam-Corp/llmexec"
},
"split_keywords": [
"llmexec",
" code execution",
" ai-generated code"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ae3ce9c9d694b1720b570cdb48a862cea4c35e1c09615689cd58305bb7f3ffba",
"md5": "0a55637644eac6068d6bb7b73357e473",
"sha256": "14f941f22ef4561115f085b24aba6326d3be3fd44e16861e6293b76c25ab0801"
},
"downloads": -1,
"filename": "llmexec-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a55637644eac6068d6bb7b73357e473",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5472,
"upload_time": "2024-06-14T04:20:29",
"upload_time_iso_8601": "2024-06-14T04:20:29.535633Z",
"url": "https://files.pythonhosted.org/packages/ae/3c/e9c9d694b1720b570cdb48a862cea4c35e1c09615689cd58305bb7f3ffba/llmexec-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7f318614c485bfec99951702e97d6155205cb36cfb907746e440728e77c2e96d",
"md5": "3ea42fb2682e9573afcfdc25a226da2f",
"sha256": "cf9c2835cff65f01d83e534c39e557d6b6e70d86788e3db55f9d8bf4f99ee44f"
},
"downloads": -1,
"filename": "llmexec-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3ea42fb2682e9573afcfdc25a226da2f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6586,
"upload_time": "2024-06-14T04:20:30",
"upload_time_iso_8601": "2024-06-14T04:20:30.789003Z",
"url": "https://files.pythonhosted.org/packages/7f/31/8614c485bfec99951702e97d6155205cb36cfb907746e440728e77c2e96d/llmexec-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-14 04:20:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Bam-Corp",
"github_project": "llmexec",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "llmexec"
}