use async_trait::async_trait;
use serde_json::Value;
use crate::types::chat::{FunctionDefinition, ToolDefinition, ToolType};
#[async_trait]
pub trait LlmTool: Send + Sync {
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
#[must_use]
fn to_tool_definition(&self) -> ToolDefinition {
ToolDefinition {
kind: ToolType::Function,
function: FunctionDefinition {
name: self.name().to_owned(),
description: Some(self.description().to_owned()),
parameters: Some(self.parameters_schema()),
strict: None,
},
}
}
async fn call(&self, args_json: &str) -> anyhow::Result<String>;
}