30 instantiations of UriContent
Microsoft.Extensions.AI.Abstractions.Tests (21)
Contents\UriContentTests.cs (17)
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<ArgumentNullException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", null!)); 20Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", "")); 21Assert.Throws<ArgumentException>("mediaType", () => new UriContent("data:image/png;base64,aGVsbG8=", "image")); 23Assert.Throws<ArgumentNullException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), null!)); 24Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), "")); 25Assert.Throws<ArgumentException>("mediaType", () => new UriContent(new Uri("data:image/png;base64,aGVsbG8="), "audio")); 27UriContent c = new("http://localhost/something", "image/png"); 40Assert.Throws<ArgumentException>("mediaType", () => new UriContent("http://localhost/something", type)); 42UriContent c = new("http://localhost/something", "image/png"); 54var content = new UriContent("http://localhost/something", mediaType); 70new UriContent("http://localhost/something", "image/png"), 101UriContent c = new("http://localhost", mediaType); 114var content = new UriContent("http://localhost", mediaType); 127var content = new UriContent("http://localhost", mediaType);
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.AzureAIInference.Tests (1)
AzureAIInferenceChatClientTests.cs (1)
1070new UriContent("http://dot.net/someimage.png", mediaType: "image/*"),
Microsoft.Extensions.AI.Evaluation.Integration.Tests (4)
SafetyEvaluatorTests.cs (4)
338new UriContent("https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "image/png")], 423new UriContent("https://uhf.microsoft.com/images/banners/RW1iGSh.png", "image/png")], 459new UriContent("https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png", "image/png")], 472new UriContent("https://uhf.microsoft.com/images/banners/RW1iGSh.png", "image/png")],
Microsoft.Extensions.AI.OpenAI (2)
OpenAIChatClient.cs (1)
688contentPart.ImageUri is not null ? new UriContent(contentPart.ImageUri, "image/*") :
OpenAIImageGenerator.cs (1)
167contents.Add(new UriContent(image.ImageUri, contentType));
Microsoft.Extensions.AI.OpenAI.Tests (1)
OpenAIConversionTests.cs (1)
400new UriContent("https://example.com/image.jpg", "image/jpeg"),
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\ChatClientStructuredOutputExtensionsTests.cs (1)
283var expectedResponse = new ChatResponse(new ChatMessage(ChatRole.Assistant, [new UriContent("https://example.com", "image/*")]));
27 references to UriContent
Microsoft.Extensions.AI.Abstractions (4)
Contents\AIContent.cs (1)
19[JsonDerivedType(typeof(UriContent), typeDiscriminator: "uri")]
Contents\DataContent.cs (1)
30/// The content represents in-memory data. For references to data at a remote URI, use <see cref="UriContent"/> instead.
Contents\UriContent.cs (2)
27/// <summary>Initializes a new instance of the <see cref="UriContent"/> class.</summary> 44/// <summary>Initializes a new instance of the <see cref="UriContent"/> class.</summary>
Microsoft.Extensions.AI.Abstractions.Tests (11)
Contents\UriContentTests.cs (6)
27UriContent c = new("http://localhost/something", "image/png"); 42UriContent c = new("http://localhost/something", "image/png"); 54var content = new UriContent("http://localhost/something", mediaType); 101UriContent c = new("http://localhost", mediaType); 114var content = new UriContent("http://localhost", mediaType); 127var content = new UriContent("http://localhost", mediaType);
Image\ImageGenerationResponseTests.cs (5)
48UriContent uc = Assert.IsType<UriContent>(response.Contents[i]); 112UriContent uriContent = Assert.IsType<UriContent>(deserialized.Contents[0]); 150Assert.IsType<UriContent>(deserialized.Contents[0]);
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceChatClient.cs (2)
523case UriContent uriContent when uriContent.HasTopLevelMediaType("image"): 531case UriContent uriContent when uriContent.HasTopLevelMediaType("audio"):
Microsoft.Extensions.AI.Evaluation (1)
EvaluationContext.cs (1)
66/// <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)
332else if (content is UriContent uriContent && uriContent.HasTopLevelMediaType("image")) 519$"The current evaluation being performed by {evaluatorName} only supports content of type '{nameof(TextContent)}', '{nameof(UriContent)}' and '{nameof(DataContent)}'. " + 520$"For '{nameof(UriContent)}' and '{nameof(DataContent)}', only content with media type 'image/png', 'image/jpeg' and 'image/gif' are supported. " +
Microsoft.Extensions.AI.OpenAI (3)
OpenAIAssistantsChatClient.cs (1)
501case UriContent image when image.HasTopLevelMediaType("image"):
OpenAIChatClient.cs (1)
263case UriContent uriContent when uriContent.HasTopLevelMediaType("image"):
OpenAIResponsesChatClient.cs (1)
706case UriContent uriContent when uriContent.HasTopLevelMediaType("image"):
Microsoft.Extensions.AI.OpenAI.Tests (2)
OpenAIConversionTests.cs (2)
233Assert.Equal("http://example.com/image.png", Assert.IsType<UriContent>(message.Contents[1], exactMatch: false).Uri.ToString()); 264Assert.Equal("http://example.com/image.png", Assert.IsType<UriContent>(message.Contents[1], exactMatch: false).Uri.ToString());