73 instantiations of UriContent
Microsoft.Extensions.AI.Abstractions.Tests (40)
Contents\AIContentTests.cs (1)
70new UriContent("http://example.com", "application/json"),
Contents\ImageGenerationToolResultContentTests.cs (3)
54new UriContent("http://example.com/image.jpg", "image/jpeg"), 74new UriContent("http://example.com/image.jpg", "image/jpeg") 99new UriContent("http://example.com/another.jpg", "image/jpeg")
Contents\UriContentTests.cs (25)
15Assert.Throws<ArgumentNullException>("uri", () => new UriContent((string)null!, "image/png")); 16Assert.Throws<ArgumentNullException>("uri", () => new UriContent((Uri)null!, "image/png")); 17Assert.Throws<UriFormatException>(() => new UriContent("notauri", "image/png")); 19Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", "")); 20Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", "image")); 22Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), "")); 23Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), "audio")); 25UriContent c = new("http://localhost/something", "image/png"); 38Assert.Throws<ArgumentException>("mediaType", () => new UriContent("http://localhost/something", type)); 40UriContent c = new("http://localhost/something", "image/png"); 52var content = new UriContent("http://localhost/something", mediaType); 76var content = new UriContent(uri); 79var content2 = new UriContent(uri, null); 93var content = new UriContent(new Uri(uri)); 96var content2 = new UriContent(new Uri(uri), null); 112var content = new UriContent(new Uri(uri, UriKind.Relative)); 115var content2 = new UriContent(new Uri(uri, UriKind.Relative), null); 127var content = new UriContent(uri); 140var content = new UriContent(new Uri(uri, UriKind.Relative)); 147var content = new UriContent("http://localhost/image.png", "application/octet-stream"); 150var relContent = new UriContent(new Uri("image.png", UriKind.Relative), "application/octet-stream"); 160new UriContent("http://localhost/something", "image/png"), 191UriContent c = new("http://localhost", mediaType); 204var content = new UriContent("http://localhost", mediaType); 217var content = new UriContent("http://localhost", mediaType);
Contents\WebSearchToolResultContentTests.cs (7)
33new UriContent(new Uri("https://example.com/1"), "text/html") { AdditionalProperties = new() { ["title"] = "Result 1" } } 56new UriContent(new Uri("https://example.com/1"), "text/html") { AdditionalProperties = new() { ["title"] = "First" } }, 57new UriContent(new Uri("https://example.com/2"), "text/html") { AdditionalProperties = new() { ["title"] = "Second" } }, 58new UriContent(new Uri("https://example.com/3"), "text/html"), 82new UriContent(new Uri("https://example.com"), "text/html") { AdditionalProperties = new() { ["title"] = "Example Page" } }, 83new UriContent(new Uri("https://another.com"), "text/html"), 110new UriContent(new Uri("https://test.com"), "text/html") { AdditionalProperties = new() { ["title"] = "Test" } },
Image\ImageGenerationResponseTests.cs (4)
33content.Add(new UriContent(new Uri($"https://example.com/image-{i}.png"), "image/png")); 73new UriContent(new Uri("https://example.com/image1.png"), "image/png"), 99new UriContent(new Uri("https://example.com/image1.png"), "image/png"), 137new UriContent(new Uri("https://example.com/image.png"), "image/png"),
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
SafetyEvaluatorTests.cs (4)
340new UriContent("https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "image/png")], 425new UriContent("https://uhf.microsoft.com/images/banners/RW1iGSh.png", "image/png")], 461new UriContent("https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "image/png")], 474new UriContent("https://uhf.microsoft.com/images/banners/RW1iGSh.png", "image/png")],
Microsoft.Extensions.AI.OpenAI (5)
OpenAIChatClient.cs (1)
797contentPart.ImageUri is not null ? new UriContent(contentPart.ImageUri, OpenAIClientExtensions.ImageUriToMediaType(contentPart.ImageUri)) :
OpenAIImageGenerator.cs (1)
124contents.Add(new UriContent(image.ImageUri, contentType));
OpenAIResponsesChatClient.cs (3)
1719content = new UriContent(imageUri, OpenAIClientExtensions.ImageUriToMediaType(imageUri)); 1832(results ??= []).Add(new UriContent(uriSource.Uri, "text/html") 1885outputContents.Add(new UriContent(cicio.ImageUri, OpenAIClientExtensions.ImageUriToMediaType(cicio.ImageUri)) { RawRepresentation = cicio });
Microsoft.Extensions.AI.OpenAI.Tests (6)
OpenAIConversionTests.cs (1)
1522new UriContent("https://example.com/image.jpg", "image/jpeg"),
OpenAIResponseClientTests.cs (5)
5105new FunctionResultContent("call_uri", new UriContent(new Uri("https://example.com/image.png"), "image/png")) 5224new UriContent(new Uri("https://example.com/result.png"), "image/png"), 5451new FunctionResultContent("call_file_uri", new UriContent(new Uri("https://example.com/document.pdf"), "application/pdf")) 5677new UriContent(new Uri("https://example.com/image.png"), "image/png"), 5678new UriContent(new Uri("https://example.com/image.png"), "image/png") { AdditionalProperties = new AdditionalPropertiesDictionary { ["detail"] = "high" }},
Microsoft.Extensions.AI.Stabilization.Tests (10)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\ImageGenerationToolResultContentTests.cs (3)
54new UriContent("http://example.com/image.jpg", "image/jpeg"), 74new UriContent("http://example.com/image.jpg", "image/jpeg") 99new UriContent("http://example.com/another.jpg", "image/jpeg")
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\WebSearchToolResultContentTests.cs (7)
33new UriContent(new Uri("https://example.com/1"), "text/html") { AdditionalProperties = new() { ["title"] = "Result 1" } } 56new UriContent(new Uri("https://example.com/1"), "text/html") { AdditionalProperties = new() { ["title"] = "First" } }, 57new UriContent(new Uri("https://example.com/2"), "text/html") { AdditionalProperties = new() { ["title"] = "Second" } }, 58new UriContent(new Uri("https://example.com/3"), "text/html"), 82new UriContent(new Uri("https://example.com"), "text/html") { AdditionalProperties = new() { ["title"] = "Example Page" } }, 83new UriContent(new Uri("https://another.com"), "text/html"), 110new UriContent(new Uri("https://test.com"), "text/html") { AdditionalProperties = new() { ["title"] = "Test" } },
Microsoft.Extensions.AI.Tests (8)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
277var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new UriContent("https://example.com", "image/*")]));
ChatCompletion\OpenTelemetryChatClientTests.cs (5)
411new UriContent(new Uri("https://example.com/image.jpg"), "image/jpeg"), 427yield return new() { Contents = [new UriContent(new Uri("https://example.com/image.jpg"), "image/jpeg")] }; 447new UriContent(new Uri("https://example.com/video.mp4"), "video/mp4"), 664new ImageGenerationToolResultContent("img-123") { Outputs = [new UriContent(new Uri("https://example.com/image.png"), "image/png")] }, 686Outputs = [new UriContent(new Uri("https://example.com/image.png"), "image/png")]
Image\OpenTelemetryImageGeneratorTests.cs (2)
47new UriContent("http://example/output.png", "image/png"), 76OriginalImages = [new UriContent("http://example/input.png", "image/png")],
98 references to UriContent
Microsoft.Extensions.AI (2)
Common\OtelMessageSerializer.cs (1)
103case UriContent uc:
Realtime\OpenTelemetryRealtimeClientSession.cs (1)
567case UriContent uc:
Microsoft.Extensions.AI.Abstractions (8)
Contents\AIContent.cs (1)
19[JsonDerivedType(typeof(UriContent), typeDiscriminator: "uri")]
Contents\DataContent.cs (1)
33/// The content represents in-memory data. For references to data at a remote URI, use <see cref="UriContent"/> instead.
Contents\ImageGenerationToolResultContent.cs (1)
30/// Content is typically <see cref="DataContent"/> for images streamed from the tool, or <see cref="UriContent"/> for remotely hosted images, but
Contents\UriContent.cs (2)
31/// <summary>Initializes a new instance of the <see cref="UriContent"/> class.</summary> 46/// <summary>Initializes a new instance of the <see cref="UriContent"/> class.</summary>
Contents\WebSearchToolResultContent.cs (2)
14/// found during the search, typically as <see cref="UriContent"/> instances. 31/// Each output represents a web page result found during the search, typically as a <see cref="UriContent"/> instance.
Image\ImageGenerationResponse.cs (1)
41/// Content is typically <see cref="DataContent"/> for images streamed from the generator, or <see cref="UriContent"/> for remotely hosted images, but
Microsoft.Extensions.AI.Abstractions.Tests (45)
Contents\ImageGenerationToolResultContentTests.cs (6)
62Assert.IsType<UriContent>(c.Outputs[1]); 87Assert.IsType<UriContent>(deserializedSut.Outputs[1]); 88Assert.Equal("http://example.com/image.jpg", ((UriContent)deserializedSut.Outputs[1]).Uri.ToString()); 117Assert.IsType<UriContent>(imageResult.Outputs[1]); 147var uriOutput = Assert.IsType<UriContent>(imgResult.Outputs[0]);
Contents\UriContentTests.cs (18)
25UriContent c = new("http://localhost/something", "image/png"); 40UriContent c = new("http://localhost/something", "image/png"); 52var content = new UriContent("http://localhost/something", mediaType); 76var content = new UriContent(uri); 79var content2 = new UriContent(uri, null); 93var content = new UriContent(new Uri(uri)); 96var content2 = new UriContent(new Uri(uri), null); 112var content = new UriContent(new Uri(uri, UriKind.Relative)); 115var content2 = new UriContent(new Uri(uri, UriKind.Relative), null); 127var content = new UriContent(uri); 140var content = new UriContent(new Uri(uri, UriKind.Relative)); 147var content = new UriContent("http://localhost/image.png", "application/octet-stream"); 150var relContent = new UriContent(new Uri("image.png", UriKind.Relative), "application/octet-stream"); 191UriContent c = new("http://localhost", mediaType); 204var content = new UriContent("http://localhost", mediaType); 217var content = new UriContent("http://localhost", mediaType); 238var uriContent = Assert.IsType<UriContent>(result);
Contents\WebSearchToolResultContentTests.cs (14)
65var first = Assert.IsType<UriContent>(c.Outputs[0]); 68var second = Assert.IsType<UriContent>(c.Outputs[1]); 71var third = Assert.IsType<UriContent>(c.Outputs[2]); 95var first = Assert.IsType<UriContent>(deserialized.Outputs[0]); 99var second = Assert.IsType<UriContent>(deserialized.Outputs[1]); 122var first = Assert.IsType<UriContent>(result.Outputs[0]); 153var uriResult = Assert.IsType<UriContent>(wsResult.Outputs[0]);
Image\ImageGenerationResponseTests.cs (7)
48UriContent uc = Assert.IsType<UriContent>(response.Contents[i]); 112UriContent uriContent = Assert.IsType<UriContent>(deserialized.Contents[0]); 150Assert.IsType<UriContent>(deserialized.Contents[0]); 178var uriContent = Assert.IsType<UriContent>(result.Contents[0]);
Microsoft.Extensions.AI.Evaluation (1)
EvaluationContext.cs (1)
59/// <see cref="TextContent"/> objects for text, <see cref="DataContent"/> or <see cref="UriContent"/> objects for
Microsoft.Extensions.AI.Evaluation.Safety (4)
AIContentExtensions.cs (1)
14(content is UriContent uriContent && IsSupportedImageFormat(uriContent.MediaType)) ||
ContentSafetyServicePayloadUtilities.cs (3)
328else if (content is UriContent uriContent && uriContent.HasTopLevelMediaType("image")) 515$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}', '{nameof(UriContent)}' and '{nameof(DataContent)}'. " + 516$"For '{nameof(UriContent)}' and '{nameof(DataContent)}', only content with media type 'image/png', 'image/jpeg' and 'image/gif' are supported. " +
Microsoft.Extensions.AI.Integration.Tests (1)
ImageGeneratorIntegrationTests.cs (1)
49case UriContent uc:
Microsoft.Extensions.AI.OpenAI (5)
OpenAIChatClient.cs (1)
298case UriContent uriContent when uriContent.HasTopLevelMediaType("image"):
OpenAIResponsesChatClient.cs (4)
1354case UriContent uriContent when uriContent.HasTopLevelMediaType("image"): 1358case UriContent uriContent when uriContent.MediaType.StartsWith("application/pdf", StringComparison.OrdinalIgnoreCase): 1451case UriContent uc when uc.HasTopLevelMediaType("image"): 1459case UriContent uc:
Microsoft.Extensions.AI.OpenAI.Tests (12)
OpenAIConversionTests.cs (2)
909Assert.Equal("http://example.com/image.png", Assert.IsType<UriContent>(message.Contents[1], exactMatch: false).Uri.ToString()); 940Assert.Equal("http://example.com/image.png", Assert.IsType<UriContent>(message.Contents[1], exactMatch: false).Uri.ToString());
OpenAIResponseClientIntegrationTests.cs (2)
113var uriContent = Assert.IsType<UriContent>(r);
OpenAIResponseClientTests.cs (8)
6382var imageContent = userMessage.Contents.OfType<UriContent>().FirstOrDefault(); 7300var source0 = Assert.IsType<UriContent>(wsResult.Outputs[0]); 7305var source1 = Assert.IsType<UriContent>(wsResult.Outputs[1]); 7440var streamSource = Assert.IsType<UriContent>(wsResult.Outputs[0]);
Microsoft.Extensions.AI.Stabilization.Tests (20)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\ImageGenerationToolResultContentTests.cs (6)
62Assert.IsType<UriContent>(c.Outputs[1]); 87Assert.IsType<UriContent>(deserializedSut.Outputs[1]); 88Assert.Equal("http://example.com/image.jpg", ((UriContent)deserializedSut.Outputs[1]).Uri.ToString()); 117Assert.IsType<UriContent>(imageResult.Outputs[1]); 147var uriOutput = Assert.IsType<UriContent>(imgResult.Outputs[0]);
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\Contents\WebSearchToolResultContentTests.cs (14)
65var first = Assert.IsType<UriContent>(c.Outputs[0]); 68var second = Assert.IsType<UriContent>(c.Outputs[1]); 71var third = Assert.IsType<UriContent>(c.Outputs[2]); 95var first = Assert.IsType<UriContent>(deserialized.Outputs[0]); 99var second = Assert.IsType<UriContent>(deserialized.Outputs[1]); 122var first = Assert.IsType<UriContent>(result.Outputs[0]); 153var uriResult = Assert.IsType<UriContent>(wsResult.Outputs[0]);