40 lines
996 B
Rust
40 lines
996 B
Rust
//! Delete a memory by name.
|
|||
|
|
|
||
|
|
use crate::tools::{Tool, ToolCtx};
|
||
|
|
use anyhow::Result;
|
||
|
|
use serde_json::{json, Value};
|
||
|
|
|
||
|
|
use zesdex_domain::cms::MemoryRepository;
|
||
|
|
|
||
|
|
pub struct Forget;
|
||
|
|
|
||
|
|
impl Tool for Forget {
|
||
|
|
fn name(&self) -> &'static str {
|
||
|
|
"forget"
|
||
|
|
}
|
||
|
|
|
||
|
|
fn description(&self) -> &'static str {
|
||
|
|
"Delete a saved memory by name"
|
||
|
|
}
|
||
|
|
|
||
|
|
fn parameters(&self) -> Value {
|
||
|
|
json!({
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"name": {
|
||
|
|
"type": "string",
|
||
|
|
"description": "Name of the memory to delete"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"required": ["name"]
|
||
|
|
})
|
||
|
|
}
|
||
|
|
|
||
|
|
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||
|
|
let name = crate::tools::arg_str(args, "name")?;
|
||
|
|
let repo = crate::persistence::cms::memory_repo::MarkdownMemoryRepository::new();
|
||
|
|
repo.delete(&ctx.memory_dir, &name)?;
|
||
|
|
Ok(format!("Memory '{}' deleted", name))
|
||
|
|
}
|
||
|
|
}
|