Share via


SemanticTextMemory.GetAsync Method

Definition

Fetch a memory by key. For local memories the key is the "id" used when saving the record. For external reference, the key is the "URI" used when saving the record.

public System.Threading.Tasks.Task<Microsoft.SemanticKernel.Memory.MemoryQueryResult?> GetAsync (string collection, string key, bool withEmbedding = false, Microsoft.SemanticKernel.Kernel? kernel = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetAsync : string * string * bool * Microsoft.SemanticKernel.Kernel * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.SemanticKernel.Memory.MemoryQueryResult>
override this.GetAsync : string * string * bool * Microsoft.SemanticKernel.Kernel * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.SemanticKernel.Memory.MemoryQueryResult>
Public Function GetAsync (collection As String, key As String, Optional withEmbedding As Boolean = false, Optional kernel As Kernel = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of MemoryQueryResult)

Parameters

collection
String

Collection to search.

key
String

Unique memory record identifier.

withEmbedding
Boolean

Whether to return the embedding of the memory found.

kernel
Kernel

The Kernel containing services, plugins, and other state for use throughout the operation.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Memory record, or null when nothing is found

Implements

Applies to