use llm_connector::LlmClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("đ Comparing supported_models() vs fetch_models()\n");
println!("ââââââââââââââââââââââââââââââââââââââââ");
println!("Example 1: OpenAI Protocol");
println!("ââââââââââââââââââââââââââââââââââââââââ\n");
let openai_client = LlmClient::openai("test-key");
println!("đĻ supported_models() - Static/Cached:");
let static_models = openai_client.supported_models();
println!(" Returns: {:?}", static_models);
println!(" âšī¸ This is fast but returns empty for OpenAI\n");
println!("đ fetch_models() - Online from API:");
println!(" âšī¸ This makes an API call to get real-time model list");
println!(" â ī¸ Requires valid API key\n");
println!("ââââââââââââââââââââââââââââââââââââââââ");
println!("Example 2: DeepSeek (OpenAI-compatible)");
println!("ââââââââââââââââââââââââââââââââââââââââ\n");
if let Ok(keys_content) = std::fs::read_to_string("keys.yaml") {
use serde::{Deserialize};
#[derive(Debug, Deserialize)]
struct ProviderConfig {
api_key: String,
base_url: String,
}
#[derive(Debug, Deserialize)]
struct KeysConfig {
providers: std::collections::HashMap<String, ProviderConfig>,
}
if let Ok(config) = serde_yaml::from_str::<KeysConfig>(&keys_content) {
if let Some(deepseek) = config.providers.get("deepseek") {
let client = LlmClient::openai_compatible(
&deepseek.api_key,
&deepseek.base_url,
);
println!("đĻ supported_models():");
let static_models = client.supported_models();
println!(" Returns: {:?}", static_models);
println!(" â
Empty - no hardcoded models\n");
println!("đ fetch_models():");
match client.fetch_models().await {
Ok(models) => {
println!(" â
Success! Found {} models", models.len());
println!(" Models: {:?}", models);
println!(" â
Real-time data from DeepSeek API");
}
Err(e) => {
println!(" â Error: {}", e);
}
}
}
}
} else {
println!(" âšī¸ keys.yaml not found - skipping live test");
}
println!("\nââââââââââââââââââââââââââââââââââââââââ");
println!("đ Summary");
println!("ââââââââââââââââââââââââââââââââââââââââ\n");
println!("supported_models():");
println!(" â
Fast - no API call");
println!(" â
No authentication needed");
println!(" â Returns empty for OpenAI protocol");
println!(" â May be outdated for other protocols\n");
println!("fetch_models():");
println!(" â
Real-time data from API");
println!(" â
Always up-to-date");
println!(" â
Works with OpenAI-compatible providers");
println!(" â Requires API call (slower)");
println!(" â Requires valid API key");
println!(" â Not supported by all protocols\n");
println!("đĄ Recommendation:");
println!(" - Use fetch_models() when you need the latest model list");
println!(" - Use supported_models() for quick checks (if available)");
println!(" - Cache fetch_models() results to avoid repeated API calls\n");
Ok(())
}