Partager via


IPostgresDbClient.GetNearestMatchesAsync Method

Definition

Gets the nearest matches to the Pgvector.Vector.

public System.Collections.Generic.IAsyncEnumerable<(Microsoft.SemanticKernel.Connectors.Postgres.PostgresMemoryEntry, double)> GetNearestMatchesAsync (string tableName, Pgvector.Vector embedding, int limit, double minRelevanceScore = 0, bool withEmbeddings = false, System.Threading.CancellationToken cancellationToken = default);
abstract member GetNearestMatchesAsync : string * Pgvector.Vector * int * double * bool * System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<ValueTuple<Microsoft.SemanticKernel.Connectors.Postgres.PostgresMemoryEntry, double>>
Public Function GetNearestMatchesAsync (tableName As String, embedding As Vector, limit As Integer, Optional minRelevanceScore As Double = 0, Optional withEmbeddings As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of ValueTuple(Of PostgresMemoryEntry, Double))

Parameters

tableName
String

The name assigned to a table of entries.

embedding
Pgvector.Vector

The Pgvector.Vector to compare the table's embeddings with.

limit
Int32

The maximum number of similarity results to return.

minRelevanceScore
Double

The minimum relevance threshold for returned results.

withEmbeddings
Boolean

If true, the embeddings will be returned in the entries.

cancellationToken
CancellationToken

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

Returns

An asynchronous stream of PostgresMemoryEntry objects that the nearest matches to the Pgvector.Vector.

Applies to