8 implementations of IEmbeddingGenerator
Microsoft.Extensions.AI.Abstractions (1)
Embeddings\DelegatingEmbeddingGenerator.cs (1)
21public class DelegatingEmbeddingGenerator<TInput, TEmbedding> : IEmbeddingGenerator<TInput, TEmbedding>
Microsoft.Extensions.AI.Abstractions.Tests (1)
TestEmbeddingGenerator.cs (1)
11public sealed class TestEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>>
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceEmbeddingGenerator.cs (1)
26IEmbeddingGenerator<string, Embedding<float>>
Microsoft.Extensions.AI.Integration.Tests (2)
QuantizationEmbeddingGenerator.cs (2)
16IEmbeddingGenerator<string, BinaryEmbedding> 18, IEmbeddingGenerator<string, Embedding<Half>>
Microsoft.Extensions.AI.Ollama (1)
OllamaEmbeddingGenerator.cs (1)
16public sealed class OllamaEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>>
Microsoft.Extensions.AI.OpenAI (1)
OpenAIEmbeddingGenerator.cs (1)
20public sealed class OpenAIEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>>
Microsoft.Extensions.AI.Tests (1)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestEmbeddingGenerator.cs (1)
11public sealed class TestEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>>
179 references to IEmbeddingGenerator
Aspire.Azure.AI.OpenAI.Tests (20)
AspireAzureOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (20)
35var generator = useKeyed ? 36host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 37host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 65var generator = useKeyed ? 66host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 67host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 93var generator = useKeyed ? 94host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 95host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 125host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 126host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 156host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 157host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 186var generator = useKeyed ? 187host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 188host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 213var generator = useKeyed ? 214host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 215host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 221private Task<GeneratedEmbeddings<Embedding<float>>> TestMiddleware(IEnumerable<string> inputs, EmbeddingGenerationOptions? options, IEmbeddingGenerator<string, Embedding<float>> nextAsync, CancellationToken cancellationToken)
Aspire.OpenAI (8)
AspireOpenAIClientBuilderEmbeddingGeneratorExtensions.cs (8)
12/// Provides extension methods for registering <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> as a singleton in the services provided by the <see cref="IHostApplicationBuilder"/>. 17/// Registers a singleton <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> in the services provided by the <paramref name="builder"/>. 21/// <returns>A <see cref="EmbeddingGeneratorBuilder{TInput, TEmbedding}"/> that can be used to build a pipeline around the inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</returns> 31/// Registers a keyed singleton <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> in the services provided by the <paramref name="builder"/>. 34/// <param name="serviceKey">The service key with which the <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> will be registered.</param> 36/// <returns>A <see cref="EmbeddingGeneratorBuilder{TInput, TEmbedding}"/> that can be used to build a pipeline around the inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</returns> 47private static IEmbeddingGenerator<string, Embedding<float>> CreateInnerEmbeddingGenerator( 57var result = openAiClient.AsEmbeddingGenerator(deploymentName);
Aspire.OpenAI.Tests (20)
AspireOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (20)
36var generator = useKeyed ? 37host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 38host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 66var generator = useKeyed ? 67host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 68host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 94var generator = useKeyed ? 95host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 96host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 126host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 127host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 157host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 158host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 187var generator = useKeyed ? 188host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 189host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 214var generator = useKeyed ? 215host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 216host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 222private Task<GeneratedEmbeddings<Embedding<float>>> TestMiddleware(IEnumerable<string> inputs, EmbeddingGenerationOptions? options, IEmbeddingGenerator<string, Embedding<float>> nextAsync, CancellationToken cancellationToken)
Microsoft.Extensions.AI (46)
Embeddings\AnonymousDelegatingEmbeddingGenerator.cs (3)
19private readonly Func<IEnumerable<TInput>, EmbeddingGenerationOptions?, IEmbeddingGenerator<TInput, TEmbedding>, CancellationToken, Task<GeneratedEmbeddings<TEmbedding>>> _generateFunc; 27IEmbeddingGenerator<TInput, TEmbedding> innerGenerator, 28Func<IEnumerable<TInput>, EmbeddingGenerationOptions?, IEmbeddingGenerator<TInput, TEmbedding>, CancellationToken, Task<GeneratedEmbeddings<TEmbedding>>> generateFunc)
Embeddings\CachingEmbeddingGenerator.cs (2)
21/// <param name="innerGenerator">The underlying <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</param> 22protected CachingEmbeddingGenerator(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator)
Embeddings\ConfigureOptionsEmbeddingGenerator.cs (1)
36IEmbeddingGenerator<TInput, TEmbedding> innerGenerator,
Embeddings\DistributedCachingEmbeddingGenerator.cs (3)
21/// The provided implementation of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> is thread-safe for concurrent 31/// <param name="innerGenerator">The underlying <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</param> 33public DistributedCachingEmbeddingGenerator(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator, IDistributedCache storage)
Embeddings\DistributedCachingEmbeddingGeneratorBuilderExtensions.cs (1)
13/// <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> pipeline.
Embeddings\EmbeddingGeneratorBuilder.cs (20)
12/// <summary>A builder for creating pipelines of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</summary> 18private readonly Func<IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>> _innerGeneratorFactory; 21private List<Func<IEmbeddingGenerator<TInput, TEmbedding>, IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>>>? _generatorFactories; 25public EmbeddingGeneratorBuilder(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator) 33public EmbeddingGeneratorBuilder(Func<IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>> innerGeneratorFactory) 39/// Builds an <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the entire pipeline. Calls to this instance will pass through each of the pipeline stages in turn. 42/// The <see cref="IServiceProvider"/> that should provide services to the <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> instances. 45/// <returns>An instance of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the entire pipeline.</returns> 46public IEmbeddingGenerator<TInput, TEmbedding> Build(IServiceProvider? services = null) 49var embeddingGenerator = _innerGeneratorFactory(services); 58$"The {nameof(IEmbeddingGenerator<TInput, TEmbedding>)} entry at index {i} returned null. " + 59$"Ensure that the callbacks passed to {nameof(Use)} return non-null {nameof(IEmbeddingGenerator<TInput, TEmbedding>)} instances."); 69public EmbeddingGeneratorBuilder<TInput, TEmbedding> Use(Func<IEmbeddingGenerator<TInput, TEmbedding>, IEmbeddingGenerator<TInput, TEmbedding>> generatorFactory) 80Func<IEmbeddingGenerator<TInput, TEmbedding>, IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>> generatorFactory) 91/// an implementation for <see cref="IEmbeddingGenerator{TInput, TEmbedding}.GenerateAsync"/>. 94/// A delegate that provides the implementation for <see cref="IEmbeddingGenerator{TInput, TEmbedding}.GenerateAsync"/>. 99Func<IEnumerable<TInput>, EmbeddingGenerationOptions?, IEmbeddingGenerator<TInput, TEmbedding>, CancellationToken, Task<GeneratedEmbeddings<TEmbedding>>>? generateFunc)
Embeddings\EmbeddingGeneratorBuilderEmbeddingGeneratorExtensions.cs (2)
9/// <summary>Provides extension methods for working with <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> 26this IEmbeddingGenerator<TInput, TEmbedding> innerGenerator)
Embeddings\EmbeddingGeneratorBuilderServiceCollectionExtensions.cs (9)
10/// <summary>Provides extension methods for registering <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> with a <see cref="IServiceCollection"/>.</summary> 17/// <param name="innerGenerator">The inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the underlying backend.</param> 22IEmbeddingGenerator<TInput, TEmbedding> innerGenerator) 30/// <param name="innerGeneratorFactory">A callback that produces the inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the underlying backend.</param> 35Func<IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>> innerGeneratorFactory) 51/// <param name="innerGenerator">The inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the underlying backend.</param> 57IEmbeddingGenerator<TInput, TEmbedding> innerGenerator) 66/// <param name="innerGeneratorFactory">A callback that produces the inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that represents the underlying backend.</param> 72Func<IServiceProvider, IEmbeddingGenerator<TInput, TEmbedding>> innerGeneratorFactory)
Embeddings\LoggingEmbeddingGenerator.cs (3)
19/// The provided implementation of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> is thread-safe for concurrent use 32/// <param name="innerGenerator">The underlying <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</param> 34public LoggingEmbeddingGenerator(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator, ILogger logger)
Embeddings\OpenTelemetryEmbeddingGenerator.cs (2)
41/// <param name="innerGenerator">The underlying <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>, which is the next stage of the pipeline.</param> 45public OpenTelemetryEmbeddingGenerator(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator, ILogger? logger = null, string? sourceName = null)
Microsoft.Extensions.AI.Abstractions (25)
Embeddings\DelegatingEmbeddingGenerator.cs (5)
13/// Provides an optional base class for an <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> that passes through calls to another instance. 18/// This type is recommended as a base type when building generators that can be chained in any order around an underlying <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>. 28protected DelegatingEmbeddingGenerator(IEmbeddingGenerator<TInput, TEmbedding> innerGenerator) 33/// <summary>Gets the inner <see cref="IEmbeddingGenerator{TInput, TEmbedding}" />.</summary> 34protected IEmbeddingGenerator<TInput, TEmbedding> InnerGenerator { get; }
Embeddings\Embedding.cs (1)
9/// <summary>Represents an embedding generated by a <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</summary>
Embeddings\EmbeddingGeneratorExtensions.cs (11)
15/// <summary>Provides a collection of static methods for extending <see cref="IEmbeddingGenerator{TInput,TEmbedding}"/> instances.</summary> 18/// <summary>Asks the <see cref="IEmbeddingGenerator{TInput,TEmbedding}"/> for an object of type <typeparamref name="TService"/>.</summary> 27/// <see cref="IEmbeddingGenerator{TInput,TEmbedding}"/>, including itself or any services it might be wrapping. 29public static TService? GetService<TInput, TEmbedding, TService>(this IEmbeddingGenerator<TInput, TEmbedding> generator, object? serviceKey = null) 43/// <summary>Asks the <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> for an object of type <typeparamref name="TService"/>.</summary> 50/// <see cref="IEmbeddingGenerator{TInput,TEmbedding}"/>, including itself or any services it might be wrapping. 52public static TService? GetService<TService>(this IEmbeddingGenerator<string, Embedding<float>> generator, object? serviceKey = null) => 68this IEmbeddingGenerator<TInput, Embedding<TEmbedding>> generator, 88/// This operations is equivalent to using <see cref="IEmbeddingGenerator{TInput, TEmbedding}.GenerateAsync"/> with a 93this IEmbeddingGenerator<TInput, TEmbedding> generator, 129this IEmbeddingGenerator<TInput, TEmbedding> generator,
Embeddings\EmbeddingGeneratorMetadata.cs (1)
8/// <summary>Provides metadata about an <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</summary>
Embeddings\IEmbeddingGenerator.cs (7)
16/// Unless otherwise specified, all members of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> are thread-safe for concurrent use. 17/// It is expected that all implementations of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> support being used by multiple requests concurrently. 20/// However, implementations of <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> may mutate the arguments supplied to 23/// invocations or should otherwise ensure by construction that no <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> instances 40/// <summary>Gets metadata that describes the <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</summary> 43/// <summary>Asks the <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 49/// <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>, including itself or any services it might be wrapping.
Microsoft.Extensions.AI.Abstractions.Tests (3)
Embeddings\DelegatingEmbeddingGeneratorTests.cs (3)
96var service = delegating.GetService<IEmbeddingGenerator<string, Embedding<float>>>(expectedKey); 124private sealed class NoOpDelegatingEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> innerGenerator) :
Microsoft.Extensions.AI.AzureAIInference (4)
AzureAIInferenceEmbeddingGenerator.cs (1)
24/// <summary>Represents an <see cref="IEmbeddingGenerator{String, Embedding}"/> for an Azure.AI.Inference <see cref="EmbeddingsClient"/>.</summary>
AzureAIInferenceExtensions.cs (3)
19/// <summary>Gets an <see cref="IEmbeddingGenerator{String, Single}"/> for use with this <see cref="EmbeddingsClient"/>.</summary> 23/// <returns>An <see cref="IEmbeddingGenerator{String, Embedding}"/> that can be used to generate embeddings via the <see cref="EmbeddingsClient"/>.</returns> 24public static IEmbeddingGenerator<string, Embedding<float>> AsEmbeddingGenerator(
Microsoft.Extensions.AI.AzureAIInference.Tests (7)
AzureAIInferenceEmbeddingGeneratorIntegrationTests.cs (1)
10protected override IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator() =>
AzureAIInferenceEmbeddingGeneratorTests.cs (6)
51IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = client.AsEmbeddingGenerator(model); 61var embeddingGenerator = client.AsEmbeddingGenerator("model"); 63Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 66using IEmbeddingGenerator<string, Embedding<float>> pipeline = embeddingGenerator 77Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 112using IEmbeddingGenerator<string, Embedding<float>> generator = new EmbeddingsClient(new("http://somewhere"), new AzureKeyCredential("key"), new()
Microsoft.Extensions.AI.Integration.Tests (10)
CallCountingEmbeddingGenerator.cs (1)
13internal sealed class CallCountingEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> innerGenerator)
EmbeddingGeneratorIntegrationTests.cs (5)
27private readonly IEmbeddingGenerator<string, Embedding<float>>? _embeddingGenerator; 40protected abstract IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator(); 114var embeddingGenerator = CreateEmbeddingGenerator()! 139using IEmbeddingGenerator<string, BinaryEmbedding> generator = 176using IEmbeddingGenerator<string, Embedding<Half>> generator =
QuantizationEmbeddingGenerator.cs (4)
21private readonly IEmbeddingGenerator<string, Embedding<float>> _floatService; 23public QuantizationEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> floatService) 36async Task<GeneratedEmbeddings<BinaryEmbedding>> IEmbeddingGenerator<string, BinaryEmbedding>.GenerateAsync( 69async Task<GeneratedEmbeddings<Embedding<Half>>> IEmbeddingGenerator<string, Embedding<Half>>.GenerateAsync(
Microsoft.Extensions.AI.Ollama (1)
OllamaEmbeddingGenerator.cs (1)
15/// <summary>Represents an <see cref="IEmbeddingGenerator{String, Embedding}"/> for Ollama.</summary>
Microsoft.Extensions.AI.Ollama.Tests (6)
OllamaEmbeddingGeneratorIntegrationTests.cs (1)
10protected override IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator() =>
OllamaEmbeddingGeneratorTests.cs (5)
30Assert.Same(generator, generator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 32using IEmbeddingGenerator<string, Embedding<float>> pipeline = generator 43Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 52using IEmbeddingGenerator<string, Embedding<float>> chatClient = new OllamaEmbeddingGenerator(endpoint, model); 80using IEmbeddingGenerator<string, Embedding<float>> generator = new OllamaEmbeddingGenerator("http://localhost:11434", "all-minilm", httpClient);
Microsoft.Extensions.AI.OpenAI (7)
OpenAIClientExtensions.cs (6)
26/// <summary>Gets an <see cref="IEmbeddingGenerator{String, Single}"/> for use with this <see cref="OpenAIClient"/>.</summary> 30/// <returns>An <see cref="IEmbeddingGenerator{String, Embedding}"/> that can be used to generate embeddings via the <see cref="EmbeddingClient"/>.</returns> 31public static IEmbeddingGenerator<string, Embedding<float>> AsEmbeddingGenerator(this OpenAIClient openAIClient, string modelId, int? dimensions = null) => 34/// <summary>Gets an <see cref="IEmbeddingGenerator{String, Single}"/> for use with this <see cref="EmbeddingClient"/>.</summary> 37/// <returns>An <see cref="IEmbeddingGenerator{String, Embedding}"/> that can be used to generate embeddings via the <see cref="EmbeddingClient"/>.</returns> 38public static IEmbeddingGenerator<string, Embedding<float>> AsEmbeddingGenerator(this EmbeddingClient embeddingClient, int? dimensions = null) =>
OpenAIEmbeddingGenerator.cs (1)
19/// <summary>An <see cref="IEmbeddingGenerator{String, Embedding}"/> for an OpenAI <see cref="EmbeddingClient"/>.</summary>
Microsoft.Extensions.AI.OpenAI.Tests (11)
OpenAIEmbeddingGeneratorIntegrationTests.cs (1)
10protected override IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator() =>
OpenAIEmbeddingGeneratorTests.cs (10)
57IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = client.AsEmbeddingGenerator(model); 72IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = openAIClient.AsEmbeddingGenerator("model"); 74Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 81using IEmbeddingGenerator<string, Embedding<float>> pipeline = embeddingGenerator 92Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 99IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = openAIClient.AsEmbeddingGenerator(); 101Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 104using IEmbeddingGenerator<string, Embedding<float>> pipeline = embeddingGenerator 115Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 150using IEmbeddingGenerator<string, Embedding<float>> generator = new OpenAIClient(new ApiKeyCredential("apikey"), new OpenAIClientOptions
Microsoft.Extensions.AI.Tests (11)
Embeddings\ConfigureOptionsEmbeddingGeneratorTests.cs (2)
38using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator 48using var generator = innerGenerator
Embeddings\EmbeddingGeneratorBuilderTests.cs (5)
60Assert.Throws<ArgumentNullException>("innerGenerator", () => new EmbeddingGeneratorBuilder<string, Embedding<float>>((IEmbeddingGenerator<string, Embedding<float>>)null!)); 61Assert.Throws<ArgumentNullException>("innerGenerator", () => ((IEmbeddingGenerator<string, Embedding<float>>)null!).AsBuilder()); 68() => new EmbeddingGeneratorBuilder<string, Embedding<float>>((Func<IServiceProvider, IEmbeddingGenerator<string, Embedding<float>>>)null!)); 81private sealed class InnerServiceCapturingEmbeddingGenerator(string name, IEmbeddingGenerator<string, Embedding<float>> innerGenerator) : 87public new IEmbeddingGenerator<string, Embedding<float>> InnerGenerator => base.InnerGenerator;
Embeddings\LoggingEmbeddingGeneratorTests.cs (1)
35using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (3)
21builder.Use((Func<IEnumerable<string>, EmbeddingGenerationOptions?, IEmbeddingGenerator<string, Embedding<float>>, CancellationToken, Task<GeneratedEmbeddings<Embedding<float>>>>)null!)); 40using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator 52using IEmbeddingGenerator<string, Embedding<float>> generator = new EmbeddingGeneratorBuilder<string, Embedding<float>>(innerGenerator)