Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/src/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ impl MemoryDocuments for NullMemoryProvider {
) -> Result<NamespaceRetrievalContext, MemoryError> {
unsupported(Capability::Documents)
}

async fn recall_documents(
&self,
_namespace: &str,
_limit: usize,
) -> Result<NamespaceRetrievalContext, MemoryError> {
unsupported(Capability::Documents)
}
}

#[async_trait]
Expand Down
20 changes: 20 additions & 0 deletions api/src/provider/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use async_trait::async_trait;

use crate::capabilities::Capability;
use crate::chunks::Chunk;
use crate::error::MemoryError;
use crate::provider::types::{IngestItem, IngestOutcome, SourceScope};
Expand Down Expand Up @@ -137,6 +138,25 @@ pub trait MemoryDocuments: Send + Sync {
query: &str,
limit: usize,
) -> Result<NamespaceRetrievalContext, MemoryError>;

/// Recall the highest-ranked context from a namespace without a query.
///
/// This is a distinct engine operation rather than a query with an empty
/// string: query-less recall applies the namespace's freshness and
/// priority ranking without introducing a synthetic search term.
///
/// # Errors
///
/// [`MemoryError::Unsupported`] when a provider predating this optional
/// operation does not implement it, otherwise backend failures. An empty
/// namespace returns empty context.
async fn recall_documents(
Comment thread
coderabbitai[bot] marked this conversation as resolved.
&self,
_namespace: &str,
_limit: usize,
) -> Result<NamespaceRetrievalContext, MemoryError> {
Err(MemoryError::unsupported(Capability::Documents))
}
}

/// The time-ordered summary tree: buffered leaves rolled up into hour → day →
Expand Down
14 changes: 14 additions & 0 deletions crates/tinymemory-module/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,20 @@ impl MemoryDocuments for ModuleMemoryProvider {
.map_err(|error| Self::other("query_documents", error))?;
Self::cross(&context, "convert document query result")
}

async fn recall_documents(
&self,
namespace: &str,
limit: usize,
) -> Result<NamespaceRetrievalContext, MemoryError> {
let limit = u32::try_from(limit).unwrap_or(u32::MAX);
let context = self
.client
.recall_namespace_context_data(namespace, limit)
.await
.map_err(|error| Self::other("recall_documents", error))?;
Self::cross(&context, "convert document recall result")
}
}

#[async_trait]
Expand Down
13 changes: 13 additions & 0 deletions crates/tinymemory-module/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,19 @@ impl MemoryService {
Ok(response)
}

async fn recall_documents(
&self,
namespace: String,
limit: usize,
) -> BusResult<NamespaceRetrievalContext> {
let response = require_family!(self, as_documents, Capability::Documents)
.recall_documents(&namespace, limit)
.await
.map_err(|error| into_bus_error(&error))?;
ensure_response_fits(&response, "RecallDocuments")?;
Ok(response)
}

async fn append(&self, request: IngestRequest) -> BusResult<()> {
require_family!(self, as_tree, Capability::Tree)
.append(request)
Expand Down