Method SaveInformation
SaveInformation(string, string, string, MetadataCollection, CancellationToken)
Synchronously saves text information into a designated memory data source.
This method internally invokes the asynchronous SaveInformationAsync(string, string, string, MetadataCollection, CancellationToken) and blocks until completion.
public DataSource SaveInformation(string dataSourceIdentifier, string text, string sectionIdentifier, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe unique identifier of the data source where the information will be stored.
textstringThe text content to be stored.
sectionIdentifierstringA unique identifier for the stored section of information.
additionalMetadataMetadataCollectionOptional metadata to associate with the stored information.
cancellationTokenCancellationTokenAn optional token to monitor for cancellation requests.
Returns
- DataSource
A DataSource instance representing the stored data.
Exceptions
- ArgumentException
Thrown if
dataSourceIdentifier,text, orsectionIdentifieris null or empty.
SaveInformation(string, string, string, MemoryType, MetadataCollection, CancellationToken)
Synchronously saves text information into a designated memory data source, allowing you to specify the memory type.
This method internally calls the asynchronous SaveInformationAsync(string, string, string, MemoryType, MetadataCollection, CancellationToken) method and blocks until the operation completes. It stores the provided text under the specified section identifier, associates it with the provided memory type, and optionally attaches additional metadata.
public DataSource SaveInformation(string dataSourceIdentifier, string text, string sectionIdentifier, MemoryType memoryType, MetadataCollection additionalMetadata = null, CancellationToken cancellationToken = default)
Parameters
dataSourceIdentifierstringThe unique identifier of the data source where the information will be stored.
textstringThe text content to be stored in the memory.
sectionIdentifierstringA unique identifier for the stored section of information.
memoryTypeMemoryTypeSpecifies the type of memory to use when saving the information. This parameter determines how the text is processed and stored, and may affect retrieval operations by indicating the underlying memory model (e.g., Semantic).
additionalMetadataMetadataCollectionOptional metadata to associate with the stored information. If provided, this metadata will be added to the section.
cancellationTokenCancellationTokenAn optional token that can be used to cancel the operation.
Returns
- DataSource
A DataSource instance representing the data source where the information has been stored.
Exceptions
- ArgumentException
Thrown if
dataSourceIdentifier,text, orsectionIdentifieris null or empty, or if the provided memory type is incompatible with the existing memory type associated with the data source.