Table of Contents

Constructor AgentMemory

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

AgentMemory(LM)

Initializes a new instance of the AgentMemory class with the specified embedding model.

public AgentMemory(LM embeddingModel)

Parameters

embeddingModel LM

The language model used to generate text embeddings for semantic search. This model should be optimized for embedding generation (e.g., sentence transformers).

Examples

Example: Creating a new agent memory instance

using LMKit.Agents;
using LMKit.Model;

// Load an embedding model (e.g., all-MiniLM-L6-v2)
using var embeddingModel = new LM("path/to/embedding-model.gguf");

// Create the memory store
var memory = new AgentMemory(embeddingModel);

Console.WriteLine($"Memory initialized. Data sources: {memory.DataSources.Count}");
Console.WriteLine($"Is empty: {memory.IsEmpty()}");

Remarks

The embedding model is used both when storing new information (to generate embeddings) and when retrieving information (to embed the query). For consistent results, always use the same embedding model for storage and retrieval.

The memory instance holds a reference to the embedding model but does not dispose it. Ensure the model remains valid for the lifetime of the memory instance.

Exceptions

ArgumentNullException

Thrown when embeddingModel is null.