From 5c0874ab85d25d1e2276a3c1031a63bbfbaf6459 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 22 Apr 2025 16:20:26 -0700 Subject: [PATCH] dave: give present notes a proper tool response so the ai know we actually did something --- crates/notedeck_dave/src/lib.rs | 4 ++-- crates/notedeck_dave/src/tools.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs index e482343..051e482 100644 --- a/crates/notedeck_dave/src/lib.rs +++ b/crates/notedeck_dave/src/lib.rs @@ -129,10 +129,10 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr for call in &toolcalls { // execute toolcall match call.calls() { - ToolCalls::PresentNotes(_note_ids) => { + ToolCalls::PresentNotes(present) => { self.chat.push(Message::ToolResponse(ToolResponse::new( call.id().to_owned(), - ToolResponses::PresentNotes, + ToolResponses::PresentNotes(present.note_ids.len() as i32), ))); should_send = true; diff --git a/crates/notedeck_dave/src/tools.rs b/crates/notedeck_dave/src/tools.rs index 8d71a29..40303b1 100644 --- a/crates/notedeck_dave/src/tools.rs +++ b/crates/notedeck_dave/src/tools.rs @@ -93,7 +93,7 @@ pub struct QueryResponse { pub enum ToolResponses { Error(String), Query(QueryResponse), - PresentNotes, + PresentNotes(i32), } #[derive(Debug, Clone)] @@ -499,7 +499,7 @@ struct SimpleNote { /// it can interepret it and take further action fn format_tool_response_for_ai(txn: &Transaction, ndb: &Ndb, resp: &ToolResponses) -> String { match resp { - ToolResponses::PresentNotes => "".to_string(), + ToolResponses::PresentNotes(n) => format!("{n} notes presented to the user"), ToolResponses::Error(s) => format!("error: {}", &s), ToolResponses::Query(search_r) => {