rig-dyn
A dynamic client-provider abstraction framework for Rust applications on top of rig-core.
Overview
rig-dyn is a Rust library that provides a flexible client-provider architecture for building modular and extensible applications. It leverages asynchronous Rust to deliver a seamless experience when working with various service providers. It enables users to use all of the LLM providers supported by rig-core, without having to repeat similar code for each provider, using a simple and intuitive API. This library is meant to be used with rig-core, as it only abstracts the client-provider communication and provides a simpler API for working with LLM providers. It in no way replaces rig-core or any of its underlying providers, or performs any kind of optimization or API calls on it's own.
Features
- 🔄 Dynamic provider registration and discovery
- 🔒 Type-safe client-provider communication
- ⚡ Asynchronous API built on top of
async-trait - 🧩 Extensible architecture through traits
- 🔌 Simple plugin system for custom providers
- 🔧 Serialization and deserialization with
serde
Installation
Add rig-dyn to your Cargo.toml:
[]
= "0.1.0"
Usage
Basic Example
use env;
use Result;
use ;
use Provider;
async
Using the serde feature
The serde feature enables serialization and deserialization of the Provider enum, making it easy to save and load provider configurations from JSON, YAML, or other formats:
// Enable the serde feature in your Cargo.toml
// [dependencies]
// rig-dyn = { version = "0.1.0", features = ["serde"] }
use Result;
use Provider;
use ;
This feature is particularly useful when building applications that need to store user preferences or when working with configuration files that specify which provider to use.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Projects
- rig - A Rust library for interacting with LLM providers
- Tokio - Asynchronous runtime for Rust
- async-trait - Asynchronous trait methods in Rust
- serde - A powerful and efficient serialization and deserialization framework for Rust
Built with ❤️ using Rust