17 types derived from AIContent
Microsoft.Extensions.AI.Abstractions (14)
Contents\DataContent.cs (1)
38public class DataContent : AIContent
Contents\ErrorContent.cs (1)
15public class ErrorContent : AIContent
Contents\FunctionCallContent.cs (1)
17public sealed class FunctionCallContent : AIContent
Contents\FunctionResultContent.cs (1)
16public sealed class FunctionResultContent : AIContent
Contents\HostedFileContent.cs (1)
18public sealed class HostedFileContent : AIContent
Contents\HostedVectorStoreContent.cs (1)
19public sealed class HostedVectorStoreContent : AIContent
Contents\McpServerToolCallContent.cs (1)
19public sealed class McpServerToolCallContent : AIContent
Contents\McpServerToolResultContent.cs (1)
19public sealed class McpServerToolResultContent : AIContent
Contents\TextContent.cs (1)
13public sealed class TextContent : AIContent
Contents\TextReasoningContent.cs (1)
18public sealed class TextReasoningContent : AIContent
Contents\UriContent.cs (1)
19public class UriContent : AIContent
Contents\UsageContent.cs (1)
14public class UsageContent : AIContent
Contents\UserInputRequestContent.cs (1)
14public class UserInputRequestContent : AIContent
Contents\UserInputResponseContent.cs (1)
14public class UserInputResponseContent : AIContent
Microsoft.Extensions.AI.Abstractions.Tests (1)
Utilities\AIJsonUtilitiesTests.cs (1)
1354private class DerivedAIContent : AIContent
Microsoft.Extensions.AI.Tests (2)
ChatCompletion\DistributedCachingChatClientTest.cs (2)
887public class CustomAIContent1(string text, DateTime date) : AIContent 893public class CustomAIContent2(string text, int number) : AIContent
7 instantiations of AIContent
Microsoft.Extensions.AI.Abstractions.Tests (3)
Contents\AIContentTests.cs (3)
14AIContent c = new(); 22AIContent c = new(); 38AIContent original = new()
Microsoft.Extensions.AI.OpenAI (4)
OpenAIResponsesChatClient.cs (4)
186message.Contents.Add(new() { RawRepresentation = outputItem }); 287yield return CreateUpdate(new AIContent { RawRepresentation = mtdli }); 305AIContent annotatedContent = new(); 757results.Add(new() { RawRepresentation = part });
218 references to AIContent
Microsoft.Extensions.AI (12)
ChatCompletion\FunctionInvokingChatClient.cs (11)
517IList<AIContent> contents = update.Contents; 775IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 1066var contents = new List<AIContent>(results.Length); 1218List<AIContent>? rejectedFunctionCallResults = GenerateRejectedFunctionResults(notInvokedResponses.rejections); 1275List<AIContent>? keptContents = null; 1280var content = message.Contents[j]; 1372/// <returns>The <see cref="AIContent"/> for the rejected function calls.</returns> 1373private static List<AIContent>? GenerateRejectedFunctionResults(List<ApprovalResultWithRequestMessage>? rejections) => 1375rejections.ConvertAll(static m => (AIContent)new FunctionResultContent(m.Response.FunctionCall.CallId, "Error: Tool call invocation was rejected by user.")) : 1492private static bool TryReplaceFunctionCallsWithApprovalRequests(IList<AIContent> content, out List<AIContent>? updatedContent)
ChatCompletion\OpenTelemetryChatClient.cs (1)
243foreach (AIContent content in message.Contents)
Microsoft.Extensions.AI.Abstractions (65)
ChatCompletion\ChatMessage.cs (5)
19private IList<AIContent>? _contents; 40public ChatMessage(ChatRole role, IList<AIContent>? contents) 86public IList<AIContent> Contents 110/// <summary>Gets a <see cref="AIContent"/> object to display in the debugger display.</summary> 112private AIContent? ContentForDebuggerDisplay
ChatCompletion\ChatResponseExtensions.cs (16)
55/// contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 74/// <param name="filter">A predicate to filter which <see cref="AIContent"/> gets included in the message.</param> 81public static void AddMessages(this IList<ChatMessage> list, ChatResponseUpdate update, Func<AIContent, bool>? filter = null) 109/// contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 132/// message boundaries, as well as coalescing contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 160/// message boundaries, as well as coalescing contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 186/// <summary>Coalesces sequential <see cref="AIContent"/> content elements.</summary> 187internal static void CoalesceTextContent(IList<AIContent> contents) 201static string MergeText(IList<AIContent> contents, int start, int end) 212static void Coalesce<TContent>(IList<AIContent> contents, bool mergeSingle, Func<IList<AIContent>, int, int, TContent> merge) 213where TContent : AIContent 250static bool TryAsCoalescable(AIContent content, [NotNullWhen(true)] out TContent? coalescable) 264if (contents is List<AIContent> contentsList) 296CoalesceTextContent((List<AIContent>)response.Messages[i].Contents); 363foreach (var content in update.Contents)
ChatCompletion\ChatResponseUpdate.cs (5)
38private IList<AIContent>? _contents; 60public ChatResponseUpdate(ChatRole? role, IList<AIContent>? contents) 85public IList<AIContent> Contents 144/// <summary>Gets a <see cref="AIContent"/> object to display in the debugger display.</summary> 146private AIContent? ContentForDebuggerDisplay
Contents\AIAnnotation.cs (1)
23/// <summary>Gets or sets any target regions for the annotation, pointing to where in the associated <see cref="AIContent"/> this annotation applies.</summary>
Contents\AIContent.cs (2)
35/// Initializes a new instance of the <see cref="AIContent"/> class. 48/// If an <see cref="AIContent"/> is created to represent some underlying object from another object
Contents\AIContentExtensions.cs (3)
15/// <summary>Internal extensions for working with <see cref="AIContent"/>.</summary> 19public static string ConcatText(this IEnumerable<AIContent> contents) 21if (contents is IList<AIContent> list)
Contents\AnnotatedRegion.cs (1)
8/// <summary>Describes the portion of an associated <see cref="AIContent"/> to which an annotation applies.</summary>
Contents\McpServerToolResultContent.cs (1)
40public IList<AIContent>? Output { get; set; }
Contents\TextSpanAnnotatedRegion.cs (3)
9/// <summary>Describes a location in the associated <see cref="AIContent"/> based on starting and ending character indices.</summary> 22/// Gets or sets the start character index (inclusive) of the annotated span in the <see cref="AIContent"/>. 28/// Gets or sets the end character index (exclusive) of the annotated span in the <see cref="AIContent"/>.
Image\ImageGenerationRequest.cs (2)
28public ImageGenerationRequest(string prompt, IEnumerable<AIContent>? originalImages) 44public IEnumerable<AIContent>? OriginalImages { get; set; }
Image\ImageGenerationResponse.cs (3)
17private IList<AIContent>? _contents; 27public ImageGenerationResponse(IList<AIContent>? contents) 49public IList<AIContent> Contents
Image\ImageGeneratorExtensions.cs (1)
131IEnumerable<AIContent> originalImages,
SpeechToText\SpeechToTextResponse.cs (4)
19private IList<AIContent>? _contents; 29public SpeechToTextResponse(IList<AIContent> contents) 79IList<AIContent> contents = Contents; 102public IList<AIContent> Contents
SpeechToText\SpeechToTextResponseUpdate.cs (3)
36private IList<AIContent>? _contents; 46public SpeechToTextResponseUpdate(IList<AIContent> contents) 94public IList<AIContent> Contents
SpeechToText\SpeechToTextResponseUpdateExtensions.cs (3)
35ChatResponseExtensions.CoalesceTextContent((List<AIContent>)response.Contents); 61ChatResponseExtensions.CoalesceTextContent((List<AIContent>)response.Contents); 96foreach (var content in update.Contents)
Tools\HostedCodeInterpreterTool.cs (2)
20/// <summary>Gets or sets a collection of <see cref="AIContent"/> to be used as input to the code interpreter tool.</summary> 26public IList<AIContent>? Inputs { get; set; }
Tools\HostedFileSearchTool.cs (2)
20/// <summary>Gets or sets a collection of <see cref="AIContent"/> to be used as input to the file search tool.</summary> 27public IList<AIContent>? Inputs { get; set; }
Utilities\AIJsonUtilities.cs (7)
28/// Adds a custom content type to the polymorphic configuration for <see cref="AIContent"/>. 37where TContent : AIContent 46/// Adds a custom content type to the polymorphic configuration for <see cref="AIContent"/>. 52/// <exception cref="ArgumentException"><paramref name="contentType"/> is a built-in content type or does not derived from <see cref="AIContent"/>.</exception> 60if (!typeof(AIContent).IsAssignableFrom(contentType)) 194if (contentType.Assembly == typeof(AIContent).Assembly) 202if (typeInfo.Type == typeof(AIContent))
Utilities\AIJsonUtilities.Defaults.cs (1)
117[JsonSerializable(typeof(AIContent))]
Microsoft.Extensions.AI.Abstractions.Tests (34)
AssertExtensions.cs (2)
33var expectedItem = expectedMessage.Contents[j]; 34var chatItem = chatMessage.Contents[j];
ChatCompletion\ChatMessageTests.cs (6)
73message = new(ChatRole.User, (IList<AIContent>?)null); 77message = new ChatMessage(ChatRole.User, Array.Empty<AIContent>()); 88List<AIContent> content = []; 171Assert.IsType<List<AIContent>>(new ChatMessage().Contents); 180List<AIContent> contents = []; 254IList<AIContent> items =
ChatCompletion\ChatResponseUpdateTests.cs (1)
48IList<AIContent> newList = [new TextContent("text")];
Contents\AIContentTests.cs (7)
14AIContent c = new(); 22AIContent c = new(); 38AIContent original = new() 47string json = JsonSerializer.Serialize(original, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(AIContent))); 50AIContent? deserialized = (AIContent?)JsonSerializer.Deserialize(json, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(AIContent)));
Contents\McpServerToolResultContentTests.cs (1)
40IList<AIContent> output = [];
Image\ImageGenerationResponseTests.cs (4)
30List<AIContent> content = []; 72List<AIContent> contents = [ 98List<AIContent> contents = [ 136List<AIContent> contents = [
Image\ImageGeneratorTests.cs (1)
140AIContent[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
SpeechToText\SpeechToTextResponseTests.cs (4)
17Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!)); 64Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!)); 73List<AIContent> content = []; 133List<AIContent> newContents = [new TextContent("text1"), new TextContent("text2")];
SpeechToText\SpeechToTextResponseUpdateTests.cs (2)
41List<AIContent> newList = new(); 92Contents = new List<AIContent>
Utilities\AIJsonUtilitiesTests.cs (6)
473JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options); 986AIContent c = new DerivedAIContent { DerivedValue = 42 }; 990AIContent? deserialized = JsonSerializer.Deserialize<AIContent>(json, options); 1013Assert.Throws<ArgumentException>(() => options.AddAIContentType<AIContent>("discriminator")); 1024AIContent c = new DerivedAIContent();
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
448foreach (AIContent item in input.Contents) 492foreach (var content in input.Contents) 509/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentItem"/>.</summary> 510private static List<ChatMessageContentItem> GetContentParts(IList<AIContent> contents) 515foreach (var content in contents)
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (2)
145[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 218[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] :
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (2)
33var expectedItem = expectedMessage.Contents[j]; 34var chatItem = chatMessage.Contents[j];
Microsoft.Extensions.AI.Evaluation (14)
ChatMessageExtensions.cs (2)
99/// This function only considers the <see cref="ChatMessage.Text"/> and ignores any <see cref="AIContent"/>s 138/// This function only considers the <see cref="ChatMessage.Text"/> and ignores any <see cref="AIContent"/>s
ChatResponseExtensions.cs (1)
20/// This function only considers the <see cref="ChatResponse.Text"/> and ignores any <see cref="AIContent"/>s
EvaluationContext.cs (11)
28/// <see cref="AIContent"/>s that represent <b>all</b> the contextual information that is modeled by the 41/// <see cref="Contents"/> property returns a collection of <see cref="AIContent"/>s that represent <b>all</b> the 60/// Gets or sets a list of <see cref="AIContent"/> objects that include all the information present in this 67/// images, and other similar <see cref="AIContent"/> objects for other modalities such as audio and video in the 77/// <see cref="AIContent"/>s that represent <b>all</b> the contextual information that is modeled by the 91/// <see cref="Contents"/> property returns a collection of <see cref="AIContent"/>s that represent <b>all</b> the 96/// A list of <see cref="AIContent"/> objects that include all the information present in this 99public IList<AIContent> Contents { get; set; } 109protected EvaluationContext(string name, IEnumerable<AIContent> contents) 122protected EvaluationContext(string name, params AIContent[] contents) 123: this(name, contents as IEnumerable<AIContent>)
Microsoft.Extensions.AI.Evaluation.Quality (1)
ChatResponseExtensions.cs (1)
29foreach (AIContent content in modelResponse.Messages.SelectMany(m => m.Contents))
Microsoft.Extensions.AI.Evaluation.Reporting (5)
JsonSerialization\EvaluationContextConverter.cs (5)
14private sealed class DeserializedEvaluationContext(string name, IReadOnlyList<AIContent> contents) 31IReadOnlyList<AIContent>? contents = null; 68JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<AIContent>)); 69contents = JsonSerializer.Deserialize(ref reader, contentsTypeInfo) as IReadOnlyList<AIContent>; 90JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<AIContent>));
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (5)
src\Libraries\Microsoft.Extensions.AI.Evaluation.Reporting\CSharp\JsonSerialization\EvaluationContextConverter.cs (5)
14private sealed class DeserializedEvaluationContext(string name, IReadOnlyList<AIContent> contents) 31IReadOnlyList<AIContent>? contents = null; 68JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<AIContent>)); 69contents = JsonSerializer.Deserialize(ref reader, contentsTypeInfo) as IReadOnlyList<AIContent>; 90JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<AIContent>));
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (8)
ScenarioRunResultTests.cs (7)
17private sealed class TestContext(string name, params AIContent[] contents) 344if (x?.Contents is IList<AIContent> xContents && y?.Contents is IList<AIContent> yContents) 356private class AIContentComparer : IEqualityComparer<AIContent> 360public bool Equals(AIContent? x, AIContent? y) 375public int GetHashCode(AIContent obj)
SerializationChainingTests.cs (1)
32Contents = new List<AIContent>
Microsoft.Extensions.AI.Evaluation.Safety (5)
AIContentExtensions.cs (2)
10internal static bool IsTextOrUsage(this AIContent content) 13internal static bool IsImageWithSupportedFormat(this AIContent content) =>
ContentSafetyEvaluator.cs (1)
120relevantContext.SelectMany(c => c.Contents) is IEnumerable<AIContent> contents && contents.Any() &&
ContentSafetyServicePayloadUtilities.cs (2)
320foreach (AIContent content in message.Contents) 456foreach (AIContent content in message.Contents)
Microsoft.Extensions.AI.Integration.Tests (6)
ImageGeneratorIntegrationTests.cs (4)
48var content = response.Contents[0]; 71foreach (var content in response.Contents) 86AIContent[] originalImages = [new DataContent(imageData, "image/png") { Name = "dotnet.png" }]; 99var content = response.Contents[0];
PromptBasedFunctionCallingChatClient.cs (1)
90var contentItem = message.Contents.SingleOrDefault();
ReducingChatClientTests.cs (1)
99foreach (AIContent content in message.Contents)
Microsoft.Extensions.AI.OpenAI (42)
MicrosoftExtensionsAIChatExtensions.cs (2)
76static IEnumerable<ChatMessageAnnotation> ConvertAnnotations(IEnumerable<AIContent>? contents) 83foreach (var content in contents)
OpenAIAssistantsChatClient.cs (4)
353foreach (var input in codeInterpreterTool.Inputs) 374foreach (var input in fileSearchInputs) 480foreach (AIContent content in chatMessage.Contents) 484case AIContent when content.RawRepresentation is MessageContent rawRep:
OpenAIChatClient.cs (15)
138foreach (AIContent item in input.Contents) 164foreach (var content in input.Contents) 215/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentPart"/>.</summary> 216internal static List<ChatMessageContentPart> ToOpenAIChatContent(IEnumerable<AIContent> contents) 220foreach (var content in contents) 243private static ChatMessageContentPart? ToChatMessageContentPart(AIContent content) 247case AIContent when content.RawRepresentation is ChatMessageContentPart rawContentPart: 282private static ChatImageDetailLevel? GetImageDetail(AIContent content) 449if (ToAIContent(contentPart) is AIContent aiContent) 649/// <summary>Creates <see cref="AIContent"/>s from <see cref="ChatMessageContent"/>.</summary> 652internal static void ConvertContentParts(ChatMessageContent content, IList<AIContent> results) 663/// <summary>Creates an <see cref="AIContent"/> from a <see cref="ChatMessageContentPart"/>.</summary> 665/// <returns>The constructed <see cref="AIContent"/>, or <see langword="null"/> if the content part could not be converted.</returns> 666private static AIContent? ToAIContent(ChatMessageContentPart contentPart) 668AIContent? aiContent = null;
OpenAIImageGenerator.cs (2)
69var originalImage = request.OriginalImages.FirstOrDefault(); 148List<AIContent> contents = [];
OpenAIResponsesChatClient.cs (19)
149((List<AIContent>)message.Contents).AddRange(ToAIContents(messageItem.Content)); 225ChatResponseUpdate CreateUpdate(AIContent? content = null) => 305AIContent annotatedContent = new(); 555Dictionary<string, AIContent>? idToContentMapping = null; 581foreach (AIContent item in input.Contents) 585case AIContent when item.RawRepresentation is ResponseItem rawRep: 617foreach (AIContent item in input.Contents) 621case AIContent when item.RawRepresentation is ResponseItem rawRep: 655if (idToContentMapping?.TryGetValue(mstrc.CallId, out AIContent? callContentFromMapping) is true && 713/// <summary>Convert a sequence of <see cref="ResponseContentPart"/>s to a list of <see cref="AIContent"/>.</summary> 714private static List<AIContent> ToAIContents(IEnumerable<ResponseContentPart> contents) 716List<AIContent> results = []; 766private static void PopulateAnnotations(ResponseContentPart source, AIContent destination) 799/// <summary>Convert a list of <see cref="AIContent"/>s to a list of <see cref="ResponseContentPart"/>.</summary> 800private static List<ResponseContentPart> ToResponseContentParts(IList<AIContent> contents) 803foreach (var content in contents) 807case AIContent when content.RawRepresentation is ResponseContentPart rawRep: 845/// <summary>Adds new <see cref="AIContent"/> for the specified <paramref name="mtci"/> into <paramref name="contents"/>.</summary> 846private static void AddMcpToolCallContent(McpToolCallItem mtci, IList<AIContent> contents)
Microsoft.Extensions.AI.OpenAI.Tests (2)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (2)
33var expectedItem = expectedMessage.Contents[j]; 34var chatItem = chatMessage.Contents[j];
Microsoft.Extensions.AI.Tests (10)
ChatCompletion\DistributedCachingChatClientTest.cs (5)
694if (typeInfo.Type == typeof(AIContent)) 814var expectedItem = expectedMessage.Contents[itemIndex]; 815var actualItem = actualMessage.Contents[itemIndex]; 848var expectedItemItem = expectedItem.Contents[itemIndex]; 849var actualItemItem = actualItem.Contents[itemIndex];
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
568IEnumerable<AIContent> content = finalChat.SelectMany(m => m.Contents); 911AIContent[] resultContents = existingSearchResult is not null && existingSearchResult.Contents.OfType<FunctionResultContent>().ToList() is { } frcs
Image\LoggingImageGeneratorTests.cs (1)
117AIContent[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (2)
33var expectedItem = expectedMessage.Contents[j]; 34var chatItem = chatMessage.Contents[j];