Table of Contents

Method RemoveDataSource

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

RemoveDataSource(DataSource)

Removes a specific data source from the memory.

public bool RemoveDataSource(DataSource dataSource)

Parameters

dataSource DataSource

The data source to remove.

Returns

bool

true if 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 dataSource is null.

RemoveDataSource(string)

Removes a data source from the memory by its identifier.

public bool RemoveDataSource(string dataSourceIdentifier)

Parameters

dataSourceIdentifier string

The unique identifier of the data source to remove.

Returns

bool

true if 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 dataSourceIdentifier is null, empty, or whitespace.

Share