use async_trait::async_trait;
use serde_json::json;
use crate::ctx::ToolCtx;
use crate::tool::{Tool, ToolDescriptor, ToolError, ToolResponse};
#[derive(Debug)]
#[non_exhaustive]
pub struct CleanTool {
descriptor: ToolDescriptor,
}
impl CleanTool {
pub fn new() -> Self {
Self {
descriptor: ToolDescriptor::agent(
"clean",
json!({
"type": "object",
"properties": {
"text": { "type": "string", "description": "Text to redact." }
},
"required": ["text"]
}),
)
.with_description("Redact PII in the supplied text via the gaze pipeline."),
}
}
}
impl Default for CleanTool {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl Tool for CleanTool {
fn descriptor(&self) -> &ToolDescriptor {
&self.descriptor
}
async fn invoke(&self, ctx: &ToolCtx<'_>) -> Result<ToolResponse, ToolError> {
Ok(ToolResponse::json(ctx.redacted_args().clone()))
}
}