Method SaveInformationAsync
SaveInformationAsync(string, string, string, MetadataCollection, CancellationToken)
Saves text information into a user-scoped data source using semantic memory type.
public Task<DataSource> SaveInformationAsync(string dataSourceIdentifier, string text, string sectionIdentifier, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe data source identifier (without the user prefix). The user's namespace prefix is added automatically.
textstringThe text content to store.
sectionIdentifierstringA unique identifier for this piece of information within the data source.
additionalMetadataMetadataCollectionOptional metadata to associate with the stored information.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<DataSource>
The DataSource containing the stored information.
Examples
Example: Storing user preferences
var userMemory = new UserScopedMemory(sharedMemory, "alice");
await userMemory.SaveInformationAsync("preferences", "Prefers dark mode.", "theme");
// Stored under data source: "alice::preferences"
SaveInformationAsync(string, string, string, MemoryType, MetadataCollection, CancellationToken)
Saves text information into a user-scoped data source with a specified memory type.
public Task<DataSource> SaveInformationAsync(string dataSourceIdentifier, string text, string sectionIdentifier, MemoryType memoryType, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe data source identifier (without the user prefix).
textstringThe text content to store.
sectionIdentifierstringA unique identifier for this piece of information.
memoryTypeMemoryTypeThe type of memory classification.
additionalMetadataMetadataCollectionOptional metadata to associate with the information.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<DataSource>
The DataSource containing the stored information.