94 references to DataContent
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatResponseExtensions.cs (1)
290
return new
DataContent
(new ReadOnlyMemory<byte>(ms.GetBuffer(), 0, (int)ms.Length), first.MediaType) { Name = first.Name };
Contents\DataContent.cs (1)
195
return new
DataContent
(new ReadOnlyMemory<byte>(memoryStream.GetBuffer(), 0, (int)memoryStream.Length), mediaType)
Image\ImageGeneratorExtensions.cs (1)
184
var dataContent = new
DataContent
(originalImageData, mediaType) { Name = fileName };
Microsoft.Extensions.AI.Abstractions.Tests (46)
ChatCompletion\ChatMessageTests.cs (1)
263
new
DataContent
(new BinaryData(new[] { 1, 2, 3 }, options: TestJsonSerializerContext.Default.Options), "mime-type/3")
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (7)
923
var image1 = new
DataContent
((byte[])[1, 2, 3, 4], "image/png") { Name = "image1.png" };
924
var image2 = new
DataContent
((byte[])[5, 6, 7, 8], "image/jpeg") { Name = "image2.jpg" };
925
var image3 = new
DataContent
((byte[])[9, 10, 11, 12], "image/png") { Name = "image3.png" };
926
var image4 = new
DataContent
((byte[])[13, 14, 15, 16], "image/gif") { Name = "image4.gif" };
981
var image1 = new
DataContent
((byte[])[1, 2, 3, 4], "image/png") { Name = "image1.png" };
982
var image2 = new
DataContent
((byte[])[5, 6, 7, 8], "image/jpeg") { Name = "image2.jpg" };
983
var image3 = new
DataContent
((byte[])[9, 10, 11, 12], "image/png") { Name = "image3.png" };
ChatCompletion\ChatResponseUpdateTests.cs (1)
124
new
DataContent
("data"u8.ToArray(), "text/plain"),
Contents\AIContentTests.cs (2)
65
new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream"),
80
new ImageGenerationToolResultContent { ImageId = "img456", Outputs = [new
DataContent
(new byte[] { 4, 5, 6 }, "image/png")] }
Contents\CodeInterpreterToolCallContentTests.cs (1)
57
new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")
Contents\CodeInterpreterToolResultContentTests.cs (1)
57
new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream"),
Contents\DataContentTests.cs (20)
87
content = new
DataContent
(new byte[] { 0, 1, 2 }, mediaType);
153
new
DataContent
(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream"),
159
new
DataContent
(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream") { Name = "test.bin" },
287
var content = new
DataContent
(data, "application/octet-stream");
306
DataContent content =
new
(new byte[] { 1, 2, 3 }, "application/octet-stream");
457
DataContent content =
new
(testData, "application/octet-stream");
484
DataContent content =
new
(testData, "application/json");
511
DataContent content =
new
(testData, "application/json")
543
DataContent content =
new
(testData, "application/json");
572
DataContent content =
new
(testData, "application/json");
598
DataContent content =
new
(testData, "application/json");
626
DataContent content =
new
(testData, "image/png") { Name = "myimage.png" };
655
DataContent content =
new
(testData, "text/plain") { Name = $"testfile_{Guid.NewGuid()}.txt" };
698
DataContent content =
new
(new byte[] { 1 }, "application/octet-stream");
735
DataContent content =
new
(testData, "text/css");
792
DataContent content =
new
(new byte[] { 1, 2, 3 }, "application/octet-stream");
832
DataContent content =
new
(testData, "application/json")
863
DataContent content =
new
(testData, "application/json");
921
DataContent content =
new
(testData, "application/octet-stream");
954
DataContent content =
new
(newContent, "application/octet-stream");
Contents\ImageGenerationToolResultContentTests.cs (5)
32
IList<AIContent> outputs = [new
DataContent
(new byte[] { 1, 2, 3 }, "image/png")];
55
new
DataContent
(new byte[] { 1, 2, 3 }, "image/png"),
57
new
DataContent
(new byte[] { 4, 5, 6 }, "image/gif")
76
new
DataContent
(new byte[] { 1, 2, 3 }, "image/png"),
102
new
DataContent
(new byte[] { 7, 8, 9 }, "image/png"),
Image\ImageGenerationResponseTests.cs (3)
74
new
DataContent
(imageData, "image/jpeg")
100
new
DataContent
((byte[])[1, 2, 3, 4], "image/jpeg")
138
new
DataContent
((byte[])[255, 216, 255, 224], "image/jpeg"),
Image\ImageGeneratorExtensionsTests.cs (3)
64
var dataContent = new
DataContent
(imageData, "image/png") { Name = "test.png" };
92
var dataContent = new
DataContent
(new byte[] { 1, 2, 3 }, "image/png");
202
var dataContent = new
DataContent
(imageData, "image/png");
Image\ImageGeneratorTests.cs (1)
139
AIContent[] originalImages = [new
DataContent
((byte[])[1, 2, 3, 4], "image/png")];
Tools\HostedCodeInterpreterToolTests.cs (1)
48
new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")
Microsoft.Extensions.AI.Integration.Tests (5)
ImageGeneratingChatClientIntegrationTests.cs (3)
159
var originalImageData = new
DataContent
(testImageData, "image/png") { Name = "original.png" };
375
var originalImage = new
DataContent
(testImageData, "image/png") { Name = "test.png" };
422
var imageContent = new
DataContent
(imageData, TestImageMediaType)
ImageGeneratorIntegrationTests.cs (1)
96
AIContent[] originalImages = [new
DataContent
(imageData, "image/png") { Name = "dotnet.png" }];
ToolReductionTests.cs (1)
311
new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream"),
Microsoft.Extensions.AI.OpenAI (11)
OpenAIAssistantsChatClient.cs (1)
208
Inputs = [new
DataContent
(Encoding.UTF8.GetBytes(details.CodeInterpreterInput), OpenAIClientExtensions.PythonMediaType)],
OpenAIChatClient.cs (4)
379
responseUpdate.Contents.Add(new
DataContent
(audioUpdate.AudioBytesUpdate.ToMemory(), GetOutputAudioMimeType(options))
499
returnMessage.Contents.Add(new
DataContent
(audio.AudioBytes.ToMemory(), GetOutputAudioMimeType(chatCompletionOptions))
751
contentPart.ImageBytes is not null ? new
DataContent
(contentPart.ImageBytes.ToMemory(), contentPart.ImageBytesMediaType) :
765
contentPart.FileBytes is not null ? new
DataContent
(contentPart.FileBytes.ToMemory(), contentPart.FileBytesMediaType) { Name = contentPart.Filename } :
OpenAIImageGenerator.cs (1)
134
contents.Add(new
DataContent
(image.ImageBytes.ToMemory(), contentType));
OpenAIResponsesChatClient.cs (5)
231
Inputs = !string.IsNullOrWhiteSpace(cicri.Code) ? [new
DataContent
(Encoding.UTF8.GetBytes(cicri.Code), OpenAIClientExtensions.PythonMediaType)] : null,
430
Inputs = [new
DataContent
(Encoding.UTF8.GetBytes(codeInterpreterDeltaUpdate.Delta), OpenAIClientExtensions.PythonMediaType)],
1278
content = new
DataContent
(part.InputFileBytes, part.InputFileBytesMediaType ?? "application/octet-stream") { Name = part.InputFilename };
1424
Outputs = [new
DataContent
(outputItem.ImageResultBytes, $"image/{outputFormat}")]
1439
new
DataContent
(update.PartialImageBytes, $"image/{outputType}")
Microsoft.Extensions.AI.OpenAI.Tests (7)
OpenAIConversionTests.cs (1)
992
new
DataContent
(new byte[] { 1, 2, 3, 4 }, "application/octet-stream")
OpenAIResponseClientIntegrationTests.cs (1)
540
new
DataContent
(imageBytes, "image/png"),
OpenAIResponseClientTests.cs (5)
4310
new FunctionResultContent("call_789", new
DataContent
(imageData, "image/png"))
4546
new FunctionResultContent("call_pdf", new
DataContent
(pdfData, "application/pdf") { Name = "report.pdf" })
4939
new
DataContent
(imageData, "image/png"),
4940
new
DataContent
(imageData, "image/png") { AdditionalProperties = new AdditionalPropertiesDictionary { ["detail"] = ResponseImageDetailLevel.Low }},
4941
new
DataContent
(pdfData, "application/pdf") { Name = "doc.pdf" },
Microsoft.Extensions.AI.Tests (20)
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
362
new
DataContent
(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png"),
378
yield return new() { Contents = [new
DataContent
(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png")] };
398
new
DataContent
(Convert.FromBase64String("ZGF0YSBjb250ZW50"), "audio/mp3"),
Functions\AIFunctionFactoryTest.cs (15)
941
AIFunctionFactory.Create(() => new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")),
942
AIFunctionFactory.Create(async () => new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")),
943
AIFunctionFactory.Create(async ValueTask<DataContent> () => new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")),
948
AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
949
AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
950
AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
955
AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
956
AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
957
AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
962
AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
963
AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
964
AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
969
AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
970
AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
971
AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new
DataContent
(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Image\LoggingImageGeneratorTests.cs (1)
116
AIContent[] originalImages = [new
DataContent
((byte[])[1, 2, 3, 4], "image/png")];
Image\OpenTelemetryImageGeneratorTests.cs (1)
46
new
DataContent
(new byte[] { 1, 2, 3, 4 }, "image/png") { Name = "moreOutput.png" },
Microsoft.Extensions.DataIngestion (1)
Processors\ImageAlternativeTextEnricher.cs (1)
93
contents.Add(new
DataContent
(image.Content!.Value, image.MediaType!));
Microsoft.Extensions.DataIngestion.Tests (1)
IngestionPipelineTests.cs (1)
182
content:
new
(image.Content.GetValueOrDefault(), image.MediaType!),