Partager via


EmbeddingGeneratorExtensions.GenerateAndZipAsync<TInput,TEmbedding> Method

Definition

Generates embeddings for each of the supplied values and produces a list that pairs each input value with its resulting embedding.

public static System.Threading.Tasks.Task<(TInput Value, TEmbedding Embedding)[]> GenerateAndZipAsync<TInput,TEmbedding> (this Microsoft.Extensions.AI.IEmbeddingGenerator<TInput,TEmbedding> generator, System.Collections.Generic.IEnumerable<TInput> values, Microsoft.Extensions.AI.EmbeddingGenerationOptions? options = default, System.Threading.CancellationToken cancellationToken = default) where TEmbedding : Microsoft.Extensions.AI.Embedding;
static member GenerateAndZipAsync : Microsoft.Extensions.AI.IEmbeddingGenerator<'Input, 'Embedding (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)> * seq<'Input> * Microsoft.Extensions.AI.EmbeddingGenerationOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<ValueTuple<'Input, 'Embedding>[]> (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)
<Extension()>
Public Function GenerateAndZipAsync(Of TInput, TEmbedding) (generator As IEmbeddingGenerator(Of TInput, TEmbedding), values As IEnumerable(Of TInput), Optional options As EmbeddingGenerationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ValueTuple(Of TInput, TEmbedding)())

Type Parameters

TInput

The type from which embeddings will be generated.

TEmbedding

The type of embedding to generate.

Parameters

generator
IEmbeddingGenerator<TInput,TEmbedding>

The embedding generator.

values
IEnumerable<TInput>

The collection of values for which to generate embeddings.

options
EmbeddingGenerationOptions

The embedding generation options to configure the request.

cancellationToken
CancellationToken

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

Returns

Task<ValueTuple<TInput,TEmbedding>[]>

An array containing tuples of the input values and the associated generated embeddings.

Applies to