use llmkit::prelude::*;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, JsonSchema, ToolSchema)]
#[tool(name = "get_weather", description = "Get current weather for a city")]
struct GetWeatherInput {
city: String,
#[serde(default)]
units: Option<String>,
}
#[tokio::main]
async fn main() -> LlmResult<()> {
let client = LlmClientBuilder::new()
.provider(AnthropicProvider::from_env()?.model("claude-opus-4-8"))
.build()?;
let response = client
.chat(ChatRequest::builder().user("What's the weather in Karachi?").build())
.with_tool::<GetWeatherInput, _, _>(|input| async move {
Ok(format!("28°C in {}", input.city))
})
.await?;
println!("{}", response.text().unwrap_or_default());
Ok(())
}