Method AddDataSource
AddDataSource(DataSource)
Adds a data source to the agent memory.
public void AddDataSource(DataSource dataSource)
Parameters
dataSourceDataSourceThe data source to add.
Examples
Example: Adding a pre-built 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);
// Load a data source from another system
var externalDataSource = DataSource.Deserialize("knowledge_base.bin");
// Add it to the memory
memory.AddDataSource(externalDataSource);
Console.WriteLine($"Memory now contains {memory.DataSources.Count} data source(s).");
Remarks
Use this method to add pre-built data sources (e.g., from document processing or external systems) to the memory without going through the SaveInformationAsync workflow.
Exceptions
- ArgumentNullException
Thrown when
dataSourceisnull.