共用方式為


EmbeddingGeneratorBuilderServiceCollectionExtensions.AddEmbeddingGenerator<TInput,TEmbedding> Method

Definition

Adds a embedding generator to the IServiceCollection.

public:
generic <typename TInput, typename TEmbedding>
 where TEmbedding : Microsoft::Extensions::AI::Embedding[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddEmbeddingGenerator(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Func<Microsoft::Extensions::AI::EmbeddingGeneratorBuilder<TInput, TEmbedding> ^, Microsoft::Extensions::AI::IEmbeddingGenerator<TInput, TEmbedding> ^> ^ generatorFactory);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddEmbeddingGenerator<TInput,TEmbedding> (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Func<Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<TInput,TEmbedding>,Microsoft.Extensions.AI.IEmbeddingGenerator<TInput,TEmbedding>> generatorFactory) where TEmbedding : Microsoft.Extensions.AI.Embedding;
static member AddEmbeddingGenerator : Microsoft.Extensions.DependencyInjection.IServiceCollection * Func<Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<'Input, 'Embedding>, Microsoft.Extensions.AI.IEmbeddingGenerator<'Input, 'Embedding>> -> Microsoft.Extensions.DependencyInjection.IServiceCollection (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)
<Extension()>
Public Function AddEmbeddingGenerator(Of TInput, TEmbedding) (services As IServiceCollection, generatorFactory As Func(Of EmbeddingGeneratorBuilder(Of TInput, TEmbedding), IEmbeddingGenerator(Of TInput, TEmbedding))) As IServiceCollection

Type Parameters

TInput

The type from which embeddings will be generated.

TEmbedding

The type of embeddings to generate.

Parameters

services
IServiceCollection

The IServiceCollection to which the generator should be added.

generatorFactory
Func<EmbeddingGeneratorBuilder<TInput,TEmbedding>,IEmbeddingGenerator<TInput,TEmbedding>>

The factory to use to construct the IEmbeddingGenerator<TInput,TEmbedding> instance.

Returns

The services collection.

Remarks

The generator is registered as a scoped service.

Applies to