Table of Contents

Class MemoryRecallEventArgs

Namespace
LMKit.TextGeneration.Events
Assembly
LM-Kit.NET.dll

Provides data for the MemoryRecall event.

This event is raised when memory is being recalled to augment a conversation. Subscribers can inspect details such as the memory collection, the recalled text, and a unique identifier. They also have the option to cancel the integration of this memory by setting the Cancel property.

public class MemoryRecallEventArgs : EventArgs
Inheritance
MemoryRecallEventArgs
Inherited Members

Examples

The following example shows how to subscribe to the MemoryRecall event, inspect the recalled memory content, add a contextual prefix, and selectively cancel irrelevant memories.

using LMKit.Model;
using LMKit.TextGeneration;
using LMKit.TextGeneration.Events;

LM model = LM.LoadFromModelID("gemma3:4b");
var chat = new MultiTurnConversation(model);

chat.MemoryRecall += (sender, e) =>
{
    Console.WriteLine($"Memory collection: {e.MemoryCollection}");
    Console.WriteLine($"Memory ID: {e.MemoryId}");
    Console.WriteLine($"Memory type: {e.MemoryType}");
    Console.WriteLine($"Recalled text: {e.MemoryText}");

    // Add a prefix to provide context for the recalled content.
    e.Prefix = "[Recalled from knowledge base] ";

    // Cancel integration of memories from a specific collection.
    if (e.MemoryCollection == "outdated_docs")
    {
        e.Cancel = true;
    }
};

var response = chat.Submit("What were the key points from our last meeting?");

Properties

Cancel

Gets or sets a value indicating whether the recalled memory should be cancelled and not integrated into the conversation.

Set this property to true to skip incorporating this memory partition.

MemoryCollection

Gets the identifier of the memory collection (a DataSource identifier) from which the memory partition originates.

MemoryId

Gets the unique identifier ( a Section identifier) of the recalled memory section.

MemoryText

Gets the text content of the recalled memory partition.

MemoryType

Gets the type of memory of the recalled memory section.

Metadata

Gets the optional metadata associated with the recalled memory section.

Prefix

Gets or sets an optional prefix that can be placed before the inserted recall content.

This property is empty by default.

Share