Rig Framework Integration
LLMG integrates with the Rig agent framework via the RigAdapter.
[dependencies]llmg-core = "0.1.9"llmg-providers = { version = "0.1.9", features = ["openai"] }use llmg_core::rig::RigAdapter;use llmg_providers::openai::OpenAiClient;
#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> { // 1. Setup provider-agnostic client let mut registry = llmg_core::provider::ProviderRegistry::new(); llmg_providers::utils::register_all_from_env(&mut registry); let client = llmg_core::provider::RoutingProvider::new(registry);
// 2. Create adapter with specific model (routes automatically) let adapter = RigAdapter::new(client, "openai/gpt-4"); // or "anthropic/claude-3-opus"
let completion = adapter .completion() .system("You are a helpful assistant") .user("Hello!") .send() .await?;
println!("{}", completion); Ok(())}The RigAdapter wraps any LLMG provider to make it compatible with Rig’s CompletionModel trait.