feat: enhance goose to search sessions for easy recall (#5177)

This commit is contained in:
Michael Neale
2025-10-16 18:26:25 +11:00
committed by GitHub
parent 0ffd29ce8b
commit d142f4267d
7 changed files with 693 additions and 2 deletions
@@ -69,6 +69,8 @@ pub struct SessionInsights {
total_tokens: i64,
}
pub type SessionId = String;
impl SessionUpdateBuilder {
fn new(session_id: String) -> Self {
Self {
@@ -241,6 +243,19 @@ impl SessionManager {
Ok(())
}
}
pub async fn search_chat_history(
query: &str,
limit: Option<usize>,
after_date: Option<DateTime<Utc>>,
before_date: Option<DateTime<Utc>>,
exclude_session_id: Option<String>,
) -> Result<crate::session::chat_history_search::ChatRecallResults> {
Self::instance()
.await?
.search_chat_history(query, limit, after_date, before_date, exclude_session_id)
.await
}
}
pub struct SessionStorage {
@@ -959,6 +974,28 @@ impl SessionStorage {
self.get_session(&session.id, true).await
}
async fn search_chat_history(
&self,
query: &str,
limit: Option<usize>,
after_date: Option<DateTime<Utc>>,
before_date: Option<DateTime<Utc>>,
exclude_session_id: Option<String>,
) -> Result<crate::session::chat_history_search::ChatRecallResults> {
use crate::session::chat_history_search::ChatHistorySearch;
ChatHistorySearch::new(
&self.pool,
query,
limit,
after_date,
before_date,
exclude_session_id,
)
.execute()
.await
}
}
#[cfg(test)]