Skip to main content

A simple package to run a ReAct agent with Ollama and tools with privileges to run code inside a docker container.

Project description

PyReact-Agent

PyReact-Agent is a Python package that provides tools for creating an LLM ReAct agent.

This package also includes tools that an LLM can use for running Bash or Python code inside Docker containers with enhanced control and flexibility. It is designed to be simple to use, making it easy to set up Docker environments and execute Python scripts, even from within a Jupyter Notebook.

Features

  • Create LLM ReAct Agents Easily: Create a ReAct agent with tools in just a few lines of code.
  • Framework for creating custom LLM Tools: Use the ToolSet classes to create custom toolsets, or turn any simple python function into a tool that an LLM can use
  • Build Docker Images: Build Docker images from a Dockerfile with a single function call.
  • Manage Containers: Start, stop, and fetch existing Docker containers programmatically.
  • Run Python Code in Docker: Start and interact with Python Docker containers seamlessly.

Roadmap

  • Integration with Open WebUI using Pipelines: Use Open WebUI's Pipelines to use ReAct agents from this package with the Open WebUI frontend framework
  • Integration with 3rd Party LLM Providers: Use this package with LLM providers. Currently only Ollama is supported.
  • RAG Integration: A simple in-package RAG system + integration with other 3rd party rag providers
  • Memory Management: Ability to self-manage memory for a single query, so that queries with multiple steps can be managed more gracefully.

Installation

To install PyReact-Agent, run:

pip install pyreact-agent

Usage

End-To-End

See example.py for a full end-to-end working example of how to create and run a ReAct agent with code writing tools.

Building a Docker Image

To build a Docker image using the Dockerfile in your project:

from pyreact_agent import docker_utils

docker_utils.build_docker_image(image_name="my-python-env")

Starting a Python Docker Environment

To start a Docker container and run Python code inside:

docker_utils.start_python_docker_environment(
    image_name="my-python-env",
    container_name="my-python-container",
    local_bound_dir="/path/to/your/local/dir"
)

Managing Containers

Start a Stopped Container

docker_utils.start_container_by_name("my-python-container")

Stop a Running Container

docker_utils.stop_container_by_name("my-python-container")

Get an Existing Container

container = docker_utils.get_container("my-python-container")

Get a Docker Image

image = docker_utils.get_image("my-python-env")

Requirements

  • Python 3.9 or higher
  • Docker installed and running
  • Ollama server (if running LLM locally)

Contributing

Contributions are welcome! If you have ideas, suggestions, or bug reports, please feel free to submit a pull request or open an issue on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Author

Cody Maughan GitHub Profile

Acknowledgments

  • Thanks to the Python and Docker communities for their incredible support and tools.

Happy coding with PyReact-Agent!

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

pyreact-agent-0.1.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

pyreact_agent-0.1.0-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file pyreact-agent-0.1.0.tar.gz.

File metadata

  • Download URL: pyreact-agent-0.1.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for pyreact-agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 51478c95852af93d724ae23dd77073d012f9a12510110d7fb1041e9fa40a67ab
MD5 b82370bd509bedbdc237480bc528a751
BLAKE2b-256 ccfcb3cb33f1dbe2d2325578568db8736da4607bc2da059ecb9a12dc64ce566a

See more details on using hashes here.

File details

Details for the file pyreact_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyreact_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for pyreact_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3332370249543d9cf58d6c3f2a145c57f31ed17a60ad626d2619cd8d9de31d65
MD5 3d1f2106df949c370945d5fb754789aa
BLAKE2b-256 23992006d129724d19732fe36f5e56feb584cdec35ea6a0bce769851d4e25b6b

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