Partager via


IEmbeddingGenerator<TInput,TEmbedding> Interface

Definition

Represents a generator of embeddings.

generic <typename TInput, typename TEmbedding>
 where TEmbedding : Embeddingpublic interface class IEmbeddingGenerator : IDisposable, Microsoft::Extensions::AI::IEmbeddingGenerator
public interface IEmbeddingGenerator<in TInput,TEmbedding> : IDisposable, Microsoft.Extensions.AI.IEmbeddingGenerator where TEmbedding : Embedding
type IEmbeddingGenerator<'Input, 'Embedding (requires 'Embedding :> Embedding)> = interface
    interface IEmbeddingGenerator
    interface IDisposable
Public Interface IEmbeddingGenerator(Of In TInput, TEmbedding)
Implements IDisposable, IEmbeddingGenerator

Type Parameters

TInput

The type from which embeddings will be generated.

This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
TEmbedding

The type of embeddings to generate.

Derived
Implements

Remarks

Unless otherwise specified, all members of IEmbeddingGenerator<TInput,TEmbedding> are thread-safe for concurrent use. It is expected that all implementations of IEmbeddingGenerator<TInput,TEmbedding> support being used by multiple requests concurrently. Instances must not be disposed of while the instance is still in use.

However, implementations of IEmbeddingGenerator<TInput,TEmbedding> may mutate the arguments supplied to GenerateAsync(IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken), such as by configuring the options instance. Thus, consumers of the interface either should avoid using shared instances of these arguments for concurrent invocations or should otherwise ensure by construction that no IEmbeddingGenerator<TInput,TEmbedding> instances are used which might employ such mutation.

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

(Inherited from IDisposable)
GenerateAsync(IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken)

Generates embeddings for each of the supplied values.

GetService(Type, Object)

Asks the IEmbeddingGenerator<TInput,TEmbedding> for an object of the specified type serviceType.

(Inherited from IEmbeddingGenerator)

Extension Methods

AsBuilder<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>)

Creates a new EmbeddingGeneratorBuilder<TInput,TEmbedding> using innerGenerator as its inner generator.

GenerateAndZipAsync<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>, IEnumerable<TInput>, EmbeddingGenerationOptions, CancellationToken)

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

GenerateEmbeddingAsync<TInput,TEmbedding>(IEmbeddingGenerator<TInput,TEmbedding>, TInput, EmbeddingGenerationOptions, CancellationToken)

Generates an embedding from the specified value.

GetRequiredService(IEmbeddingGenerator, Type, Object)

Asks the IEmbeddingGenerator<TInput,TEmbedding> for an object of the specified type serviceType and throws an exception if one isn't available.

GetRequiredService<TService>(IEmbeddingGenerator, Object)

Asks the IEmbeddingGenerator<TInput,TEmbedding> for an object of type TService and throws an exception if one isn't available.

GetService<TService>(IEmbeddingGenerator, Object)

Asks the IEmbeddingGenerator<TInput,TEmbedding> for an object of type TService.

Applies to