70 instantiations of Embedding
Aspire.Azure.AI.OpenAI.Tests (1)
AspireAzureOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (1)
224return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>(inputs.Select(i => new Embedding<float>(floats))));
Aspire.OpenAI.Tests (1)
AspireOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (1)
271return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>(inputs.Select(i => new Embedding<float>(floats))));
Microsoft.Extensions.AI.Abstractions (6)
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingByte.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<byte>((global::System.ReadOnlyMemory<byte>)args[0]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingDouble.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<double>((global::System.ReadOnlyMemory<double>)args[0]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingHalf.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<global::System.Half>((global::System.ReadOnlyMemory<global::System.Half>)args[0]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingInt32.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<int>((global::System.ReadOnlyMemory<int>)args[0]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingSByte.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<sbyte>((global::System.ReadOnlyMemory<sbyte>)args[0]),
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingSingle.g.cs (1)
34ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<float>((global::System.ReadOnlyMemory<float>)args[0]),
Microsoft.Extensions.AI.Abstractions.Tests (35)
Embeddings\DelegatingEmbeddingGeneratorTests.cs (1)
28var expectedEmbedding = new GeneratedEmbeddings<Embedding<float>>([new(new float[] { 1.0f, 2.0f, 3.0f })]);
Embeddings\EmbeddingGeneratorExtensionsTests.cs (2)
89Embedding<float> result = new(new float[] { 1f, 2f, 3f }); 110.Select(i => new Embedding<float>(Enumerable.Range(i, 4).Select(i => (float)i).ToArray()))
Embeddings\EmbeddingTests.cs (5)
23Embedding<float> e = new(floats) 43Embedding<byte> e = new(bytes); 56Embedding<sbyte> e = new(bytes); 84Embedding<float> e = new(floats); 97Embedding<double> e = new(floats);
Embeddings\GeneratedEmbeddingsTests.cs (23)
42Assert.False(instance.Contains(new Embedding<float>(new float[] { 1, 2, 3 }))); 45Assert.Equal(-1, instance.IndexOf(new Embedding<float>(new float[] { 1, 2, 3 }))); 60new(new float[] { 1, 2, 3 }), 61new(new float[] { 4, 5, 6 }), 86var e = new Embedding<float>(new float[] { 7, 8, 9 }); 117var e = new Embedding<float>(new float[] { 1, 2, 3 }); 129var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 130var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 144var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 145var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 160var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 161var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 183var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 184var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 202var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 203var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 208var e3 = new Embedding<float>(new float[] { 7, 8, 9 }); 220var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 221var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 226var e3 = new Embedding<float>(new float[] { 7, 8, 9 }); 238var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 239var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 251var expectedGeneratedEmbeddings = new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1, 2, 3 })]);
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingByte.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<byte>((global::System.ReadOnlyMemory<byte>)args[0]),
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingDouble.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<double>((global::System.ReadOnlyMemory<double>)args[0]),
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSByte.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<sbyte>((global::System.ReadOnlyMemory<sbyte>)args[0]),
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSingle.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<float>((global::System.ReadOnlyMemory<float>)args[0]),
Microsoft.Extensions.AI.OpenAI (1)
OpenAIEmbeddingGenerator.cs (1)
86new Embedding<float>(e.ToFloats())
Microsoft.Extensions.AI.Tests (15)
ChatRouting\SemanticRoutingChatClientTests.cs (3)
94[.. inputs.Select(input => new Embedding<float>(vectors[input]))])); 144[.. values.Select(input => new Embedding<float>(vectors[input]))])), 187[.. values.Select(input => new Embedding<float>(vectors[input]))])),
Embeddings\DistributedCachingEmbeddingGeneratorTest.cs (8)
18private readonly Embedding<float> _expectedEmbedding = new(new float[] { 1.0f, 2.0f, 3.0f }) 90new Embedding<float>(new[] { 1.0f, 2.0f, 3.0f }) 254return [new(((string)options!.AdditionalProperties!["someKey"]!).Select(c => (float)c).ToArray())]; 274AssertEmbeddingsEqual(new("value 1".Select(c => (float)c).ToArray()), result1); 275AssertEmbeddingsEqual(new("value 1".Select(c => (float)c).ToArray()), result2); 289AssertEmbeddingsEqual(new("value 1".Select(c => (float)c).ToArray()), result3); 290AssertEmbeddingsEqual(new("value 2".Select(c => (float)c).ToArray()), result4); 305return new(new Embedding<float>[] { new Embedding<float>(new float[] { innerCallCount }) });
Embeddings\LoggingEmbeddingGeneratorTests.cs (1)
58return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1f, 2f, 3f })]));
Embeddings\OpenTelemetryEmbeddingGeneratorTests.cs (1)
38return new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1, 2, 3 })])
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (1)
53e.Add(new Embedding<float>(default));
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSingle.g.cs (1)
32ObjectWithParameterizedConstructorCreator = static args => new global::Microsoft.Extensions.AI.Embedding<float>((global::System.ReadOnlyMemory<float>)args[0]),
Microsoft.Extensions.DataIngestion.Tests (7)
Chunkers\SemanticSimilarityChunkerTests.cs (6)
50new Embedding<float>(new float[] { 1.0f, 2.0f, 3.0f, 4.0f })) 880 => new Embedding<float>(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }), 891 => new Embedding<float>(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }), 902 => new Embedding<float>(new float[] { -1.0f, -1.0f, -1.0f, -1.0f }), 165<= 3 => new Embedding<float>(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }), 166>= 4 and <= 7 => new Embedding<float>(new float[] { -1.0f, -1.0f, -1.0f, -1.0f }),
Utils\TestEmbeddingGenerator.cs (1)
28[new(new float[] { 0, 1, 2, 3 })]));
Microsoft.Extensions.VectorData.ConformanceTests (4)
EmbeddingGenerationTests.cs (2)
597results.Add(new Embedding<float>(vector)); 614=> Task.FromResult(new GeneratedEmbeddings<Embedding<float>> { new(embedding) });
TypeTests\EmbeddingTypeTests.cs (2)
31new Embedding<float>(new ReadOnlyMemory<float>([1, 2, 3])), 186=> Task.FromResult(new GeneratedEmbeddings<Embedding<T>>([new(data)]));
491 references to Embedding
Aspire.Azure.AI.Inference (5)
AspireAzureAIInferenceExtensions.cs (5)
477public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddEmbeddingGenerator(this AspireEmbeddingsClientBuilder builder, string? deploymentName = null) 506public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddKeyedEmbeddingGenerator(this AspireEmbeddingsClientBuilder builder, string serviceKey, string? deploymentName = null) 517private static IEmbeddingGenerator<string, Embedding<float>> CreateInnerEmbeddingGenerator(AspireEmbeddingsClientBuilder builder, IServiceProvider services, string? deploymentName) 531return new OpenTelemetryEmbeddingGenerator<string, Embedding<float>>(result, loggerFactory?.CreateLogger(typeof(OpenTelemetryEmbeddingGenerator<string, Embedding<float>>)))
Aspire.Azure.AI.Inference.Tests (2)
AspireAzureAIInferenceEmbeddingsExtensionTests.cs (2)
108host.Services.GetKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("embedding") : 109host.Services.GetService<IEmbeddingGenerator<string, Embedding<float>>>();
Aspire.Azure.AI.OpenAI.Tests (18)
AspireAzureOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (18)
36host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 37host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 66host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 67host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 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>>>(); 187host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 188host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 190Assert.Equal(disableOpenTelemetry, generator.GetService<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>() is null); 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) 224return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>(inputs.Select(i => new Embedding<float>(floats))));
Aspire.OpenAI (5)
AspireOpenAIClientBuilderEmbeddingGeneratorExtensions.cs (5)
23public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddEmbeddingGenerator( 40public static EmbeddingGeneratorBuilder<string, Embedding<float>> AddKeyedEmbeddingGenerator( 58private static IEmbeddingGenerator<string, Embedding<float>> CreateInnerEmbeddingGenerator( 76return new OpenTelemetryEmbeddingGenerator<string, Embedding<float>>( 78loggerFactory?.CreateLogger(typeof(OpenTelemetryEmbeddingGenerator<string, Embedding<float>>)))
Aspire.OpenAI.Tests (20)
AspireOpenAIClientBuilderEmbeddingGeneratorExtensionsTests.cs (20)
39host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 40host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 69host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 70host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 97host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 98host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 128host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 129host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 159host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 160host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 190host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 191host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 193Assert.Equal(disableOpenTelemetry, generator.GetService<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>() is null); 217host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 218host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 250host.Services.GetRequiredKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("openai_embeddinggenerator") : 251host.Services.GetRequiredService<IEmbeddingGenerator<string, Embedding<float>>>(); 268private Task<GeneratedEmbeddings<Embedding<float>>> TestMiddleware(IEnumerable<string> inputs, EmbeddingGenerationOptions? options, IEmbeddingGenerator<string, Embedding<float>> nextAsync, CancellationToken cancellationToken) 271return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>(inputs.Select(i => new Embedding<float>(floats))));
Microsoft.Extensions.AI (5)
ChatRouting\SemanticRoutingChatClient.cs (4)
48private readonly IEmbeddingGenerator<string, Embedding<float>> _embeddingGenerator; 88IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator, 185GeneratedEmbeddings<Embedding<float>> generated = 316GeneratedEmbeddings<Embedding<float>> embeddings =
Embeddings\CachingEmbeddingGenerator.cs (1)
119/// <summary>Returns a previously cached <see cref="Embedding{TEmbedding}"/>, if available.</summary>
Microsoft.Extensions.AI.Abstractions (129)
Embeddings\Embedding.cs (5)
14[JsonDerivedType(typeof(Embedding<byte>), typeDiscriminator: "uint8")] 15[JsonDerivedType(typeof(Embedding<sbyte>), typeDiscriminator: "int8")] 17[JsonDerivedType(typeof(Embedding<Half>), typeDiscriminator: "float16")] 19[JsonDerivedType(typeof(Embedding<float>), typeDiscriminator: "float32")] 20[JsonDerivedType(typeof(Embedding<double>), typeDiscriminator: "float64")]
Embeddings\Embedding{T}.cs (1)
14/// <summary>Initializes a new instance of the <see cref="Embedding{T}"/> class with the embedding vector.</summary>
Embeddings\EmbeddingGeneratorExtensions.cs (4)
100/// resulting <see cref="Embedding{T}"/>'s <see cref="Embedding{T}.Vector"/> property. 103this IEmbeddingGenerator<TInput, Embedding<TEmbeddingElement>> generator, 108var embedding = await GenerateAsync(generator, value, options, cancellationToken).ConfigureAwait(false);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingByte.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>>? _EmbeddingByte; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> EmbeddingByte 24get => _EmbeddingByte ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<byte>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> Create_EmbeddingByte(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<byte>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<byte>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<byte>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<byte>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<byte>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<byte>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<byte>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<byte>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<byte>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingByteSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<byte>? value) 169global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::Microsoft.Extensions.AI.Embedding<byte>)value).Vector, ReadOnlyMemoryByte);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingDouble.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>>? _EmbeddingDouble; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> EmbeddingDouble 24get => _EmbeddingDouble ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<double>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> Create_EmbeddingDouble(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<double>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<double>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<double>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<double>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<double>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<double>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<double>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<double>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<double>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingDoubleSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<double>? value) 169ReadOnlyMemoryDoubleSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<double>)value).Vector);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingHalf.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>>? _EmbeddingHalf; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>> EmbeddingHalf 24get => _EmbeddingHalf ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>> Create_EmbeddingHalf(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<global::System.Half>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<global::System.Half>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<global::System.Half>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<global::System.Half>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<global::System.Half>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<global::System.Half>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<global::System.Half>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingHalfSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<global::System.Half>? value) 169ReadOnlyMemoryHalfSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<global::System.Half>)value).Vector);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingInt32.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<int>>? _EmbeddingInt32; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<int>> EmbeddingInt32 24get => _EmbeddingInt32 ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<int>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<int>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<int>> Create_EmbeddingInt32(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<int>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<int>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<int>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<int>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<int>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<int>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<int>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<int>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<int>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<int>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<int>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<int>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<int>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingInt32SerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<int>? value) 169ReadOnlyMemoryInt32SerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<int>)value).Vector);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingSByte.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>? _EmbeddingSByte; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> EmbeddingSByte 24get => _EmbeddingSByte ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> Create_EmbeddingSByte(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<sbyte>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<sbyte>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<sbyte>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<sbyte>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<sbyte>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<sbyte>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingSByteSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<sbyte>? value) 169ReadOnlyMemorySByteSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<sbyte>)value).Vector);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.EmbeddingSingle.g.cs (18)
15private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>? _EmbeddingSingle; 21public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> EmbeddingSingle 24get => _EmbeddingSingle ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<float>)); 27private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> Create_EmbeddingSingle(global::System.Text.Json.JsonSerializerOptions options) 29if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<float>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> jsonTypeInfo)) 31var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<float>> 37ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<float>)}, modifiers: null), 41jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<float>>(options, objectInfo); 58DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 60Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector, 61Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector = value!, 68AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<float>), global::System.Array.Empty<global::System.Type>(), null), 78DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 88AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 158private void EmbeddingSingleSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<float>? value) 169ReadOnlyMemorySingleSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<float>)value).Vector);
Generated\Basic.CompilerLog.Util\Basic.CompilerLog.Util.Impl.BasicGeneratedFilesAnalyzerReference\JsonContext.GetJsonTypeInfo.g.cs (6)
160if (type == typeof(global::Microsoft.Extensions.AI.Embedding<byte>)) 164if (type == typeof(global::Microsoft.Extensions.AI.Embedding<double>)) 168if (type == typeof(global::Microsoft.Extensions.AI.Embedding<float>)) 172if (type == typeof(global::Microsoft.Extensions.AI.Embedding<global::System.Half>)) 176if (type == typeof(global::Microsoft.Extensions.AI.Embedding<int>)) 180if (type == typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>))
Utilities\AIJsonUtilities.Defaults.cs (5)
116[JsonSerializable(typeof(Embedding<byte>))] 117[JsonSerializable(typeof(Embedding<int>))] 119[JsonSerializable(typeof(Embedding<Half>))] 121[JsonSerializable(typeof(Embedding<float>))] 122[JsonSerializable(typeof(Embedding<double>))]
Microsoft.Extensions.AI.Abstractions.Tests (142)
Embeddings\DelegatingEmbeddingGeneratorTests.cs (6)
27var expectedResult = new TaskCompletionSource<GeneratedEmbeddings<Embedding<float>>>(); 28var expectedEmbedding = new GeneratedEmbeddings<Embedding<float>>([new(new float[] { 1.0f, 2.0f, 3.0f })]); 67var service = delegating.GetService<DelegatingEmbeddingGenerator<string, Embedding<float>>>(); 87var service = delegating.GetService<IEmbeddingGenerator<string, Embedding<float>>>(expectedKey); 115private sealed class NoOpDelegatingEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> innerGenerator) : 116DelegatingEmbeddingGenerator<string, Embedding<float>>(innerGenerator);
Embeddings\EmbeddingGeneratorExtensionsTests.cs (6)
31using IEmbeddingGenerator<string, Embedding<float>> generator = new TestEmbeddingGenerator 40if (serviceType == typeof(IEmbeddingGenerator<string, Embedding<float>>)) 89Embedding<float> result = new(new float[] { 1f, 2f, 3f }); 94Task.FromResult<GeneratedEmbeddings<Embedding<float>>>([result]) 108Embedding<float>[] embeddings = Enumerable 116Task.FromResult<GeneratedEmbeddings<Embedding<float>>>(new(embeddings))
Embeddings\EmbeddingTests.cs (15)
23Embedding<float> e = new(floats) 43Embedding<byte> e = new(bytes); 48Embedding<byte> result = Assert.IsType<Embedding<byte>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 56Embedding<sbyte> e = new(bytes); 61Embedding<sbyte> result = Assert.IsType<Embedding<sbyte>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 84Embedding<float> e = new(floats); 89Embedding<float> result = Assert.IsType<Embedding<float>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 97Embedding<double> e = new(floats); 102Embedding<double> result = Assert.IsType<Embedding<double>>(JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.Embedding)); 124var floatEmbedding = Assert.IsType<Embedding<float>>(result);
Embeddings\GeneratedEmbeddingsTests.cs (38)
20Assert.Throws<ArgumentNullException>("embeddings", () => new GeneratedEmbeddings<Embedding<float>>(null!)); 21Assert.Throws<ArgumentOutOfRangeException>("capacity", () => new GeneratedEmbeddings<Embedding<float>>(-1)); 27GeneratedEmbeddings<Embedding<float>>[] instances = 39Assert.False(((ICollection<Embedding<float>>)instance).IsReadOnly); 48instance.CopyTo(Array.Empty<Embedding<float>>(), 0); 58List<Embedding<float>> embeddings = 64var generatedEmbeddings = new GeneratedEmbeddings<Embedding<float>>(embeddings); 86var e = new Embedding<float>(new float[] { 7, 8, 9 }); 95GeneratedEmbeddings<Embedding<float>> embeddings = []; 116GeneratedEmbeddings<Embedding<float>> embeddings = []; 117var e = new Embedding<float>(new float[] { 1, 2, 3 }); 127GeneratedEmbeddings<Embedding<float>> embeddings = []; 129var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 130var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 142GeneratedEmbeddings<Embedding<float>> embeddings = []; 144var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 145var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 158GeneratedEmbeddings<Embedding<float>> embeddings = []; 160var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 161var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 181GeneratedEmbeddings<Embedding<float>> embeddings = []; 183var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 184var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 200GeneratedEmbeddings<Embedding<float>> embeddings = []; 202var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 203var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 208var e3 = new Embedding<float>(new float[] { 7, 8, 9 }); 218GeneratedEmbeddings<Embedding<float>> embeddings = []; 220var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 221var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 226var e3 = new Embedding<float>(new float[] { 7, 8, 9 }); 236GeneratedEmbeddings<Embedding<float>> embeddings = []; 238var e1 = new Embedding<float>(new float[] { 1, 2, 3 }); 239var e2 = new Embedding<float>(new float[] { 4, 5, 6 }); 251var expectedGeneratedEmbeddings = new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1, 2, 3 })]); 253using IEmbeddingGenerator<object, Embedding<float>> acceptsObject = new TestEmbeddingGenerator<object, Embedding<float>> 258IEmbeddingGenerator<string, Embedding<float>> acceptsString = acceptsObject;
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingByte.g.cs (18)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>>? _EmbeddingByte; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> EmbeddingByte 22get => _EmbeddingByte ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<byte>)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> Create_EmbeddingByte(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<byte>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<byte>> jsonTypeInfo)) 29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<byte>> 35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<byte>)}, modifiers: null), 39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<byte>>(options, objectInfo); 56DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<byte>), 58Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<byte>)obj).Vector, 59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<byte>)obj).Vector = value!, 66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<byte>), global::System.Array.Empty<global::System.Type>(), null), 76DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<byte>), 86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<byte>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 156private void EmbeddingByteSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<byte>? value) 167global::System.Text.Json.JsonSerializer.Serialize(writer, ((global::Microsoft.Extensions.AI.Embedding<byte>)value).Vector, ReadOnlyMemoryByte);
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingDouble.g.cs (18)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>>? _EmbeddingDouble; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> EmbeddingDouble 22get => _EmbeddingDouble ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<double>)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> Create_EmbeddingDouble(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<double>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<double>> jsonTypeInfo)) 29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<double>> 35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<double>)}, modifiers: null), 39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<double>>(options, objectInfo); 56DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<double>), 58Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<double>)obj).Vector, 59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<double>)obj).Vector = value!, 66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<double>), global::System.Array.Empty<global::System.Type>(), null), 76DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<double>), 86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<double>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 156private void EmbeddingDoubleSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<double>? value) 167ReadOnlyMemoryDoubleSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<double>)value).Vector);
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSByte.g.cs (18)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>? _EmbeddingSByte; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> EmbeddingSByte 22get => _EmbeddingSByte ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> Create_EmbeddingSByte(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<sbyte>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>> jsonTypeInfo)) 29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<sbyte>> 35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<sbyte>)}, modifiers: null), 39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<sbyte>>(options, objectInfo); 56DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>), 58Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<sbyte>)obj).Vector, 59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<sbyte>)obj).Vector = value!, 66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<sbyte>), global::System.Array.Empty<global::System.Type>(), null), 76DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>), 86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 156private void EmbeddingSByteSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<sbyte>? value) 167ReadOnlyMemorySByteSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<sbyte>)value).Vector);
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSingle.g.cs (18)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>? _EmbeddingSingle; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> EmbeddingSingle 22get => _EmbeddingSingle ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<float>)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> Create_EmbeddingSingle(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<float>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> jsonTypeInfo)) 29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<float>> 35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<float>)}, modifiers: null), 39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<float>>(options, objectInfo); 56DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 58Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector, 59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector = value!, 66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<float>), global::System.Array.Empty<global::System.Type>(), null), 76DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 156private void EmbeddingSingleSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<float>? value) 167ReadOnlyMemorySingleSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<float>)value).Vector);
Generated\361d1da7f942c932\TestJsonSerializerContext.GetJsonTypeInfo.g.cs (4)
154if (type == typeof(global::Microsoft.Extensions.AI.Embedding<byte>)) 158if (type == typeof(global::Microsoft.Extensions.AI.Embedding<double>)) 162if (type == typeof(global::Microsoft.Extensions.AI.Embedding<float>)) 166if (type == typeof(global::Microsoft.Extensions.AI.Embedding<sbyte>))
TestEmbeddingGenerator.cs (1)
41public sealed class TestEmbeddingGenerator : TestEmbeddingGenerator<string, Embedding<float>>;
Microsoft.Extensions.AI.Integration.Tests (14)
CallCountingEmbeddingGenerator.cs (5)
13internal sealed class CallCountingEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> innerGenerator) 14: DelegatingEmbeddingGenerator<string, Embedding<float>>(innerGenerator) 20public override Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync( 30public static EmbeddingGeneratorBuilder<string, Embedding<float>> UseCallCounting( 31this EmbeddingGeneratorBuilder<string, Embedding<float>> builder) =>
EmbeddingGeneratorIntegrationTests.cs (6)
29private readonly IEmbeddingGenerator<string, Embedding<float>>? _embeddingGenerator; 42protected abstract IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator(); 93var embedding1 = await generator.GenerateAsync(input); 94var embedding2 = await generator.GenerateAsync(input); 95var embedding3 = await generator.GenerateAsync(input + "... and Green"); 96var embedding4 = await generator.GenerateAsync(input);
QuantizationEmbeddingGenerator.cs (3)
22private readonly IEmbeddingGenerator<string, Embedding<float>> _floatService; 24public QuantizationEmbeddingGenerator(IEmbeddingGenerator<string, Embedding<float>> floatService) 46private static BinaryEmbedding QuantizeToBinary(Embedding<float> embedding)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
OllamaSharpEmbeddingGeneratorIntegrationTests.cs (1)
13protected override IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator() =>
Microsoft.Extensions.AI.OpenAI (3)
OpenAIClientExtensions.cs (1)
192public static IEmbeddingGenerator<string, Embedding<float>> AsIEmbeddingGenerator(this EmbeddingClient embeddingClient, int? defaultModelDimensions = null) =>
OpenAIEmbeddingGenerator.cs (2)
21internal sealed class OpenAIEmbeddingGenerator : IEmbeddingGenerator<string, Embedding<float>> 68public async Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(IEnumerable<string> values, EmbeddingGenerationOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.OpenAI.Tests (29)
OpenAIEmbeddingGeneratorIntegrationTests.cs (1)
8protected override IEmbeddingGenerator<string, Embedding<float>>? CreateEmbeddingGenerator() =>
OpenAIEmbeddingGeneratorTests.cs (27)
35IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = client.GetEmbeddingClient(model).AsIEmbeddingGenerator(); 51IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = openAIClient.AsIEmbeddingGenerator(); 53Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 59using IEmbeddingGenerator<string, Embedding<float>> pipeline = embeddingGenerator 65Assert.NotNull(pipeline.GetService<DistributedCachingEmbeddingGenerator<string, Embedding<float>>>()); 66Assert.NotNull(pipeline.GetService<CachingEmbeddingGenerator<string, Embedding<float>>>()); 67Assert.NotNull(pipeline.GetService<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>()); 70Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 77IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator = openAIClient.AsIEmbeddingGenerator(); 79Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 82using IEmbeddingGenerator<string, Embedding<float>> pipeline = embeddingGenerator 88Assert.NotNull(pipeline.GetService<DistributedCachingEmbeddingGenerator<string, Embedding<float>>>()); 89Assert.NotNull(pipeline.GetService<CachingEmbeddingGenerator<string, Embedding<float>>>()); 90Assert.NotNull(pipeline.GetService<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>()); 93Assert.IsType<OpenTelemetryEmbeddingGenerator<string, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<string, Embedding<float>>>()); 128using IEmbeddingGenerator<string, Embedding<float>> generator = CreateEmbeddingGenerator(httpClient, "text-embedding-3-small"); 141foreach (Embedding<float> e in response) 188using IEmbeddingGenerator<string, Embedding<float>> generator = CreateEmbeddingGenerator(httpClient, "text-embedding-3-small"); 210foreach (Embedding<float> e in response) 246using IEmbeddingGenerator<string, Embedding<float>> generator = CreateEmbeddingGenerator(httpClient, "text-embedding-3-small"); 253foreach (Embedding<float> e in response) 289using IEmbeddingGenerator<string, Embedding<float>> generator = CreateEmbeddingGenerator(httpClient, "text-embedding-3-small"); 296foreach (Embedding<float> e in response) 309using IEmbeddingGenerator<string, Embedding<float>> generator = CreateEmbeddingGenerator(httpClient, "text-embedding-3-small"); 317private static IEmbeddingGenerator<string, Embedding<float>> CreateEmbeddingGenerator(HttpClient httpClient, string modelId) =>
OpenAIRequestPoliciesTests.cs (1)
53IEmbeddingGenerator<string, Embedding<float>> generator =
Microsoft.Extensions.AI.Tests (100)
ChatCompletion\DependencyInjectionPatterns.cs (6)
172Assert.Equal(typeof(IEmbeddingGenerator<string, Embedding<float>>), sd.ServiceType); 194IEmbeddingGenerator<string, Embedding<float>>? g = sp.GetService<IEmbeddingGenerator<string, Embedding<float>>>(); 217Assert.Equal(typeof(IEmbeddingGenerator<string, Embedding<float>>), sd.ServiceType); 240IEmbeddingGenerator<string, Embedding<float>>? g = sp.GetKeyedService<IEmbeddingGenerator<string, Embedding<float>>>("key");
ChatRouting\SemanticRoutingChatClientTests.cs (5)
93return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>( 143Task.FromResult(new GeneratedEmbeddings<Embedding<float>>( 186Task.FromResult(new GeneratedEmbeddings<Embedding<float>>( 262IEmbeddingGenerator<string, Embedding<float>> 266public Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(
Embeddings\ConfigureOptionsEmbeddingGeneratorTests.cs (4)
16Assert.Throws<ArgumentNullException>("innerGenerator", () => new ConfigureOptionsEmbeddingGenerator<string, Embedding<float>>(null!, _ => { })); 17Assert.Throws<ArgumentNullException>("configure", () => new ConfigureOptionsEmbeddingGenerator<string, Embedding<float>>(new TestEmbeddingGenerator(), null!)); 35GeneratedEmbeddings<Embedding<float>> expectedEmbeddings = []; 38using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator
Embeddings\DistributedCachingEmbeddingGeneratorTest.cs (35)
18private readonly Embedding<float> _expectedEmbedding = new(new float[] { 1.0f, 2.0f, 3.0f }) 29using DistributedCachingEmbeddingGenerator<string, Embedding<float>> generator = new(innerGenerator, _storage); 56return Task.FromResult<GeneratedEmbeddings<Embedding<float>>>([_expectedEmbedding]); 59using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(testGenerator, _storage) 65var result1 = await outer.GenerateAsync("abc"); 70var result2 = await outer.GenerateAsync("abc"); 89Embedding<float>[] expected = Enumerable.Range(0, 10).Select(i => 102return Task.FromResult<GeneratedEmbeddings<Embedding<float>>>(new(values.Select(i => expected[int.Parse(i)]))); 105using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(testGenerator, _storage) 150using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, _storage) 168var result3 = await outer.GenerateAsync("abc"); 186using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, _storage) 223using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, _storage) 237var result2 = await outer.GenerateAsync("abc"); 257using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, _storage) 263var result1 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 267var result2 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 278var result3 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 282var result4 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 305return new(new Embedding<float>[] { new Embedding<float>(new float[] { innerCallCount }) }); 308using var outer = new DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, _storage) 313var result1 = await outer.GenerateAsync("abc"); 314var result2 = await outer.GenerateAsync("abc"); 317var result3 = await outer.GenerateAsync("abc"); 323var result4 = await outer.GenerateAsync("abc"); 326var result5 = await outer.GenerateAsync("abc"); 332var result6 = await outer.GenerateAsync("abc"); 357var result1 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 361var result2 = await outer.GenerateAsync("abc", new EmbeddingGenerationOptions 383return Task.FromResult<GeneratedEmbeddings<Embedding<float>>>([_expectedEmbedding]); 396var result = await outer.GenerateAsync("abc"); 403private static void AssertEmbeddingsEqual(Embedding<float> expected, Embedding<float> actual) 413private sealed class CachingEmbeddingGeneratorWithCustomKey(IEmbeddingGenerator<string, Embedding<float>> innerGenerator, IDistributedCache storage) 414: DistributedCachingEmbeddingGenerator<string, Embedding<float>>(innerGenerator, storage)
Embeddings\EmbeddingGeneratorBuilderTests.cs (9)
19var builder = new EmbeddingGeneratorBuilder<string, Embedding<float>>(services => 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) : 82DelegatingEmbeddingGenerator<string, Embedding<float>>(innerGenerator) 87public new IEmbeddingGenerator<string, Embedding<float>> InnerGenerator => base.InnerGenerator;
Embeddings\LoggingEmbeddingGeneratorTests.cs (11)
19Assert.Throws<ArgumentNullException>("innerGenerator", () => new LoggingEmbeddingGenerator<string, Embedding<float>>(null!, NullLogger.Instance)); 20Assert.Throws<ArgumentNullException>("logger", () => new LoggingEmbeddingGenerator<string, Embedding<float>>(new TestEmbeddingGenerator(), null!)); 28Assert.Null(innerGenerator.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(LoggingEmbeddingGenerator<string, Embedding<float>>))); 29Assert.Same(innerGenerator, innerGenerator.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build().GetService(typeof(IEmbeddingGenerator<string, Embedding<float>>))); 32Assert.NotNull(innerGenerator.AsBuilder().UseLogging(factory).Build().GetService(typeof(LoggingEmbeddingGenerator<string, Embedding<float>>))); 37Assert.NotNull(innerGenerator.AsBuilder().UseLogging().Build(services).GetService(typeof(LoggingEmbeddingGenerator<string, Embedding<float>>))); 38Assert.NotNull(innerGenerator.AsBuilder().UseLogging(null).Build(services).GetService(typeof(LoggingEmbeddingGenerator<string, Embedding<float>>))); 39Assert.Null(innerGenerator.AsBuilder().UseLogging(NullLoggerFactory.Instance).Build(services).GetService(typeof(LoggingEmbeddingGenerator<string, Embedding<float>>))); 54using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator 58return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1f, 2f, 3f })])); 62using IEmbeddingGenerator<string, Embedding<float>> generator = innerGenerator
Embeddings\OpenTelemetryEmbeddingGeneratorTests.cs (1)
38return new GeneratedEmbeddings<Embedding<float>>([new Embedding<float>(new float[] { 1, 2, 3 })])
Embeddings\UseDelegateEmbeddingGeneratorTests.cs (8)
18EmbeddingGeneratorBuilder<string, Embedding<float>> builder = new(generator); 21builder.Use((Func<IEnumerable<string>, EmbeddingGenerationOptions?, IEmbeddingGenerator<string, Embedding<float>>, CancellationToken, Task<GeneratedEmbeddings<Embedding<float>>>>)null!)); 27GeneratedEmbeddings<Embedding<float>> expectedEmbeddings = []; 33using IEmbeddingGenerator<string, Embedding<float>> innerGenerator = new TestEmbeddingGenerator 45using IEmbeddingGenerator<string, Embedding<float>> generator = new EmbeddingGeneratorBuilder<string, Embedding<float>>(innerGenerator) 60GeneratedEmbeddings<Embedding<float>> actual = await generator.GenerateAsync(expectedValues, expectedOptions, expectedCts.Token);
Generated\361d1da7f942c932\TestJsonSerializerContext.EmbeddingSingle.g.cs (18)
13private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>? _EmbeddingSingle; 19public global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> EmbeddingSingle 22get => _EmbeddingSingle ??= (global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>>)Options.GetTypeInfo(typeof(global::Microsoft.Extensions.AI.Embedding<float>)); 25private global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> Create_EmbeddingSingle(global::System.Text.Json.JsonSerializerOptions options) 27if (!TryGetTypeInfoForRuntimeCustomConverter<global::Microsoft.Extensions.AI.Embedding<float>>(options, out global::System.Text.Json.Serialization.Metadata.JsonTypeInfo<global::Microsoft.Extensions.AI.Embedding<float>> jsonTypeInfo)) 29var objectInfo = new global::System.Text.Json.Serialization.Metadata.JsonObjectInfoValues<global::Microsoft.Extensions.AI.Embedding<float>> 35ConstructorAttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetConstructor(InstanceMemberBindingFlags, binder: null, new[] {typeof(global::System.ReadOnlyMemory<float>)}, modifiers: null), 39jsonTypeInfo = global::System.Text.Json.Serialization.Metadata.JsonMetadataServices.CreateObjectInfo<global::Microsoft.Extensions.AI.Embedding<float>>(options, objectInfo); 56DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 58Getter = static obj => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector, 59Setter = static (obj, value) => ((global::Microsoft.Extensions.AI.Embedding<float>)obj).Vector = value!, 66AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Vector", InstanceMemberBindingFlags, null, typeof(global::System.ReadOnlyMemory<float>), global::System.Array.Empty<global::System.Type>(), null), 76DeclaringType = typeof(global::Microsoft.Extensions.AI.Embedding<float>), 86AttributeProviderFactory = static () => typeof(global::Microsoft.Extensions.AI.Embedding<float>).GetProperty("Dimensions", InstanceMemberBindingFlags, null, typeof(int), global::System.Array.Empty<global::System.Type>(), null), 156private void EmbeddingSingleSerializeHandler(global::System.Text.Json.Utf8JsonWriter writer, global::Microsoft.Extensions.AI.Embedding<float>? value) 167ReadOnlyMemorySingleSerializeHandler(writer, ((global::Microsoft.Extensions.AI.Embedding<float>)value).Vector);
Generated\361d1da7f942c932\TestJsonSerializerContext.GetJsonTypeInfo.g.cs (1)
130if (type == typeof(global::Microsoft.Extensions.AI.Embedding<float>))
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestEmbeddingGenerator.cs (1)
41public sealed class TestEmbeddingGenerator : TestEmbeddingGenerator<string, Embedding<float>>;
TestJsonSerializerContext.cs (1)
21[JsonSerializable(typeof(Embedding<float>))]
Microsoft.Extensions.DataIngestion (2)
Chunkers\SemanticSimilarityChunker.cs (2)
21private readonly IEmbeddingGenerator<string, Embedding<float>> _embeddingGenerator; 31IEmbeddingGenerator<string, Embedding<float>> embeddingGenerator,
Microsoft.Extensions.DataIngestion.Tests (4)
parent\Microsoft.Extensions.AI.Abstractions.Tests\TestEmbeddingGenerator.cs (1)
41public sealed class TestEmbeddingGenerator : TestEmbeddingGenerator<string, Embedding<float>>;
Utils\TestEmbeddingGenerator.cs (3)
12public sealed class TestEmbeddingGenerator<T> : IEmbeddingGenerator<T, Embedding<float>> 23public Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(IEnumerable<T> values, EmbeddingGenerationOptions? options = null, CancellationToken cancellationToken = default) 27return Task.FromResult(new GeneratedEmbeddings<Embedding<float>>(
Microsoft.Extensions.VectorData.Abstractions (3)
ProviderServices\CollectionModelBuilder.cs (2)
373/// Override this property in providers that support additional embedding types beyond <see cref="Embedding{T}"/> of <see langword="float"/>. 376= [EmbeddingGenerationDispatcher.Create<Embedding<float>>()];
ProviderServices\VectorPropertyModel.cs (1)
86/// (e.g., <see cref="ReadOnlyMemory{T}"/> of <see langword="float"/>, <see langword="float"/>[], <see cref="Embedding{T}"/>),
Microsoft.Extensions.VectorData.ConformanceTests (9)
EmbeddingGenerationTests.cs (6)
579protected sealed class FakeEmbeddingGenerator(int? replaceLast = null) : IEmbeddingGenerator<string, Embedding<float>> 581public Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync( 586var results = new GeneratedEmbeddings<Embedding<float>>(); 611private sealed class FakeCustomerEmbeddingGenerator(float[] embedding) : IEmbeddingGenerator<Customer, Embedding<float>> 613public Task<GeneratedEmbeddings<Embedding<float>>> GenerateAsync(IEnumerable<Customer> values, EmbeddingGenerationOptions? options = null, CancellationToken cancellationToken = default) 614=> Task.FromResult(new GeneratedEmbeddings<Embedding<float>> { new(embedding) });
TypeTests\EmbeddingTypeTests.cs (3)
180protected sealed class ReadOnlyMemoryEmbeddingGenerator<T>(T[] data) : IEmbeddingGenerator<string, Embedding<T>> 182public Task<GeneratedEmbeddings<Embedding<T>>> GenerateAsync( 186=> Task.FromResult(new GeneratedEmbeddings<Embedding<T>>([new(data)]));