Property Filter
Filter
Gets or sets the filtering criteria used during memory retrieval operations.
public DataFilter Filter { get; set; }
Property Value
- DataFilter
A DataFilter that determines which data sources and sections are considered during searches. The default is no filtering (all data is searched).
Examples
Example: Filtering memory by data source
using LMKit.Agents;
using LMKit.Data;
using LMKit.Model;
using var embeddingModel = new LM("path/to/embedding-model.gguf");
var memory = new AgentMemory(embeddingModel);
// Store information in different data sources
await memory.SaveInformationAsync("public_docs", "API rate limit is 1000 requests/hour.", "rate_limit");
await memory.SaveInformationAsync("internal_docs", "Database password is stored in vault.", "credentials");
// Filter to only search public documentation
memory.Filter = new DataFilter
{
FilterDataSource = ds => ds.Identifier == "internal_docs" // Exclude internal docs
};
// Now retrieval will only consider public_docs
Remarks
Use this property to restrict memory searches to specific data sources or sections. This is useful when you have memory organized by topic, user, or time period and want to limit searches to relevant subsets.
The filter functions return true to exclude an item from search results.