Method SaveInformationAsync
SaveInformationAsync(string, string, string, MetadataCollection, CancellationToken)
Asynchronously saves text information into a designated memory data source.
The method stores the given text and assigns it a unique section identifier. Optionally, additional metadata can be associated with the stored section.
public Task<DataSource> SaveInformationAsync(string dataSourceIdentifier, string text, string sectionIdentifier, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe unique identifier for the data source where the information will be stored.
textstringThe text content to be saved.
sectionIdentifierstringA unique identifier for this particular piece of information.
additionalMetadataMetadataCollectionOptional metadata to associate with the stored information.
cancellationTokenCancellationTokenAn optional token that can be used to cancel the operation.
Returns
- Task<DataSource>
A task that represents the asynchronous operation. The task result is a DataSource that encapsulates the stored data.
Exceptions
- ArgumentException
Thrown if
dataSourceIdentifier,text, orsectionIdentifieris null or empty.
SaveInformationAsync(string, string, string, MemoryType, MetadataCollection, CancellationToken)
Asynchronously saves text information into a designated memory data source, allowing you to specify the memory type.
The method stores the given text and assigns it a unique section identifier. Optionally, additional metadata can be associated with the stored section.
public Task<DataSource> SaveInformationAsync(string dataSourceIdentifier, string text, string sectionIdentifier, MemoryType memoryType, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe unique identifier for the data source where the information will be stored.
textstringThe text content to be saved.
sectionIdentifierstringA unique identifier for this particular piece of information.
memoryTypeMemoryTypeSpecifies the type of memory to use when saving the information. This parameter influences how the text is processed and stored, and may determine the underlying memory model (e.g., Semantic).
additionalMetadataMetadataCollectionOptional metadata to associate with the stored information.
cancellationTokenCancellationTokenAn optional token that can be used to cancel the operation.
Returns
- Task<DataSource>
A task that represents the asynchronous operation. The task result is a DataSource that encapsulates the stored data.
Exceptions
- ArgumentException
Thrown if
dataSourceIdentifier,text, orsectionIdentifieris null or empty, or if the provided memory type is incompatible with the existing memory type in the data source.