A modular Rust library for building RPC-based agents with pluggable provider integrations.
rpc-agent is a Rust crate that lets you build resilient, extensible agents which talk to LLM services over RPC. Leveraging the Rig framework, it supports multiple provider backends, currently OpenAI and Ollama, and is designed for straightforward extension and robust error handling.
- Modular agent architecture for easy extension
- Pluggable provider integrations (Ollama, OpenAI, etc.)
- Centralized error handling
- Async support (Tokio-based)
- Written in idiomatic Rust
Add this crate to your Cargo.toml:
[dependencies]
rpc-agent = "0.1.5"
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread"] }Here is a minimal example of how to set up and run an Ollama RPC agent:
use rpc_agent::Providers;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let builder = rpc_agent::AgentServerBuilder::new(
5500,
Providers::Ollama,
"You're a friendly assistant",
"gpt-oss:20b",
);
let server = builder.build()?;
server.run().await?;
Ok(())
}Note: Adjust the parameters as needed for your provider and use case. See the source files for more details and available options.
tracing: Enables tracing for logging request/response traces. It requires a RUST_LOG environment variable to be set.
Pull requests and issues are welcome! Please open an issue to discuss your ideas or report bugs.
This project is licensed under the MIT License.