Table of Contents

Method RecallAsync

Namespace
LMKit.Agents
Assembly
LM-Kit.NET.dll

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

query string

The question or topic to recall memories for. Cannot be null or empty.

topK int

The maximum number of memories to return. At or below zero (the default), TopK applies.

cancellationToken CancellationToken

A 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 query is null or empty.

Share