Share via


ConfigureOptionsEmbeddingGeneratorBuilderExtensions.UseEmbeddingGenerationOptions<TInput,TEmbedding> Method

Definition

Adds a callback that updates or replaces EmbeddingGenerationOptions. This can be used to set default options.

public:
generic <typename TInput, typename TEmbedding>
 where TEmbedding : Microsoft::Extensions::AI::Embedding[System::Runtime::CompilerServices::Extension]
 static Microsoft::Extensions::AI::EmbeddingGeneratorBuilder<TInput, TEmbedding> ^ UseEmbeddingGenerationOptions(Microsoft::Extensions::AI::EmbeddingGeneratorBuilder<TInput, TEmbedding> ^ builder, Func<Microsoft::Extensions::AI::EmbeddingGenerationOptions ^, Microsoft::Extensions::AI::EmbeddingGenerationOptions ^> ^ configureOptions);
public static Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<TInput,TEmbedding> UseEmbeddingGenerationOptions<TInput,TEmbedding> (this Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<TInput,TEmbedding> builder, Func<Microsoft.Extensions.AI.EmbeddingGenerationOptions?,Microsoft.Extensions.AI.EmbeddingGenerationOptions?> configureOptions) where TEmbedding : Microsoft.Extensions.AI.Embedding;
static member UseEmbeddingGenerationOptions : Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<'Input, 'Embedding (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)> * Func<Microsoft.Extensions.AI.EmbeddingGenerationOptions, Microsoft.Extensions.AI.EmbeddingGenerationOptions> -> Microsoft.Extensions.AI.EmbeddingGeneratorBuilder<'Input, 'Embedding (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)> (requires 'Embedding :> Microsoft.Extensions.AI.Embedding)
<Extension()>
Public Function UseEmbeddingGenerationOptions(Of TInput, TEmbedding) (builder As EmbeddingGeneratorBuilder(Of TInput, TEmbedding), configureOptions As Func(Of EmbeddingGenerationOptions, EmbeddingGenerationOptions)) As EmbeddingGeneratorBuilder(Of TInput, TEmbedding)

Type Parameters

TInput

Specifies the type of the input passed to the generator.

TEmbedding

Specifies the type of the embedding instance produced by the generator.

Parameters

configureOptions
Func<EmbeddingGenerationOptions,EmbeddingGenerationOptions>

The delegate to invoke to configure the EmbeddingGenerationOptions instance. It is passed the caller-supplied EmbeddingGenerationOptions instance and should return the configured EmbeddingGenerationOptions instance to use.

Returns

The builder.

Remarks

The configuration callback is invoked with the caller-supplied EmbeddingGenerationOptions instance. To override the caller-supplied options with a new instance, the callback may simply return that new instance, for example _ => new EmbeddingGenerationOptions() { Dimensions = 100 }. To provide a new instance only if the caller-supplied instance is null, the callback may conditionally return a new instance, for example options => options ?? new EmbeddingGenerationOptions() { Dimensions = 100 }. Any changes to the caller-provided options instance will persist on the original instance, so the callback must take care to only do so when such mutations are acceptable, such as by cloning the original instance and mutating the clone, for example: options => { var newOptions = options?.Clone() ?? new(); newOptions.Dimensions = 100; return newOptions; }

The callback may return null, in which case a null options will be passed to the next generator in the pipeline.

Applies to