use async_trait::async_trait;
use serde_json::Value;
use crate::tools::LlmTool;
pub struct RenamedTool {
inner: Box<dyn LlmTool>,
name: String,
description: Option<String>,
}
impl RenamedTool {
pub fn new(inner: Box<dyn LlmTool>, name: &str, description: Option<&str>) -> Self {
Self {
inner,
name: name.to_owned(),
description: description.map(str::to_owned),
}
}
}
#[async_trait]
impl LlmTool for RenamedTool {
fn name(&self) -> &str {
&self.name
}
fn description(&self) -> &str {
self.description
.as_deref()
.unwrap_or_else(|| self.inner.description())
}
fn parameters_schema(&self) -> Value {
self.inner.parameters_schema()
}
async fn call(&self, args_json: &str) -> anyhow::Result<String> {
self.inner.call(args_json).await
}
}