Method RecallAsync
RecallAsync(string, int, CancellationToken)
Recalls the memories most relevant to a query, ranked by similarity, honoring MinScore (or the calibrated floor when unset) and time decay when enabled.
public Task<IReadOnlyList<RecalledMemory>> RecallAsync(string query, int topK = 0, CancellationToken cancellationToken = default)
Parameters
querystringThe question or topic to recall memories for. Cannot be null or empty.
topKintThe maximum number of memories to return. At or below zero (the default), TopK applies.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<IReadOnlyList<RecalledMemory>>
The recalled memories, best match first. Empty when nothing relevant is stored.
Examples
var recalled = await memory.RecallAsync("what does the user prefer?", topK: 5);
foreach (var entry in recalled)
{
Console.WriteLine($"[{entry.MemoryType}/{entry.Importance}] {entry.Similarity:F2} {entry.Text}");
}
Exceptions
- ArgumentException
Thrown when
queryis null or empty.