94 references to DataContent
Microsoft.Extensions.AI.Abstractions (3)
ChatCompletion\ChatResponseExtensions.cs (1)
290return 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)
Image\ImageGeneratorExtensions.cs (1)
184var dataContent = new DataContent(originalImageData, mediaType) { Name = fileName };
Microsoft.Extensions.AI.Abstractions.Tests (46)
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 (1)
124new DataContent("data"u8.ToArray(), "text/plain"),
Contents\AIContentTests.cs (2)
65new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream"), 80new ImageGenerationToolResultContent { ImageId = "img456", Outputs = [new DataContent(new byte[] { 4, 5, 6 }, "image/png")] }
Contents\CodeInterpreterToolCallContentTests.cs (1)
57new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
Contents\CodeInterpreterToolResultContentTests.cs (1)
57new 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"); 626DataContent content = new(testData, "image/png") { Name = "myimage.png" }; 655DataContent content = new(testData, "text/plain") { Name = $"testfile_{Guid.NewGuid()}.txt" }; 698DataContent content = new(new byte[] { 1 }, "application/octet-stream"); 735DataContent content = new(testData, "text/css"); 792DataContent content = new(new byte[] { 1, 2, 3 }, "application/octet-stream"); 832DataContent content = new(testData, "application/json") 863DataContent content = new(testData, "application/json"); 921DataContent content = new(testData, "application/octet-stream"); 954DataContent content = new(newContent, "application/octet-stream");
Contents\ImageGenerationToolResultContentTests.cs (5)
32IList<AIContent> outputs = [new DataContent(new byte[] { 1, 2, 3 }, "image/png")]; 55new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 57new DataContent(new byte[] { 4, 5, 6 }, "image/gif") 76new DataContent(new byte[] { 1, 2, 3 }, "image/png"), 102new DataContent(new byte[] { 7, 8, 9 }, "image/png"),
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")];
Tools\HostedCodeInterpreterToolTests.cs (1)
48new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")
Microsoft.Extensions.AI.Integration.Tests (5)
ImageGeneratingChatClientIntegrationTests.cs (3)
159var originalImageData = new DataContent(testImageData, "image/png") { Name = "original.png" }; 375var originalImage = new DataContent(testImageData, "image/png") { Name = "test.png" }; 422var imageContent = new DataContent(imageData, TestImageMediaType)
ImageGeneratorIntegrationTests.cs (1)
96AIContent[] originalImages = [new DataContent(imageData, "image/png") { Name = "dotnet.png" }];
ToolReductionTests.cs (1)
311new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream"),
Microsoft.Extensions.AI.OpenAI (11)
OpenAIAssistantsChatClient.cs (1)
208Inputs = [new DataContent(Encoding.UTF8.GetBytes(details.CodeInterpreterInput), OpenAIClientExtensions.PythonMediaType)],
OpenAIChatClient.cs (4)
379responseUpdate.Contents.Add(new DataContent(audioUpdate.AudioBytesUpdate.ToMemory(), GetOutputAudioMimeType(options)) 499returnMessage.Contents.Add(new DataContent(audio.AudioBytes.ToMemory(), GetOutputAudioMimeType(chatCompletionOptions)) 751contentPart.ImageBytes is not null ? new DataContent(contentPart.ImageBytes.ToMemory(), contentPart.ImageBytesMediaType) : 765contentPart.FileBytes is not null ? new DataContent(contentPart.FileBytes.ToMemory(), contentPart.FileBytesMediaType) { Name = contentPart.Filename } :
OpenAIImageGenerator.cs (1)
134contents.Add(new DataContent(image.ImageBytes.ToMemory(), contentType));
OpenAIResponsesChatClient.cs (5)
231Inputs = !string.IsNullOrWhiteSpace(cicri.Code) ? [new DataContent(Encoding.UTF8.GetBytes(cicri.Code), OpenAIClientExtensions.PythonMediaType)] : null, 430Inputs = [new DataContent(Encoding.UTF8.GetBytes(codeInterpreterDeltaUpdate.Delta), OpenAIClientExtensions.PythonMediaType)], 1278content = new DataContent(part.InputFileBytes, part.InputFileBytesMediaType ?? "application/octet-stream") { Name = part.InputFilename }; 1424Outputs = [new DataContent(outputItem.ImageResultBytes, $"image/{outputFormat}")] 1439new DataContent(update.PartialImageBytes, $"image/{outputType}")
Microsoft.Extensions.AI.OpenAI.Tests (7)
OpenAIConversionTests.cs (1)
992new DataContent(new byte[] { 1, 2, 3, 4 }, "application/octet-stream")
OpenAIResponseClientIntegrationTests.cs (1)
540new DataContent(imageBytes, "image/png"),
OpenAIResponseClientTests.cs (5)
4310new FunctionResultContent("call_789", new DataContent(imageData, "image/png")) 4546new FunctionResultContent("call_pdf", new DataContent(pdfData, "application/pdf") { Name = "report.pdf" }) 4939new DataContent(imageData, "image/png"), 4940new DataContent(imageData, "image/png") { AdditionalProperties = new AdditionalPropertiesDictionary { ["detail"] = ResponseImageDetailLevel.Low }}, 4941new DataContent(pdfData, "application/pdf") { Name = "doc.pdf" },
Microsoft.Extensions.AI.Tests (20)
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
362new DataContent(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png"), 378yield return new() { Contents = [new DataContent(Convert.FromBase64String("aGVsbG8gd29ybGQ="), "image/png")] }; 398new DataContent(Convert.FromBase64String("ZGF0YSBjb250ZW50"), "audio/mp3"),
Functions\AIFunctionFactoryTest.cs (15)
941AIFunctionFactory.Create(() => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 942AIFunctionFactory.Create(async () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 943AIFunctionFactory.Create(async ValueTask<DataContent> () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 948AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 949AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 950AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 955AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 956AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 957AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 962AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 963AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 964AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 969AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 970AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 971AIFunctionFactory.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)
46new DataContent(new byte[] { 1, 2, 3, 4 }, "image/png") { Name = "moreOutput.png" },
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!),