#![allow(clippy::missing_errors_doc)]
#![allow(missing_docs)]
#![allow(clippy::unused_async)]
use aither::Result;
use aither_derive::tool;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[tool(description = "Get current time in UTC")]
pub async fn time() -> Result<&'static str> {
Ok("2023-10-01T12:00:00Z")
}
#[derive(Debug, Serialize)]
pub struct SearchResult {
title: String,
url: String,
}
#[tool(description = "Search on the web")]
pub async fn search(keywords: Vec<String>, max_results: u32) -> Result<Vec<SearchResult>> {
let results = keywords
.into_iter()
.take(max_results as usize)
.map(|keyword| SearchResult {
title: format!("Result for {keyword}",),
url: format!("https://example.com/search?q={keyword}",),
})
.collect();
Ok(results)
}
#[derive(Debug, JsonSchema, Deserialize)]
pub struct GenerateImageArgs {
pub prompt: String,
pub images: Vec<String>,
}
#[tool(description = "Generate an image from a text prompt")]
pub async fn generate_image(args: GenerateImageArgs) -> aither::Result<String> {
let file_name = format!("image_{}.png", args.prompt.replace(' ', "_"));
Ok(format!(
"Generated image '{file_name}' with prompt '{}'",
args.prompt
))
}
fn main() {}