use llm::{
builder::{LLMBackend, LLMBuilder}, chat::ChatMessage, };
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("GOOGLE_API_KEY").unwrap_or("google-key".into());
let llm = LLMBuilder::new()
.backend(LLMBackend::Google) .api_key(api_key) .model("gemini-2.0-flash-exp") .max_tokens(8512) .temperature(0.7) .system("You are a helpful AI assistant specialized in programming.")
.build()
.expect("Failed to build LLM (Google)");
let messages = vec![
ChatMessage::user()
.content("Explain the concept of async/await in Rust")
.build(),
ChatMessage::assistant()
.content("Async/await in Rust is a way to write asynchronous code...")
.build(),
ChatMessage::user()
.content("Can you show me a simple example?")
.build(),
];
match llm.chat(&messages).await {
Ok(text) => println!("Google Gemini response:\n{text}"),
Err(e) => eprintln!("Chat error: {e}"),
}
Ok(())
}