2 writes to MediaType
Microsoft.Extensions.AI.Abstractions (2)
Contents\DataContent.cs (2)
98MediaType = DataUriParser.ThrowIfInvalidMediaType(mediaType); 121MediaType = DataUriParser.ThrowIfInvalidMediaType(mediaType);
34 references to MediaType
Microsoft.Extensions.AI.Abstractions (7)
Contents\DataContent.cs (7)
127/// Determines whether the <see cref="MediaType"/>'s top-level type matches the specified <paramref name="topLevelType"/>. 129/// <param name="topLevelType">The type to compare against <see cref="MediaType"/>.</param> 130/// <returns><see langword="true"/> if the type portion of <see cref="MediaType"/> matches the specified value; otherwise, false.</returns> 135/// the specified <paramref name="topLevelType"/> against the type portion of <see cref="MediaType"/>. 137public bool HasTopLevelMediaType(string topLevelType) => DataUriParser.HasTopLevelMediaType(MediaType, topLevelType); 156"data:".Length + MediaType.Length + ";base64,".Length + Base64.GetMaxEncodedToUtf8Length(data.Length)); 158bool wrote = array.AsSpan().TryWrite($"data:{MediaType};base64,", out int prefixLength);
Microsoft.Extensions.AI.Abstractions.Tests (15)
ChatCompletion\ChatMessageTests.cs (2)
290Assert.Equal("mime-type/2", dataContent.MediaType); 298Assert.Equal("mime-type/3", dataContent.MediaType);
Contents\DataContentTests.cs (12)
69Assert.Equal(mediaType, content.MediaType); 73Assert.Equal(mediaType, content.MediaType); 77Assert.Equal(mediaType, content.MediaType); 81Assert.Equal(mediaType, content.MediaType); 85Assert.Equal(mediaType, content.MediaType); 89Assert.Equal(mediaType, content.MediaType); 100Assert.Equal("image/png", content.MediaType); 105Assert.Equal("image/png", content.MediaType); 141Assert.Equal("application/octet-stream", content.MediaType); 147Assert.Equal("application/octet-stream", content.MediaType); 164Assert.Equal("audio/wav", content.MediaType); 210Assert.Equal(mediaType, c.MediaType);
SpeechToText\SpeechToTextResponseTests.cs (1)
237Assert.Equal("image/png", Assert.IsType<DataContent>(update.Contents[1]).MediaType);
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
527parts.Add(new ChatMessageImageContentItem(BinaryData.FromBytes(dataContent.Data), dataContent.MediaType)); 536if (dataContent.MediaType.Equals("audio/mpeg", StringComparison.OrdinalIgnoreCase)) 540else if (dataContent.MediaType.Equals("audio/wav", StringComparison.OrdinalIgnoreCase))
Microsoft.Extensions.AI.Evaluation.Safety (1)
AIContentExtensions.cs (1)
15(content is DataContent dataContent && IsSupportedImageFormat(dataContent.MediaType));
Microsoft.Extensions.AI.OpenAI (8)
OpenAIChatClient.cs (5)
251return ChatMessageContentPart.CreateImagePart(BinaryData.FromBytes(dataContent.Data), dataContent.MediaType, GetImageDetail(content)); 255if (dataContent.MediaType.Equals("audio/mpeg", StringComparison.OrdinalIgnoreCase)) 259else if (dataContent.MediaType.Equals("audio/wav", StringComparison.OrdinalIgnoreCase)) 266case DataContent dataContent when dataContent.MediaType.StartsWith("application/pdf", StringComparison.OrdinalIgnoreCase): 267return ChatMessageContentPart.CreateFilePart(BinaryData.FromBytes(dataContent.Data), dataContent.MediaType, $"{Guid.NewGuid():N}.pdf");
OpenAIResponseChatClient.cs (3)
638parts.Add(ResponseContentPart.CreateInputImagePart(BinaryData.FromBytes(dataContent.Data), dataContent.MediaType)); 641case DataContent dataContent when dataContent.MediaType.StartsWith("application/pdf", StringComparison.OrdinalIgnoreCase): 642parts.Add(ResponseContentPart.CreateInputFilePart(BinaryData.FromBytes(dataContent.Data), dataContent.MediaType, $"{Guid.NewGuid():N}.pdf"));