6 types derived from AIContent
Microsoft.Extensions.AI.Abstractions (5)
Contents\DataContent.cs (1)
29public class DataContent : AIContent
Contents\FunctionCallContent.cs (1)
17public sealed class FunctionCallContent : AIContent
Contents\FunctionResultContent.cs (1)
16public sealed class FunctionResultContent : AIContent
Contents\TextContent.cs (1)
11public sealed class TextContent : AIContent
Contents\UsageContent.cs (1)
14public class UsageContent : AIContent
Microsoft.Extensions.AI.Abstractions.Tests (1)
Contents\AIContentTests.cs (1)
34private sealed class DerivedAIContent : AIContent;
65 references to AIContent
Microsoft.Extensions.AI (4)
ChatCompletion\ChatCompletion{T}.cs (1)
120var content = choice?.Contents.Count == 1 ? choice.Contents[0] : null;
ChatCompletion\FunctionInvokingChatClient.cs (3)
200HashSet<AIContent>? contentsToRemove = null; 433HashSet<AIContent>? contentToRemove, 595var contents = new AIContent[results.Length];
Microsoft.Extensions.AI.Abstractions (21)
ChatCompletion\ChatMessage.cs (3)
14private IList<AIContent>? _contents; 36IList<AIContent> contents) 78public IList<AIContent> Contents
ChatCompletion\StreamingChatCompletionUpdate.cs (2)
43private IList<AIContent>? _contents; 84public IList<AIContent> Contents
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (9)
27/// <see langword="true"/> to attempt to coalesce contiguous <see cref="AIContent"/> items, where applicable, 28/// into a single <see cref="AIContent"/>, in order to reduce the number of individual content items that are included in 54/// <see langword="true"/> to attempt to coalesce contiguous <see cref="AIContent"/> items, where applicable, 55/// into a single <see cref="AIContent"/>, in order to reduce the number of individual content items that are included in 98new(default, new List<AIContent>()); 106((List<AIContent>)message.Contents).AddRange(update.Contents); 177CoalesceTextContent((List<AIContent>)entry.Value.Contents); 184foreach (var content in entry.Value.Contents) 199private static void CoalesceTextContent(List<AIContent> contents)
Contents\AIContent.cs (2)
20/// Initializes a new instance of the <see cref="AIContent"/> class. 28/// If an <see cref="AIContent"/> is created to represent some underlying object from another object
Contents\AIContentExtensions.cs (4)
14/// <summary>Internal extensions for working with <see cref="AIContent"/>.</summary> 18public static T? FindFirst<T>(this IList<AIContent> contents) 19where T : AIContent 34public static string ConcatText(this IList<AIContent> contents)
Utilities\AIJsonUtilities.Defaults.cs (1)
84[JsonSerializable(typeof(AIContent))]
Microsoft.Extensions.AI.Abstractions.Tests (6)
ChatCompletion\ChatMessageTests.cs (5)
60Assert.Throws<ArgumentNullException>("contents", () => new ChatMessage(ChatRole.User, (IList<AIContent>)null!)); 69List<AIContent> content = []; 193Assert.IsType<List<AIContent>>(new ChatMessage().Contents); 202List<AIContent> contents = []; 262IList<AIContent> items =
ChatCompletion\StreamingChatCompletionUpdateTests.cs (1)
48IList<AIContent> newList = [new TextContent("text")];
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
423foreach (AIContent item in input.Contents) 456foreach (var content in input.Contents) 473/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentItem"/>.</summary> 474private static List<ChatMessageContentItem> GetContentParts(IList<AIContent> contents) 479foreach (var content in contents)
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
150[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] : 217[new ChatMessage(ChatRole.User, "hello".Select(c => (AIContent)new TextContent(c.ToString())).ToList())] :
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
232List<AIContent> contents = []; 375foreach (var item in content.Contents)
Microsoft.Extensions.AI.OpenAI (16)
OpenAIModelMapper.ChatCompletion.cs (6)
36foreach (AIContent content in chatCompletion.Message.Contents) 85if (ToAIContent(contentPart) is AIContent aiContent) 519/// <summary>Creates an <see cref="AIContent"/> from a <see cref="ChatMessageContentPart"/>.</summary> 521/// <returns>The constructed <see cref="AIContent"/>, or null if the content part could not be converted.</returns> 522private static AIContent? ToAIContent(ChatMessageContentPart contentPart) 524AIContent? aiContent = null;
OpenAIModelMapper.ChatMessage.cs (8)
80Contents = new AIContent[] { new FunctionResultContent(toolMessage.ToolCallId, functionName, result) }, 134foreach (AIContent item in input.Contents) 162foreach (var content in input.Contents) 186private static List<AIContent> FromOpenAIChatContent(IList<ChatMessageContentPart> openAiMessageContentParts) 188List<AIContent> contents = new(); 211/// <summary>Converts a list of <see cref="AIContent"/> to a list of <see cref="ChatMessageContentPart"/>.</summary> 212private static List<ChatMessageContentPart> ToOpenAIChatContent(IList<AIContent> contents) 215foreach (var content in contents)
OpenAIModelMappers.StreamingChatCompletion.cs (2)
31foreach (var content in chatCompletionUpdate.Contents) 120if (ToAIContent(contentPart) is AIContent aiContent)
Microsoft.Extensions.AI.OpenAI.Tests (3)
OpenAISerializationTests.cs (3)
48AIContent content = Assert.Single(message.Contents); 81AIContent content = Assert.Single(message.Contents); 559List<AIContent> contents = [new TextContent($"Streaming update {i}")];
Microsoft.Extensions.AI.Tests (6)
ChatCompletion\FunctionInvokingChatClientTests.cs (6)
242IEnumerable<AIContent> content = finalChat.SelectMany(m => m.Contents); 310IEnumerable<AIContent> content = finalChat.SelectMany(m => m.Contents); 606var expectedItem = expectedMessage.Contents[j]; 607var chatItem = chatMessage.Contents[j]; 696var expectedItem = expectedMessage.Contents[j]; 697var chatItem = chatMessage.Contents[j];