mirror of
https://github.com/mii443/rust-genai.git
synced 2025-08-22 16:25:27 +00:00
28 lines
661 B
Rust
28 lines
661 B
Rust
//! Example showing how to get the list of models per AdapterKind
|
|
//! Note: Currently, only Ollama makes a dynamic query. Other adapters have a static list of models.
|
|
|
|
use genai::adapter::AdapterKind;
|
|
use genai::Client;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
const KINDS: &[AdapterKind] = &[
|
|
AdapterKind::OpenAI,
|
|
AdapterKind::Ollama,
|
|
AdapterKind::Gemini,
|
|
AdapterKind::Anthropic,
|
|
AdapterKind::Groq,
|
|
AdapterKind::Cohere,
|
|
];
|
|
|
|
let client = Client::default();
|
|
|
|
for &kind in KINDS {
|
|
println!("\n--- Models for {kind}");
|
|
let models = client.all_model_names(kind).await?;
|
|
println!("{models:?}");
|
|
}
|
|
|
|
Ok(())
|
|
}
|