Method IsEmpty
IsEmpty()
Determines whether the memory contains any stored data.
public bool IsEmpty()
Returns
- bool
trueif no information is stored; otherwise,false.
Examples
Example: Conditional memory initialization
using LMKit.Agents;
using LMKit.Model;
using var embeddingModel = new LM("path/to/embedding-model.gguf");
var memory = new AgentMemory(embeddingModel);
if (memory.IsEmpty())
{
Console.WriteLine("Memory is empty. Loading initial knowledge...");
await memory.SaveInformationAsync("init", "Initial system knowledge.", "startup");
}
else
{
Console.WriteLine($"Memory contains {memory.DataSources.Count} data source(s).");
}
Remarks
Use this method to check if memory needs to be initialized or loaded before using an agent.