Method RemoveDataSource
RemoveDataSource(DataSource)
Removes a specific data source from the memory.
public bool RemoveDataSource(DataSource dataSource)
Parameters
dataSourceDataSourceThe data source to remove.
Returns
- bool
trueif the data source was removed; otherwise,false.
Examples
Example: Removing outdated data
using LMKit.Agents;
using LMKit.Model;
using var embeddingModel = new LM("path/to/embedding-model.gguf");
var memory = new AgentMemory(embeddingModel);
// Find and remove outdated data sources
var outdatedSources = memory.DataSources
.Where(ds => ds.Identifier.StartsWith("archive_"))
.ToList();
foreach (var ds in outdatedSources)
{
if (memory.RemoveDataSource(ds))
{
Console.WriteLine($"Removed: {ds.Identifier}");
}
}
Exceptions
- ArgumentNullException
Thrown when
dataSourceisnull.
RemoveDataSource(string)
Removes a data source from the memory by its identifier.
public bool RemoveDataSource(string dataSourceIdentifier)
Parameters
dataSourceIdentifierstringThe unique identifier of the data source to remove.
Returns
- bool
trueif a data source with the identifier was removed; otherwise,false.
Examples
Example: Removing by identifier
using LMKit.Agents;
using LMKit.Model;
using var embeddingModel = new LM("path/to/embedding-model.gguf");
var memory = new AgentMemory(embeddingModel);
// Store then remove
await memory.SaveInformationAsync("temporary", "This is temporary data.", "temp_001");
// Later, remove it by identifier
bool removed = memory.RemoveDataSource("temporary");
Console.WriteLine($"Removed temporary data: {removed}");
Exceptions
- ArgumentNullException
Thrown when
dataSourceIdentifieris null, empty, or whitespace.