crew-python-runner
Allows crew.ai agents to run python code in dockerized containers.
LLM code should not be run locally on your system, but we would like the ability of crew.ai agents to run Python code so they can see that it works.
crew_python_runner will take your agents code and run it in a Docker instance, so you can be sure that nothing bad will happen to your code.
Installation
You will need Docker installed on your system
pip install crew_python_runner
Note that crew_python_runner has a dependency on crewai[tools], which has quite a lot of dependencies; this is likely not an issue if you have crewai already in your virtual environment.
Setup
On importing, a docker container will start running in the background. The first time this happens, it may have to download the docker image that it uses (python:3.11) so it is suggested you run the command
python -c "import crew_python_runner"
Before using the library, as otherwise you may see a delay in usage. Alternatively, pull the image from docker yourself on the command line
docker image pull python:3.11
Usage
To use as a crew.ai tool:
from crew_python_runner import runner
# this is just an example - setup your agent however you like
programmer = Agent(
role='Senior Python Programmer',
goal='Write simple, well crafted and bug-free Python code',
backstory='You are a skilled Python programmer with a passion for writing working Python code',
tools=[python_runner])
If you want to test it yourself:
from crew_python_runner import runner
result = runner.run_python('print("Hello, World!"))
This returns a class with 2 variables, error_code, an integer, and output, a string of the python output. In this case error_code will be 0 (meaning no error) and output will be Hello, World!.
Future Enhancements
- Another tool giving coder agents the ability to pip install packages.
- The tool will auto-restart the docker instance if it falls over (which could be because of rogue code).
- The ability to log all code and results.
Metadata
Release files for crew-python-runner 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crew_python_runner-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / crew_python_runner-0.2.1-py3-none-any.whl
| Download URL | crew_python_runner-0.2.1-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdf2b39e98d2f61d095a40093a1438e57efc42f8adad05eb8f633a6edb601ca4
|
|
BLAKE2b-256 checksum How to use checksums |
0e64048e86fdb2fc702fc92f1a167ff82f6c90dfd4c17aaa5ef0099e2a7937b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|
Security for crew-python-runner 0.2.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.