144 references to DataContent
Microsoft.Extensions.AI.Abstractions (4)
ChatCompletion\ChatResponseExtensions.cs (1)
345return new DataContent(new ReadOnlyMemory<byte>(ms.GetBuffer(), 0, (int)ms.Length), first.MediaType) { Name = first.Name };
Contents\DataContent.cs (1)
195return new DataContent(new ReadOnlyMemory<byte>(memoryStream.GetBuffer(), 0, (int)memoryStream.Length), mediaType)
Files\HostedFileDownloadStream.cs (1)
107return new DataContent(
Image\ImageGeneratorExtensions.cs (1)
184var dataContent = new DataContent(originalImageData, mediaType) { Name = fileName };
Microsoft.Extensions.AI.Abstractions.Tests (74)
ChatCompletion\ChatMessageTests.cs (1)
263new DataContent(new BinaryData(new[] { 1, 2, 3 }, options: TestJsonSerializerContext.Default.Options), "mime-type/3")
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (7)
923var image1 = new DataContent((byte[])[1, 2, 3, 4], "image/png") { Name = "image1.png" }; 924var image2 = new DataContent((byte[])[5, 6, 7, 8], "image/jpeg") { Name = "image2.jpg" }; 925var image3 = new DataContent((byte[])[9, 10, 11, 12], "image/png") { Name = "image3.png" }; 926var image4 = new DataContent((byte[])[13, 14, 15, 16], "image/gif") { Name = "image4.gif" }; 981var image1 = new DataContent((byte[])[1, 2, 3, 4], "image/png") { Name = "image1.png" }; 982var image2 = new DataContent((byte[])[5, 6, 7, 8], "image/jpeg") { Name = "image2.jpg" }; 983var image3 = new DataContent((byte[])[9, 10, 11, 12], "image/png") { Name = "image3.png" };
ChatCompletion\ChatResponseUpdateTests.cs (2)
124new DataContent("data"u8.ToArray(), "text/plain"), 187new DataContent("data"u8.ToArray(), "text/plain"),
Contents\AIContentTests.cs (2)
69new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream"), 84new ImageGenerationToolResultContent("img456") { Outputs = [new DataContent(new byte[] { 4, 5, 6 }, "image/png")] },
Contents\CodeInterpreterToolCallContentTests.cs (1)
54new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
Contents\CodeInterpreterToolResultContentTests.cs (1)
54new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream"),
Contents\DataContentTests.cs (20)
87content = new DataContent(new byte[] { 0, 1, 2 }, mediaType); 153new DataContent(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream"), 159new DataContent(new ReadOnlyMemory<byte>([0x01, 0x02, 0x03, 0x04]), "application/octet-stream") { Name = "test.bin" }, 287var content = new DataContent(data, "application/octet-stream"); 306DataContent content = new(new byte[] { 1, 2, 3 }, "application/octet-stream"); 457DataContent content = new(testData, "application/octet-stream"); 484DataContent content = new(testData, "application/json"); 511DataContent content = new(testData, "application/json") 543DataContent content = new(testData, "application/json"); 572DataContent content = new(testData, "application/json"); 598DataContent content = new(testData, "application/json"); 628DataContent content = new(testData, "image/png") { Name = "myimage.png" }; 657DataContent content = new(testData, "text/plain") { Name = $"testfile_{Guid.NewGuid()}.txt" }; 702DataContent content = new(new byte[] { 1 }, "application/octet-stream"); 739DataContent content = new(testData, "text/css"); 796DataContent content = new(new byte[] { 1, 2, 3 }, "application/octet-stream"); 836DataContent content = new(testData, "application/json") 867DataContent content = new(testData, "application/json"); 925DataContent content = new(testData, "application/octet-stream"); 958DataContent content = new(newContent, "application/octet-stream");
Contents\ImageGenerationToolResultContentTests.cs (5)
31IList<AIContent> outputs = [new DataContent(new byte[] { 1, 2, 3 }, "image/png")]; 53new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 55new DataContent(new byte[] { 4, 5, 6 }, "image/gif") 73new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 98new DataContent(new byte[] { 7, 8, 9 }, "image/png"),
Contents\ToolApprovalRequestContentTests.cs (1)
26new CodeInterpreterToolCallContent("CI1") { Inputs = [new DataContent("print('hello')"u8.ToArray(), "text/x-python")] },
Contents\ToolApprovalResponseContentTests.cs (1)
26new CodeInterpreterToolCallContent("CI1") { Inputs = [new DataContent("print('hello')"u8.ToArray(), "text/x-python")] },
Files\HostedFileClientExtensionsTests.cs (2)
19var content = new DataContent(data, "application/pdf") { Name = "doc.pdf" }; 49var content = new DataContent(new byte[] { 1 }, "text/plain");
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"),
Image\ImageGeneratorExtensionsTests.cs (3)
64var dataContent = new DataContent(imageData, "image/png") { Name = "test.png" }; 92var dataContent = new DataContent(new byte[] { 1, 2, 3 }, "image/png"); 202var dataContent = new DataContent(imageData, "image/png");
Image\ImageGeneratorTests.cs (1)
139AIContent[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
Realtime\RealtimeClientMessageTests.cs (4)
76var audioContent = new DataContent(new byte[] { 1, 2, 3 }, "audio/pcm"); 85var audioContent = new DataContent(new byte[] { 1, 2, 3 }, "audio/pcm"); 88var newContent = new DataContent(new byte[] { 4, 5, 6 }, "audio/wav"); 97var audioContent = new DataContent(new byte[] { 1, 2, 3 }, "audio/pcm");
TextToSpeech\DelegatingTextToSpeechClientTests.cs (2)
61new([new DataContent(new byte[] { 1, 2 }, "audio/mpeg")]), 62new([new DataContent(new byte[] { 3, 4 }, "audio/mpeg")])
TextToSpeech\TextToSpeechClientTests.cs (4)
24return Task.FromResult(new TextToSpeechResponse([new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg")])); 68yield return new([new DataContent(new byte[] { 1 }, "audio/mpeg")]); 69yield return new([new DataContent(new byte[] { 2 }, "audio/mpeg")]); 70yield return new([new DataContent(new byte[] { 3 }, "audio/mpeg")]);
TextToSpeech\TextToSpeechResponseTests.cs (6)
41content.Add(new DataContent(new byte[] { (byte)i }, "audio/mpeg")); 84List<AIContent> newContents = [new DataContent(new byte[] { 1 }, "audio/mpeg"), new DataContent(new byte[] { 2 }, "audio/mpeg")]; 101new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg"), 142new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg"), 143new DataContent(new byte[] { 4, 5, 6 }, "audio/wav"),
TextToSpeech\TextToSpeechResponseUpdateExtensionsTests.cs (5)
26new([new DataContent(new byte[] { 1 }, "audio/mpeg")]) { ModelId = "model123", AdditionalProperties = new() { ["a"] = "b" } }, 27new([new DataContent(new byte[] { 2 }, "audio/mpeg")]) { ModelId = "model123" }, 28new([new DataContent(new byte[] { 3 }, "audio/mpeg")]) { ModelId = "model123", AdditionalProperties = new() { ["c"] = "d" } }, 57new() { Contents = [new DataContent(new byte[] { 1 }, "audio/mpeg")] }, 59new() { Contents = [new DataContent(new byte[] { 2 }, "audio/mpeg")] },
TextToSpeech\TextToSpeechResponseUpdateTests.cs (2)
33List<AIContent> newList = [new DataContent(new byte[] { 1 }, "audio/mpeg")]; 53new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg"),
Tools\HostedCodeInterpreterToolTests.cs (1)
48new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
ScenarioRunResultTests.cs (1)
238new DataContent(new byte[] { 0x89, 0x50, 0x4E, 0x47 }, "image/png"),
Microsoft.Extensions.AI.Integration.Tests (4)
ImageGeneratingChatClientIntegrationTests.cs (3)
158var originalImageData = new DataContent(testImageData, "image/png") { Name = "original.png" }; 374var originalImage = new DataContent(testImageData, "image/png") { Name = "test.png" }; 421var imageContent = new DataContent(imageData, TestImageMediaType)
ImageGeneratorIntegrationTests.cs (1)
95AIContent[] originalImages = [new DataContent(imageData, "image/png") { Name = "dotnet.png" }];
Microsoft.Extensions.AI.OpenAI (14)
OpenAIAssistantsChatClient.cs (1)
207Inputs = [new DataContent(Encoding.UTF8.GetBytes(details.CodeInterpreterInput), OpenAIClientExtensions.PythonMediaType)],
OpenAIChatClient.cs (4)
402responseUpdate.Contents.Add(new DataContent(audioUpdate.AudioBytesUpdate.ToMemory(), GetOutputAudioMimeType(options)) 529returnMessage.Contents.Add(new DataContent(audio.AudioBytes.ToMemory(), GetOutputAudioMimeType(chatCompletionOptions)) 795contentPart.ImageBytes is not null ? new DataContent(contentPart.ImageBytes.ToMemory(), contentPart.ImageBytesMediaType) : 809contentPart.FileBytes is not null ? new DataContent(contentPart.FileBytes.ToMemory(), contentPart.FileBytesMediaType) { Name = contentPart.Filename } :
OpenAIFileDownloadStream.cs (1)
49return Task.FromResult(new DataContent(_data.ToMemory(), MediaType ?? "application/octet-stream")
OpenAIImageGenerator.cs (1)
120contents.Add(new DataContent(image.ImageBytes.ToMemory(), contentType));
OpenAIResponsesChatClient.cs (5)
258Inputs = !string.IsNullOrWhiteSpace(cicri.Code) ? [new DataContent(Encoding.UTF8.GetBytes(cicri.Code), OpenAIClientExtensions.PythonMediaType)] : null, 501Inputs = [new DataContent(Encoding.UTF8.GetBytes(codeInterpreterDeltaUpdate.Delta), OpenAIClientExtensions.PythonMediaType)], 1706content = new DataContent(part.InputFileBytes, part.InputFileBytesMediaType ?? "application/octet-stream") { Name = part.InputFilename }; 1975Outputs = [new DataContent(outputItem.ImageResultBytes, $"image/{outputFormat}")] 1989new DataContent(update.PartialImageBytes, $"image/{outputType}")
OpenAITextToSpeechClient.cs (2)
72return new TextToSpeechResponse([new DataContent(result.Value.ToMemory(), mediaType)]) 121Contents = [new DataContent(deltaUpdate.AudioBytes.ToMemory(), mediaType)],
Microsoft.Extensions.AI.OpenAI.Tests (9)
OpenAIConversionTests.cs (2)
442new Uri(new DataContent((byte[])[0x89, 0x50, 0x4E, 0x47], "image/png").Uri)); 1523new DataContent(new byte[] { 1, 2, 3, 4 }, "application/octet-stream")
OpenAIHostedFileClientIntegrationTests.cs (1)
178var dataContent = new DataContent(contentBytes, "text/plain") { Name = fileName };
OpenAIResponseClientIntegrationTests.cs (1)
666new DataContent(imageBytes, "image/png"),
OpenAIResponseClientTests.cs (5)
4942new FunctionResultContent("call_789", new DataContent(imageData, "image/png")) 5178new FunctionResultContent("call_pdf", new DataContent(pdfData, "application/pdf") { Name = "report.pdf" }) 5573new DataContent(imageData, "image/png"), 5574new DataContent(imageData, "image/png") { AdditionalProperties = new AdditionalPropertiesDictionary { ["detail"] = ResponseImageDetailLevel.Low }}, 5575new DataContent(pdfData, "application/pdf") { Name = "doc.pdf" },
Microsoft.Extensions.AI.Stabilization.Tests (8)
parent\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolCallContentTests.cs (1)
54new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
parent\Microsoft.Extensions.AI.Abstractions.Tests\Contents\CodeInterpreterToolResultContentTests.cs (1)
54new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream"),
parent\Microsoft.Extensions.AI.Abstractions.Tests\Contents\ImageGenerationToolResultContentTests.cs (5)
31IList<AIContent> outputs = [new DataContent(new byte[] { 1, 2, 3 }, "image/png")]; 53new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 55new DataContent(new byte[] { 4, 5, 6 }, "image/gif") 73new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 98new DataContent(new byte[] { 7, 8, 9 }, "image/png"),
parent\Microsoft.Extensions.AI.Abstractions.Tests\Tools\HostedCodeInterpreterToolTests.cs (1)
48new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
Microsoft.Extensions.AI.Tests (28)
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
410new DataContent(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png"), 426yield return new() { Contents = [new DataContent(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png")] }; 446new DataContent(Convert.FromBase64String("ZGF0YSBjb250ZW50"), "audio/mp3"),
Functions\AIFunctionFactoryTest.cs (15)
1172AIFunctionFactory.Create(() => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1173AIFunctionFactory.Create(async () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1174AIFunctionFactory.Create(async ValueTask<DataContent> () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1179AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1180AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1181AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1186AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1187AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1188AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1193AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1194AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1195AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1200AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1201AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1202AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Image\LoggingImageGeneratorTests.cs (1)
116AIContent[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
Image\OpenTelemetryImageGeneratorTests.cs (1)
48new DataContent(new byte[] { 1, 2, 3, 4 }, "image/png") { Name = "moreOutput.png" },
Realtime\OpenTelemetryRealtimeClientTests.cs (2)
580yield return new InputAudioBufferAppendRealtimeClientMessage(new DataContent(new byte[] { 1, 2, 3 }, "audio/pcm")); 1020var imageData = new DataContent(new byte[] { 0x89, 0x50, 0x4E, 0x47 }, "image/png");
TextToSpeech\LoggingTextToSpeechClientTests.cs (3)
59return Task.FromResult(new TextToSpeechResponse([new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg")])); 110yield return new([new DataContent(new byte[] { 1 }, "audio/mpeg")]); 111yield return new([new DataContent(new byte[] { 2 }, "audio/mpeg")]);
TextToSpeech\OpenTelemetryTextToSpeechClientTests.cs (3)
44return new([new DataContent(new byte[] { 1, 2, 3 }, "audio/mpeg")]) 66yield return new([new DataContent(new byte[] { 1 }, "audio/mpeg")]); 71new DataContent(new byte[] { 2 }, "audio/mpeg"),
Microsoft.Extensions.DataIngestion (1)
Processors\ImageAlternativeTextEnricher.cs (1)
93contents.Add(new DataContent(image.Content!.Value, image.MediaType!));
Microsoft.Extensions.DataIngestion.Tests (1)
IngestionPipelineTests.cs (1)
182content: new(image.Content.GetValueOrDefault(), image.MediaType!),