use std::fs;
use llm::{
builder::{LLMBackend, LLMBuilder}, chat::{ChatMessage, ImageMime}, };
#[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 content = fs::read("./examples/image001.jpg").expect("The image001.jpg file should exist");
let messages = vec![
ChatMessage::user()
.content("Explain what you see in the image")
.build(),
ChatMessage::user().image(ImageMime::JPEG, content).build(),
];
match llm.chat(&messages).await {
Ok(text) => println!("Google Gemini response:\n{text}"),
Err(e) => eprintln!("Chat error: {e}"),
}
Ok(())
}