Method WithMemory
WithMemory(AgentMemory)
Sets the memory system for the agent.
public AgentBuilder WithMemory(AgentMemory memory)
Parameters
memoryAgentMemoryThe agent memory for persistent knowledge.
Returns
- AgentBuilder
This builder instance for method chaining.
Examples
Adding memory to an agent:
using LMKit.Model;
using LMKit.Agents;
using var model = new LM("path/to/model.gguf");
using var embeddingModel = new LM("path/to/embedding-model.gguf");
// Create a memory system
var memory = new AgentMemory(embeddingModel);
var agent = new AgentBuilder()
.WithModel(model)
.WithPersona("Personal Assistant")
.WithInstruction("Remember user preferences and past conversations.")
.WithMemory(memory)
.Build();
Remarks
Memory enables the agent to retain and recall information across conversations. It uses semantic search to find relevant context for the current query.