44 lines
1.4 KiB
Rust
44 lines
1.4 KiB
Rust
|
|
use stratum_llm::{Message, Role, UnifiedClient};
|
||
|
|
|
||
|
|
#[tokio::main]
|
||
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
tracing_subscriber::fmt::init();
|
||
|
|
|
||
|
|
println!("Creating UnifiedClient with auto-detected providers...");
|
||
|
|
let client = UnifiedClient::auto()?;
|
||
|
|
|
||
|
|
println!("\nAvailable providers:");
|
||
|
|
for provider in client.providers() {
|
||
|
|
println!(
|
||
|
|
" - {} ({}): circuit={:?}, subscription={}",
|
||
|
|
provider.name, provider.model, provider.circuit_state, provider.is_subscription
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
let messages = vec![Message {
|
||
|
|
role: Role::User,
|
||
|
|
content: "What is the capital of France? Answer in one word.".to_string(),
|
||
|
|
}];
|
||
|
|
|
||
|
|
println!("\nSending request...");
|
||
|
|
match client.generate(&messages, None).await {
|
||
|
|
Ok(response) => {
|
||
|
|
println!("\n✓ Success!");
|
||
|
|
println!("Provider: {}", response.provider);
|
||
|
|
println!("Model: {}", response.model);
|
||
|
|
println!("Response: {}", response.content);
|
||
|
|
println!(
|
||
|
|
"Tokens: {} in, {} out",
|
||
|
|
response.input_tokens, response.output_tokens
|
||
|
|
);
|
||
|
|
println!("Cost: ${:.4}", response.cost_cents / 100.0);
|
||
|
|
println!("Latency: {}ms", response.latency_ms);
|
||
|
|
}
|
||
|
|
Err(e) => {
|
||
|
|
eprintln!("\n✗ Error: {}", e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Ok(())
|
||
|
|
}
|