Predictable development for unpredictable models. Let the compiler handle the chaos.
use rsai::{llm, Provider, completion_schema, LlmError};
use rsai_macros::{tool, toolset};
#[tool]
/// Get weather for a city
fn get_weather(city: String) -> String {
format!("{}°C in {}", 22, city)
}
#[completion_schema]
struct Weather {
temperature: f32,
description: String,
}
async fn weather_report() -> Result<Weather, LlmError> {
let response = llm::with(Provider::OpenAI)
.model("gpt-4o-mini")
.tools(toolset![get_weather])
.complete::<Weather>()
.await?;
Ok(response.content)
}