This project leverages Rig and Actix-web for building a fast, asynchronous web server with Rig, that helps you "build modular and scalable LLM Applications in Rust".
OpenAI has been used here (so you will need to set the API key in your env). Rig allows you to easily switch LLM providers.
https://actix.rs/
https://rig.rs/
- Rig: Rig is a Rust library for building portable, modular, and lightweight Fullstack AI Agents. You can find API documentation on docs.rs.
- Actix-web: A fast and powerful web framework for Rust, designed for asynchronous operations.
- Rig Tools: Tools are a core concept in Rig that allow agents to perform specific actions or computations. They provide a structured way to extend an agent’s capabilities beyond pure language model interactions.
Avoid using #[tokio::main] in "run", as Actix already provides an async context. Instead, just make run a regular async function without creating a new (tokio) runtime.
("run" is the name that I used in rig.rs for the function that calls the LLM).
You can't start a Tokio runtime from within another Tokio runtime - so if you ever build everything in main.rs to begin with and then refactor yoru code, make sure your "new" main.rs with the actix-web entry point, is calling the function from another file which does NOT have #[tokio::main] above it!
-
Clone the repository:
git clone https://github.com/RGGH/actix_rig cd actix_rig
-
Install dependencies:
cargo build
-
Create a
.env
file and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key
-
Run the project:
cargo run
-
Run Python test.py:
cd tests/ python3 test.py
-
Efficient, async HTTP handling with Actix-web.
-
Use LLM's with Rust and tools written in Rust.
-
Scalable and easily extensible API structure.
-
Create endpoint for query
- Implement a basic endpoint to handle query requests.
-
Pass query/queries as input parameter(s)
- Modify the endpoint to accept query as an input parameter.
-
Start a Docker Container as an Agent
- Bring your own Docker image
-
Build MVP front end
- Create a minimal front end to interact with the endpoint(s).
This project is licensed under the MIT License.