10 types derived from AIContent
Microsoft.Extensions.AI.Abstractions (8)
Contents\DataContent.cs (1)
29public 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\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
Microsoft.Extensions.AI.Abstractions.Tests (2)
Contents\AIContentTests.cs (1)
34private sealed class DerivedAIContent : AIContent;
Utilities\AIJsonUtilitiesTests.cs (1)
557private class DerivedAIContent : AIContent
133 references to AIContent
Microsoft.Extensions.AI (5)
ChatCompletion\FunctionInvokingChatClient.cs (3)
343IList<AIContent> contents = update.Contents; 512IList<AIContent> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls) 733var contents = new List<AIContent>(results.Length);
ChatCompletion\OpenTelemetryChatClient.cs (2)
520private AssistantEvent CreateAssistantEvent(IEnumerable<AIContent> contents) 541private string? GetMessageContent(IEnumerable<AIContent> contents)
Microsoft.Extensions.AI.Abstractions (44)
ChatCompletion\ChatMessage.cs (5)
17private IList<AIContent>? _contents; 38public ChatMessage(ChatRole role, IList<AIContent>? contents) 80public IList<AIContent> Contents 104/// <summary>Gets a <see cref="AIContent"/> object to display in the debugger display.</summary> 106private AIContent? ContentForDebuggerDisplay => _contents is { Count: > 0 } ? _contents[0] : null;
ChatCompletion\ChatResponseExtensions.cs (12)
53/// contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 72/// <param name="filter">A predicate to filter which <see cref="AIContent"/> gets included in the message.</param> 79public static void AddMessages(this IList<ChatMessage> list, ChatResponseUpdate update, Func<AIContent, bool>? filter = null) 106/// contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 129/// message boundaries, as well as coalescing contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 157/// message boundaries, as well as coalescing contiguous <see cref="AIContent"/> items where applicable, e.g. multiple 183/// <summary>Coalesces sequential <see cref="AIContent"/> content elements.</summary> 184internal static void CoalesceTextContent(List<AIContent> contents) 190static void Coalesce<TContent>(List<AIContent> contents, Func<string, TContent> fromText) 191where TContent : AIContent 245CoalesceTextContent((List<AIContent>)response.Messages[i].Contents); 300foreach (var content in update.Contents)
ChatCompletion\ChatResponseUpdate.cs (5)
36private IList<AIContent>? _contents; 58public ChatResponseUpdate(ChatRole? role, IList<AIContent>? contents) 83public IList<AIContent> Contents 160/// <summary>Gets a <see cref="AIContent"/> object to display in the debugger display.</summary> 162private AIContent? ContentForDebuggerDisplay => _contents is { Count: > 0 } ? _contents[0] : null;
Contents\AIContent.cs (2)
21/// Initializes a new instance of the <see cref="AIContent"/> class. 29/// 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)
SpeechToText\SpeechToTextResponse.cs (3)
19private IList<AIContent>? _contents; 29public SpeechToTextResponse(IList<AIContent> contents) 96public IList<AIContent> Contents
SpeechToText\SpeechToTextResponseUpdate.cs (3)
36private IList<AIContent>? _contents; 46public SpeechToTextResponseUpdate(IList<AIContent> contents) 94public IList<AIContent> Contents
SpeechToText\SpeechToTextResponseUpdateExtensions.cs (3)
28List<AIContent> contents = []; 73List<AIContent> contents = []; 113List<AIContent> contents,
Utilities\AIJsonUtilities.cs (7)
26/// Adds a custom content type to the polymorphic configuration for <see cref="AIContent"/>. 35where TContent : AIContent 44/// Adds a custom content type to the polymorphic configuration for <see cref="AIContent"/>. 50/// <exception cref="ArgumentException"><paramref name="contentType"/> is a built-in content type or does not derived from <see cref="AIContent"/>.</exception> 58if (!typeof(AIContent).IsAssignableFrom(contentType)) 163if (contentType.Assembly == typeof(AIContent).Assembly) 171if (typeInfo.Type == typeof(AIContent))
Utilities\AIJsonUtilities.Defaults.cs (1)
115[JsonSerializable(typeof(AIContent))]
Microsoft.Extensions.AI.Abstractions.Tests (18)
ChatCompletion\ChatMessageTests.cs (6)
71message = new(ChatRole.User, (IList<AIContent>?)null); 75message = new ChatMessage(ChatRole.User, Array.Empty<AIContent>()); 86List<AIContent> content = []; 168Assert.IsType<List<AIContent>>(new ChatMessage().Contents); 177List<AIContent> contents = []; 237IList<AIContent> items =
ChatCompletion\ChatResponseUpdateTests.cs (1)
48IList<AIContent> newList = [new TextContent("text")];
SpeechToText\SpeechToTextResponseTests.cs (4)
17Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!)); 63Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<AIContent>)null!)); 72List<AIContent> content = []; 132List<AIContent> newContents = [new TextContent("text1"), new TextContent("text2")];
SpeechToText\SpeechToTextResponseUpdateTests.cs (2)
41List<AIContent> newList = new(); 92Contents = new List<AIContent>
Utilities\AIJsonUtilitiesTests.cs (5)
458AIContent c = new DerivedAIContent { DerivedValue = 42 }; 462AIContent? deserialized = JsonSerializer.Deserialize<AIContent>(json, options); 485Assert.Throws<ArgumentException>(() => options.AddAIContentType<AIContent>("discriminator")); 496AIContent c = new DerivedAIContent();
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
423foreach (AIContent item in input.Contents) 467foreach (var content in input.Contents) 484/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentItem"/>.</summary> 485private static List<ChatMessageContentItem> GetContentParts(IList<AIContent> contents) 490foreach (var content in contents)
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
131[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 204[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] :
Microsoft.Extensions.AI.Evaluation (14)
EvaluationContext.cs (4)
17/// Returns a list of <see cref="AIContent"/> objects that include all the information present in this 24/// images, and other similar <see cref="AIContent"/> objects for other modalities such as audio and video in the 33/// A list of <see cref="AIContent"/> objects that include all the information present in this 36public abstract IReadOnlyList<AIContent> GetContents();
EvaluationMetric.cs (3)
52/// Each entry in the returned dictionary has a name (key), and a collection of <see cref="AIContent"/> objects 56/// <see cref="EvaluationContext"/> as the key, and the <see cref="AIContent"/> objects returned from 59public IDictionary<string, IList<AIContent>>? Context { get; set; }
EvaluationMetricExtensions.cs (4)
23public static void AddOrUpdateContext(this EvaluationMetric metric, string name, params AIContent[] value) 24=> metric.AddOrUpdateContext(name, value as IEnumerable<AIContent>); 33public static void AddOrUpdateContext(this EvaluationMetric metric, string name, IEnumerable<AIContent> value) 37metric.Context ??= new Dictionary<string, IList<AIContent>>();
EvaluationResultExtensions.cs (3)
28params AIContent[] value) 29=> result.AddOrUpdateContextInAllMetrics(name, value as IEnumerable<AIContent>); 43IEnumerable<AIContent> value)
Microsoft.Extensions.AI.Evaluation.Quality (2)
EquivalenceEvaluatorContext.cs (1)
36public override IReadOnlyList<AIContent> GetContents()
GroundednessEvaluatorContext.cs (1)
36public override IReadOnlyList<AIContent> GetContents()
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
SerializationChainingTests.cs (1)
32Contents = new List<AIContent>
Microsoft.Extensions.AI.Evaluation.Safety (5)
AIContentExtensions.cs (2)
9internal static bool IsTextOrUsage(this AIContent content) 12internal static bool IsImageWithSupportedFormat(this AIContent content) =>
ContentSafetyEvaluator.cs (1)
129relevantContext.SelectMany(c => c.GetContents()) is IEnumerable<AIContent> content && content.Any() &&
GroundednessProEvaluatorContext.cs (1)
36public override IReadOnlyList<AIContent> GetContents()
UngroundedAttributesEvaluatorContext.cs (1)
38public override IReadOnlyList<AIContent> GetContents()
Microsoft.Extensions.AI.Integration.Tests (1)
ReducingChatClientTests.cs (1)
158foreach (AIContent content in message.Contents)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
256List<AIContent> contents = []; 400foreach (var item in content.Contents)
Microsoft.Extensions.AI.OpenAI (22)
OpenAIChatClient.cs (12)
128foreach (AIContent item in input.Contents) 156foreach (var content in input.Contents) 180/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentPart"/>.</summary> 181private static List<ChatMessageContentPart> ToOpenAIChatContent(IList<AIContent> contents) 184foreach (var content in contents) 223private static ChatImageDetailLevel? GetImageDetail(AIContent content) 295if (ToAIContent(contentPart) is AIContent aiContent) 397if (ToAIContent(contentPart) is AIContent aiContent) 685/// <summary>Creates an <see cref="AIContent"/> from a <see cref="ChatMessageContentPart"/>.</summary> 687/// <returns>The constructed <see cref="AIContent"/>, or <see langword="null"/> if the content part could not be converted.</returns> 688private static AIContent? ToAIContent(ChatMessageContentPart contentPart) 690AIContent? aiContent = null;
OpenAIResponseChatClient.cs (10)
111Debug.Assert(message.Contents is List<AIContent>, "Expected a List<AIContent> for message contents."); 122((List<AIContent>)message.Contents).AddRange(ToAIContents(messageItem.Content)); 463foreach (AIContent item in input.Contents) 491foreach (AIContent item in input.Contents) 540/// <summary>Convert a sequence of <see cref="ResponseContentPart"/>s to a list of <see cref="AIContent"/>.</summary> 541private static List<AIContent> ToAIContents(IEnumerable<ResponseContentPart> contents) 543List<AIContent> results = []; 556/// <summary>Convert a list of <see cref="AIContent"/>s to a list of <see cref="ResponseContentPart"/>.</summary> 557private static List<ResponseContentPart> ToOpenAIResponsesContent(IList<AIContent> contents) 560foreach (var content in contents)
Microsoft.Extensions.AI.Tests (12)
ChatCompletion\DistributedCachingChatClientTest.cs (6)
618if (typeInfo.Type == typeof(AIContent)) 738var expectedItem = expectedMessage.Contents[itemIndex]; 739var actualItem = actualMessage.Contents[itemIndex]; 772var expectedItemItem = expectedItem.Contents[itemIndex]; 773var actualItemItem = actualItem.Contents[itemIndex]; 811public class CustomAIContent1(string text, DateTime date) : AIContent
ChatCompletion\FunctionInvokingChatClientTests.cs (6)
423IEnumerable<AIContent> content = finalChat.SelectMany(m => m.Contents); 766AIContent[] resultContents = existingSearchResult is not null && existingSearchResult.Contents.OfType<FunctionResultContent>().ToList() is { } frcs 988var expectedItem = expectedMessage.Contents[j]; 989var chatItem = chatMessage.Contents[j]; 1082var expectedItem = expectedMessage.Contents[j]; 1083var chatItem = chatMessage.Contents[j];