63 instantiations of DataContent
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (46)
ChatCompletion\ChatMessageTests.cs (4)
147new DataContent("data:text/image;base64,aGVsbG8="),
148new DataContent("data:text/plain;base64,aGVsbG8="),
260new DataContent(new Uri("data:text/plain;base64,aGVsbG8="), "mime-type/2")
264new DataContent(new BinaryData(new[] { 1, 2, 3 }, options: TestJsonSerializerContext.Default.Options), "mime-type/3")
Contents\DataContentTests.cs (19)
46Assert.Throws(exception, () => new DataContent(path));
58Assert.Throws<ArgumentException>("mediaType", () => new DataContent("data:image/png;base64,aGVsbG8=", type));
68var content = new DataContent("data:image/png;base64,aGVsbG8=", mediaType);
72content = new DataContent("data:,", mediaType);
76content = new DataContent("data:text/plain,", mediaType);
80content = new DataContent(new Uri("data:text/plain,"), mediaType);
84content = new DataContent(new byte[] { 0, 1, 2 }, mediaType);
88content = new DataContent(content.Uri);
98content = new DataContent("data:image/png;base64,aGVsbG8=");
103content = new DataContent(new Uri("data:image/png;base64,aGVsbG8="));
115new DataContent(uri: "data:application/octet-stream;base64,AQIDBA=="),
121new DataContent(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream"),
127new DataContent(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream") { Name = "test.bin" },
216DataContent c = new("data:,", mediaType);
229var content = new DataContent("data:application/octet-stream;base64,AQIDBA==", mediaType);
242var content = new DataContent("data:application/octet-stream;base64,AQIDBA==", mediaType);
255var content = new DataContent(data, "application/octet-stream");
265var content = new DataContent("data:text/plain,hello world");
274DataContent content = new(new byte[] { 1, 2, 3 }, "application/octet-stream");
Image\ImageGenerationResponseTests.cs (3)
74new DataContent(imageData, "image/jpeg")
100new DataContent((byte[])[1, 2, 3, 4], "image/jpeg")
138new DataContent((byte[])[255, 216, 255, 224], "image/jpeg"),
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (2)
Microsoft.Extensions.AI.Integration.Tests (3)
Microsoft.Extensions.AI.OpenAI (6)
Microsoft.Extensions.AI.OpenAI.Tests (2)
Microsoft.Extensions.AI.Tests (1)
93 references to DataContent
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (15)
Microsoft.Extensions.AI.Abstractions.Tests (38)
Contents\DataContentTests.cs (15)
68var content = new DataContent("data:image/png;base64,aGVsbG8=", mediaType);
96DataContent content;
136Assert.Throws<ArgumentNullException>("uri", () => JsonSerializer.Deserialize<DataContent>(json, TestJsonSerializerContext.Default.Options)!);
143var content = JsonSerializer.Deserialize<DataContent>("""{"uri":"data:application/octet-stream;base64,AQIDBA=="}""", TestJsonSerializerContext.Default.Options)!;
151content = JsonSerializer.Deserialize<DataContent>("""{"uri":"data:application/octet-stream;base64,AQIDBA=="}""", TestJsonSerializerContext.Default.Options)!;
157content = JsonSerializer.Deserialize<DataContent>("""
184var content = JsonSerializer.Deserialize<DataContent>(serialized, TestJsonSerializerContext.Default.Options)!;
216DataContent c = new("data:,", mediaType);
229var content = new DataContent("data:application/octet-stream;base64,AQIDBA==", mediaType);
242var content = new DataContent("data:application/octet-stream;base64,AQIDBA==", mediaType);
255var content = new DataContent(data, "application/octet-stream");
265var content = new DataContent("data:text/plain,hello world");
274DataContent content = new(new byte[] { 1, 2, 3 }, "application/octet-stream");
Microsoft.Extensions.AI.AzureAIInference (6)
Microsoft.Extensions.AI.AzureAIInference.Tests (12)
AzureAIInferenceImageEmbeddingGeneratorTests.cs (12)
39IEmbeddingGenerator<DataContent, Embedding<float>> embeddingGenerator = client.AsIEmbeddingGenerator(model);
52Assert.Same(embeddingGenerator, embeddingGenerator.GetService<IEmbeddingGenerator<DataContent, Embedding<float>>>());
55using IEmbeddingGenerator<DataContent, Embedding<float>> pipeline = embeddingGenerator
61Assert.NotNull(pipeline.GetService<DistributedCachingEmbeddingGenerator<DataContent, Embedding<float>>>());
62Assert.NotNull(pipeline.GetService<CachingEmbeddingGenerator<DataContent, Embedding<float>>>());
63Assert.NotNull(pipeline.GetService<OpenTelemetryEmbeddingGenerator<DataContent, Embedding<float>>>());
66Assert.IsType<OpenTelemetryEmbeddingGenerator<DataContent, Embedding<float>>>(pipeline.GetService<IEmbeddingGenerator<DataContent, Embedding<float>>>());
72DataContent dotnetPng = new(ImageDataUri.GetImageDataUri());
106using IEmbeddingGenerator<DataContent, Embedding<float>> generator = new ImageEmbeddingsClient(
132DataContent dotnetPng = new(ImageDataUri.GetImageDataUri());
167using IEmbeddingGenerator<DataContent, Embedding<float>> generator = new ImageEmbeddingsClient(
Microsoft.Extensions.AI.Evaluation (1)
Microsoft.Extensions.AI.Evaluation.Safety (4)
Microsoft.Extensions.AI.Integration.Tests (9)
Microsoft.Extensions.AI.OpenAI (7)