use llm::{
builder::{LLMBackend, LLMBuilder}, chat::ChatMessage, };
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("OPENAI_API_KEY").unwrap_or("sk-TESTKEY".into());
let llm = LLMBuilder::new()
.backend(LLMBackend::OpenAI) .api_key(api_key) .model("gpt-4o-search-preview") .max_tokens(512) .openai_enable_web_search(true) .openai_web_search_context_size("low") .openai_web_search_user_location_type("approximate") .openai_web_search_user_location_approximate_country("US") .openai_web_search_user_location_approximate_city("Los Angeles") .openai_web_search_user_location_approximate_region("California") .build()
.expect("Failed to build LLM (OpenAI)");
let messages = vec![ChatMessage::user()
.content("What are the latest news from Los Angeles?")
.build()];
match llm.chat(&messages).await {
Ok(text) => println!("Chat response:\n{text}"),
Err(e) => eprintln!("Chat error: {e}"),
}
Ok(())
}