22 types derived from AIContent
Microsoft.Extensions.AI.Abstractions (18)
Contents\CodeInterpreterToolCallContent.cs (1)
17
public sealed class CodeInterpreterToolCallContent :
AIContent
Contents\CodeInterpreterToolResultContent.cs (1)
13
public sealed class CodeInterpreterToolResultContent :
AIContent
Contents\DataContent.cs (1)
37
public class DataContent :
AIContent
Contents\ErrorContent.cs (1)
15
public class ErrorContent :
AIContent
Contents\FunctionCallContent.cs (1)
17
public sealed class FunctionCallContent :
AIContent
Contents\FunctionResultContent.cs (1)
16
public sealed class FunctionResultContent :
AIContent
Contents\HostedFileContent.cs (1)
18
public sealed class HostedFileContent :
AIContent
Contents\HostedVectorStoreContent.cs (1)
19
public sealed class HostedVectorStoreContent :
AIContent
Contents\ImageGenerationToolCallContent.cs (1)
12
public sealed class ImageGenerationToolCallContent :
AIContent
Contents\ImageGenerationToolResultContent.cs (1)
17
public sealed class ImageGenerationToolResultContent :
AIContent
Contents\McpServerToolCallContent.cs (1)
19
public sealed class McpServerToolCallContent :
AIContent
Contents\McpServerToolResultContent.cs (1)
19
public sealed class McpServerToolResultContent :
AIContent
Contents\TextContent.cs (1)
13
public sealed class TextContent :
AIContent
Contents\TextReasoningContent.cs (1)
18
public sealed class TextReasoningContent :
AIContent
Contents\UriContent.cs (1)
19
public class UriContent :
AIContent
Contents\UsageContent.cs (1)
14
public class UsageContent :
AIContent
Contents\UserInputRequestContent.cs (1)
18
public class UserInputRequestContent :
AIContent
Contents\UserInputResponseContent.cs (1)
18
public class UserInputResponseContent :
AIContent
Microsoft.Extensions.AI.Abstractions.Tests (1)
Utilities\AIJsonUtilitiesTests.cs (1)
1419
private class DerivedAIContent :
AIContent
Microsoft.Extensions.AI.Tests (3)
ChatCompletion\DistributedCachingChatClientTest.cs (2)
884
public class CustomAIContent1(string text, DateTime date) :
AIContent
890
public class CustomAIContent2(string text, int number) :
AIContent
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
590
private sealed class NonSerializableAIContent :
AIContent
;
11 instantiations of AIContent
Microsoft.Extensions.AI.Abstractions.Tests (3)
Contents\AIContentTests.cs (3)
15
AIContent c =
new
();
23
AIContent c =
new
();
39
AIContent original =
new
()
Microsoft.Extensions.AI.OpenAI (4)
OpenAIResponsesChatClient.cs (4)
238
message.Contents.Add(
new
() { RawRepresentation = outputItem });
409
yield return CreateUpdate(new
AIContent
{ RawRepresentation = mtdli });
433
AIContent annotatedContent =
new
();
1166
results.Add(
new
() { RawRepresentation = part });
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIConversionTests.cs (4)
563
new
AIContent
{ RawRepresentation = ResponseItem.CreateWebSearchCallItem() },
564
new
AIContent
{ RawRepresentation = ResponseItem.CreateReferenceItem("123") },
571
new
AIContent
{ RawRepresentation = ResponseItem.CreateReasoningItem("text") },
575
new
AIContent
{ RawRepresentation = ResponseItem.CreateSystemMessageItem("test") },
311 references to AIContent
Aspire.Dashboard (1)
Model\Assistant\AIHelpers.cs (1)
503
public static IList<ChatMessage> GetMessages(ChatResponseUpdate update, Func<
AIContent
, bool>? filter = null)
Microsoft.Extensions.AI (30)
ChatCompletion\FunctionInvokingChatClient.cs (11)
503
IList<
AIContent
> contents = update.Contents;
769
IList<
AIContent
> content, [NotNullWhen(true)] ref List<FunctionCallContent>? functionCalls)
1073
var contents = new List<
AIContent
>(results.Length);
1245
List<
AIContent
>? rejectedFunctionCallResults = GenerateRejectedFunctionResults(notInvokedResponses.rejections);
1302
List<
AIContent
>? keptContents = null;
1307
var
content = message.Contents[j];
1399
/// <returns>The <see cref="
AIContent
"/> for the rejected function calls.</returns>
1400
private static List<
AIContent
>? GenerateRejectedFunctionResults(List<ApprovalResultWithRequestMessage>? rejections) =>
1402
rejections.ConvertAll(static m => (
AIContent
)new FunctionResultContent(m.Response.FunctionCall.CallId, "Error: Tool call invocation was rejected by user.")) :
1518
private static bool TryReplaceFunctionCallsWithApprovalRequests(IList<
AIContent
> content, out List<
AIContent
>? updatedContent)
ChatCompletion\ImageGeneratingChatClient.cs (14)
146
private readonly Dictionary<string, List<
AIContent
>> _imageContentByCallId = [];
147
private readonly Dictionary<string,
AIContent
> _imageContentById = new(StringComparer.OrdinalIgnoreCase);
169
List<
AIContent
>? newContents = null;
172
var
content = message.Contents[contentIndex];
198
foreach (
var
output in toolResultContent.Outputs ?? [])
317
public IList<
AIContent
> ReplaceImageGenerationFunctionResults(IList<
AIContent
> contents)
319
List<
AIContent
>? newContents = null;
324
var
content = contents[i];
393
List<
AIContent
> imageContents = _imageContentByCallId[callId] = [];
394
foreach (
var
content in response.Contents)
456
List<
AIContent
> imageContents = _imageContentByCallId[callId] = [];
457
foreach (
var
content in response.Contents)
489
if (_imageContentById.TryGetValue(imageId, out
var
imageContent))
ChatCompletion\OpenTelemetryChatClient.cs (1)
243
foreach (
AIContent
content in message.Contents)
ChatCompletion\OpenTelemetryImageGenerator.cs (1)
184
List<
AIContent
> content = [];
ChatReduction\SummarizingChatReducer.cs (3)
201
/// <summary>Returns whether the given <see cref="
AIContent
"/> relates to tool calling capabilities.</summary>
203
/// This method returns <see langword="true"/> for content types whose meaning depends on other related <see cref="
AIContent
"/>
207
private static bool IsToolRelatedContent(
AIContent
content) => content
Microsoft.Extensions.AI.Abstractions (90)
ChatCompletion\ChatMessage.cs (5)
17
private IList<
AIContent
>? _contents;
38
public ChatMessage(ChatRole role, IList<
AIContent
>? contents)
84
public IList<
AIContent
> Contents
108
/// <summary>Gets a <see cref="
AIContent
"/> object to display in the debugger display.</summary>
110
private
AIContent
? ContentForDebuggerDisplay
ChatCompletion\ChatResponseExtensions.cs (20)
56
/// contiguous <see cref="
AIContent
"/> items where applicable, e.g. multiple
75
/// <param name="filter">A predicate to filter which <see cref="
AIContent
"/> gets included in the message.</param>
82
public static void AddMessages(this IList<ChatMessage> list, ChatResponseUpdate update, Func<
AIContent
, bool>? filter = null)
110
/// contiguous <see cref="
AIContent
"/> items where applicable, e.g. multiple
133
/// message boundaries, as well as coalescing contiguous <see cref="
AIContent
"/> items where applicable, e.g. multiple
161
/// message boundaries, as well as coalescing contiguous <see cref="
AIContent
"/> items where applicable, e.g. multiple
188
/// Coalesces image result content elements in the provided list of <see cref="
AIContent
"/> items.
192
private static void CoalesceImageResultContent(IList<
AIContent
> contents)
228
/// <summary>Coalesces sequential <see cref="
AIContent
"/> content elements.</summary>
229
internal static void CoalesceContent(IList<
AIContent
> contents)
311
List<
AIContent
>? inputs = null;
349
List<
AIContent
>? output = null;
369
static string MergeText(IList<
AIContent
> contents, int start, int end)
383
IList<
AIContent
> contents,
386
Func<IList<
AIContent
>, int, int, TContent> merge)
387
where TContent :
AIContent
426
static bool TryAsCoalescable(
AIContent
content, [NotNullWhen(true)] out TContent? coalescable)
447
if (contents is List<
AIContent
> contentsList)
478
CoalesceContent((List<
AIContent
>)response.Messages[i].Contents);
538
foreach (
var
content in update.Contents)
ChatCompletion\ChatResponseUpdate.cs (5)
36
private IList<
AIContent
>? _contents;
55
public ChatResponseUpdate(ChatRole? role, IList<
AIContent
>? contents)
103
public IList<
AIContent
> Contents
177
/// <summary>Gets a <see cref="
AIContent
"/> object to display in the debugger display.</summary>
179
private
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)
39
/// Initializes a new instance of the <see cref="
AIContent
"/> class.
52
/// 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>
19
public static string ConcatText(this IEnumerable<
AIContent
> contents)
21
if (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\CodeInterpreterToolCallContent.cs (2)
36
/// <see cref="DataContent"/> for binary data, or other <see cref="
AIContent
"/> types as supported
40
public IList<
AIContent
>? Inputs { get; set; }
Contents\CodeInterpreterToolResultContent.cs (2)
33
/// or other <see cref="
AIContent
"/> types as supported by the service.
35
public IList<
AIContent
>? Outputs { get; set; }
Contents\ImageGenerationToolResultContent.cs (1)
38
public IList<
AIContent
>? Outputs { get; set; }
Contents\McpServerToolResultContent.cs (1)
40
public 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
"/>.
Functions\AIFunctionFactory.cs (14)
102
/// However, return values whose declared type is <see cref="
AIContent
"/>, a derived type of <see cref="
AIContent
"/>, or
180
/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. However, return values whose declared type is <see cref="
AIContent
"/>, a
181
/// derived type of <see cref="
AIContent
"/>, or any type assignable from <see cref="IEnumerable{AIContent}"/> are not serialized;
272
/// However, return values whose declared type is <see cref="
AIContent
"/>, a derived type of <see cref="
AIContent
"/>, or
357
/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. However, return values whose declared type is <see cref="
AIContent
"/>, a
358
/// derived type of <see cref="
AIContent
"/>, or any type assignable from <see cref="IEnumerable{AIContent}"/> are returned
462
/// However, return values whose declared type is <see cref="
AIContent
"/>, a derived type of <see cref="
AIContent
"/>, or any type
1123
typeof(
AIContent
).IsAssignableFrom(type) ||
1124
typeof(IEnumerable<
AIContent
>).IsAssignableFrom(type);
1138
if (typeof(IEnumerable<
AIContent
>).IsAssignableFrom(type))
1140
return typeof(IEnumerable<
AIContent
>);
Image\ImageGenerationRequest.cs (2)
28
public ImageGenerationRequest(string prompt, IEnumerable<
AIContent
>? originalImages)
44
public IEnumerable<
AIContent
>? OriginalImages { get; set; }
Image\ImageGenerationResponse.cs (2)
22
public ImageGenerationResponse(IList<
AIContent
>? contents)
44
public IList<
AIContent
> Contents
Image\ImageGeneratorExtensions.cs (1)
131
IEnumerable<
AIContent
> originalImages,
SpeechToText\SpeechToTextResponse.cs (4)
17
private IList<
AIContent
>? _contents;
27
public SpeechToTextResponse(IList<
AIContent
> contents)
77
IList<
AIContent
> contents = Contents;
100
public IList<
AIContent
> Contents
SpeechToText\SpeechToTextResponseUpdate.cs (3)
34
private IList<
AIContent
>? _contents;
44
public SpeechToTextResponseUpdate(IList<
AIContent
> contents)
92
public IList<
AIContent
> Contents
SpeechToText\SpeechToTextResponseUpdateExtensions.cs (3)
33
ChatResponseExtensions.CoalesceContent((List<
AIContent
>)response.Contents);
59
ChatResponseExtensions.CoalesceContent((List<
AIContent
>)response.Contents);
94
foreach (
var
content in update.Contents)
Tools\HostedCodeInterpreterTool.cs (2)
23
/// <summary>Gets or sets a collection of <see cref="
AIContent
"/> to be used as input to the code interpreter tool.</summary>
29
public IList<
AIContent
>? Inputs { get; set; }
Tools\HostedFileSearchTool.cs (2)
23
/// <summary>Gets or sets a collection of <see cref="
AIContent
"/> to be used as input to the file search tool.</summary>
30
public IList<
AIContent
>? Inputs { get; set; }
Utilities\AIJsonUtilities.cs (9)
25
/// Adds a custom content type to the polymorphic configuration for <see cref="
AIContent
"/>.
34
where TContent :
AIContent
43
/// Adds a custom content type to the polymorphic configuration for <see cref="
AIContent
"/>.
49
/// <exception cref="ArgumentException"><paramref name="contentType"/> is a built-in content type or does not derived from <see cref="
AIContent
"/>.</exception>
57
if (!typeof(
AIContent
).IsAssignableFrom(contentType))
59
Throw.ArgumentException(nameof(contentType), $"The content type must derive from {nameof(
AIContent
)}.");
191
if (checkBuiltIn && (contentType.Assembly == typeof(
AIContent
).Assembly))
193
Throw.ArgumentException(nameof(contentType), $"Cannot register built-in {nameof(
AIContent
)} types.");
199
if (typeInfo.Type == typeof(
AIContent
))
Utilities\AIJsonUtilities.Defaults.cs (2)
121
[JsonSerializable(typeof(
AIContent
))]
122
[JsonSerializable(typeof(IEnumerable<
AIContent
>))]
Microsoft.Extensions.AI.Abstractions.Tests (40)
AssertExtensions.cs (2)
33
var
expectedItem = expectedMessage.Contents[j];
34
var
chatItem = chatMessage.Contents[j];
ChatCompletion\ChatMessageTests.cs (6)
72
message = new(ChatRole.User, (IList<
AIContent
>?)null);
76
message = new ChatMessage(ChatRole.User, Array.Empty<
AIContent
>());
87
List<
AIContent
> content = [];
170
Assert.IsType<List<
AIContent
>>(new ChatMessage().Contents);
179
List<
AIContent
> contents = [];
253
IList<
AIContent
> items =
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (2)
875
var
firstOutput = Assert.Single(firstImageResult.Outputs);
881
var
secondOutput = Assert.Single(secondImageResult.Outputs);
ChatCompletion\ChatResponseUpdateTests.cs (3)
48
IList<
AIContent
> newList = [new TextContent("text")];
176
var originalContents = new List<
AIContent
> { new TextContent("text1"), new TextContent("text2") };
306
var sharedContents = new List<
AIContent
> { new TextContent("initial") };
Contents\AIContentTests.cs (7)
15
AIContent
c = new();
23
AIContent
c = new();
39
AIContent
original = new()
48
string json = JsonSerializer.Serialize(original, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(
AIContent
)));
51
AIContent
? deserialized = (
AIContent
?)JsonSerializer.Deserialize(json, AIJsonUtilities.DefaultOptions.GetTypeInfo(typeof(
AIContent
)));
Contents\CodeInterpreterToolCallContentTests.cs (1)
32
IList<
AIContent
> inputs = [new TextContent("print('hello')")];
Contents\CodeInterpreterToolResultContentTests.cs (1)
32
IList<
AIContent
> output = [new TextContent("Hello, World!")];
Contents\McpServerToolResultContentTests.cs (2)
41
IList<
AIContent
> output = [];
58
Output = new List<
AIContent
> { new TextContent("result") }
Image\ImageGenerationResponseTests.cs (4)
30
List<
AIContent
> content = [];
72
List<
AIContent
> contents = [
98
List<
AIContent
> contents = [
136
List<
AIContent
> contents = [
Image\ImageGeneratorTests.cs (1)
139
AIContent
[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
SpeechToText\SpeechToTextResponseTests.cs (4)
17
Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<
AIContent
>)null!));
64
Assert.Throws<ArgumentNullException>("contents", () => new SpeechToTextResponse((IList<
AIContent
>)null!));
73
List<
AIContent
> content = [];
133
List<
AIContent
> newContents = [new TextContent("text1"), new TextContent("text2")];
SpeechToText\SpeechToTextResponseUpdateTests.cs (1)
41
List<
AIContent
> newList = [new TextContent("content1")];
Utilities\AIJsonUtilitiesTests.cs (6)
508
JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(
AIContent
), serializerOptions: options);
1048
AIContent
c = new DerivedAIContent { DerivedValue = 42 };
1052
AIContent
? deserialized = JsonSerializer.Deserialize<
AIContent
>(json, options);
1075
Assert.Throws<ArgumentException>("contentType", () => options.AddAIContentType<
AIContent
>("discriminator"));
1089
AIContent
c = new DerivedAIContent();
Microsoft.Extensions.AI.AzureAIInference (5)
AzureAIInferenceChatClient.cs (5)
440
foreach (
AIContent
item in input.Contents)
482
foreach (
var
content in input.Contents)
499
/// <summary>Converts a list of <see cref="
AIContent
"/> to a list of <see cref="ChatMessageContentItem"/>.</summary>
500
private static List<ChatMessageContentItem> GetContentParts(IList<
AIContent
> contents)
505
foreach (
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)
33
var
expectedItem = expectedMessage.Contents[j];
34
var
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
53
/// Gets or sets a list of <see cref="
AIContent
"/> objects that include all the information present in this
60
/// images, and other similar <see cref="
AIContent
"/> objects for other modalities such as audio and video in the
70
/// <see cref="
AIContent
"/>s that represent <b>all</b> the contextual information that is modeled by the
84
/// <see cref="Contents"/> property returns a collection of <see cref="
AIContent
"/>s that represent <b>all</b> the
89
/// A list of <see cref="
AIContent
"/> objects that include all the information present in this
92
public IList<
AIContent
> Contents { get; set; }
101
protected EvaluationContext(string name, IEnumerable<
AIContent
> contents)
114
protected EvaluationContext(string name, params
AIContent
[] contents)
115
: this(name, contents as IEnumerable<
AIContent
>)
Microsoft.Extensions.AI.Evaluation.Quality (1)
ChatResponseExtensions.cs (1)
29
foreach (
AIContent
content in modelResponse.Messages.SelectMany(m => m.Contents))
Microsoft.Extensions.AI.Evaluation.Reporting (5)
JsonSerialization\EvaluationContextConverter.cs (5)
14
private sealed class DeserializedEvaluationContext(string name, IReadOnlyList<
AIContent
> contents)
31
IReadOnlyList<
AIContent
>? contents = null;
68
JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<
AIContent
>));
69
contents = JsonSerializer.Deserialize(ref reader, contentsTypeInfo) as IReadOnlyList<
AIContent
>;
90
JsonTypeInfo 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)
14
private sealed class DeserializedEvaluationContext(string name, IReadOnlyList<
AIContent
> contents)
31
IReadOnlyList<
AIContent
>? contents = null;
68
JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<
AIContent
>));
69
contents = JsonSerializer.Deserialize(ref reader, contentsTypeInfo) as IReadOnlyList<
AIContent
>;
90
JsonTypeInfo contentsTypeInfo = options.GetTypeInfo(typeof(IReadOnlyList<
AIContent
>));
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (7)
ScenarioRunResultTests.cs (7)
17
private sealed class TestContext(string name, params
AIContent
[] contents)
344
if (x?.Contents is IList<
AIContent
> xContents && y?.Contents is IList<
AIContent
> yContents)
356
private class AIContentComparer : IEqualityComparer<
AIContent
>
360
public bool Equals(
AIContent
? x,
AIContent
? y)
375
public int GetHashCode(
AIContent
obj)
Microsoft.Extensions.AI.Evaluation.Safety (5)
AIContentExtensions.cs (2)
10
internal static bool IsTextOrUsage(this
AIContent
content)
13
internal static bool IsImageWithSupportedFormat(this
AIContent
content) =>
ContentSafetyEvaluator.cs (1)
112
relevantContext.SelectMany(c => c.Contents) is IEnumerable<
AIContent
> contents && contents.Any() &&
ContentSafetyServicePayloadUtilities.cs (2)
316
foreach (
AIContent
content in message.Contents)
452
foreach (
AIContent
content in message.Contents)
Microsoft.Extensions.AI.Integration.Tests (8)
ImageGeneratingChatClientIntegrationTests.cs (2)
174
var
originalImage = Assert.Single(request.OriginalImages);
223
var
editContent = Assert.Single(secondRequest.OriginalImages);
ImageGeneratorIntegrationTests.cs (4)
47
var
content = Assert.Single(response.Contents);
81
foreach (
var
content in response.Contents)
96
AIContent
[] originalImages = [new DataContent(imageData, "image/png") { Name = "dotnet.png" }];
109
var
content = response.Contents[0];
PromptBasedFunctionCallingChatClient.cs (1)
90
var
contentItem = message.Contents.SingleOrDefault();
ReducingChatClientTests.cs (1)
98
foreach (
AIContent
content in message.Contents)
Microsoft.Extensions.AI.OpenAI (52)
MicrosoftExtensionsAIChatExtensions.cs (2)
85
static IEnumerable<ChatMessageAnnotation> ConvertAnnotations(IEnumerable<
AIContent
>? contents)
92
foreach (
var
content in contents)
OpenAIAssistantsChatClient.cs (4)
394
foreach (
var
input in codeInterpreterTool.Inputs)
415
foreach (
var
input in fileSearchInputs)
526
foreach (
AIContent
content in chatMessage.Contents)
530
case
AIContent
when content.RawRepresentation is MessageContent rawRep:
OpenAIChatClient.cs (15)
166
foreach (
AIContent
item in input.Contents)
192
foreach (
var
content in input.Contents)
243
/// <summary>Converts a list of <see cref="
AIContent
"/> to a list of <see cref="ChatMessageContentPart"/>.</summary>
244
internal static List<ChatMessageContentPart> ToOpenAIChatContent(IEnumerable<
AIContent
> contents)
248
foreach (
var
content in contents)
271
private static ChatMessageContentPart? ToChatMessageContentPart(
AIContent
content)
275
case
AIContent
when content.RawRepresentation is ChatMessageContentPart rawContentPart:
310
private static ChatImageDetailLevel? GetImageDetail(
AIContent
content)
477
if (ToAIContent(contentPart) is
AIContent
aiContent)
683
/// <summary>Creates <see cref="
AIContent
"/>s from <see cref="ChatMessageContent"/>.</summary>
686
internal static void ConvertContentParts(ChatMessageContent content, IList<
AIContent
> results)
697
/// <summary>Creates an <see cref="
AIContent
"/> from a <see cref="ChatMessageContentPart"/>.</summary>
699
/// <returns>The constructed <see cref="
AIContent
"/>, or <see langword="null"/> if the content part could not be converted.</returns>
700
private static
AIContent
? ToAIContent(ChatMessageContentPart contentPart)
702
AIContent
? aiContent = null;
OpenAIImageGenerator.cs (2)
68
var
originalImage = request.OriginalImages.FirstOrDefault();
145
List<
AIContent
> contents = [];
OpenAIResponsesChatClient.cs (29)
189
((List<
AIContent
>)message.Contents).AddRange(ToAIContents(messageItem.Content));
296
ChatResponseUpdate CreateUpdate(
AIContent
? content = null) =>
433
AIContent
annotatedContent = new();
783
Dictionary<string,
AIContent
>? idToContentMapping = null;
810
foreach (
AIContent
item in input.Contents)
839
case
AIContent
when item.RawRepresentation is ResponseContentPart rawRep:
890
foreach (
AIContent
item in input.Contents)
894
case
AIContent
when item.RawRepresentation is ResponseItem rawRep:
899
static FunctionCallOutputResponseItem SerializeAIContent(string callId, IEnumerable<
AIContent
> contents)
903
foreach (
var
content in contents)
986
case
AIContent
ac:
990
case IEnumerable<
AIContent
> items:
1024
foreach (
AIContent
item in input.Contents)
1028
case
AIContent
when item.RawRepresentation is ResponseItem rawRep:
1064
if (idToContentMapping?.TryGetValue(mstrc.CallId, out
AIContent
? callContentFromMapping) is true &&
1122
/// <summary>Convert a sequence of <see cref="ResponseContentPart"/>s to a list of <see cref="
AIContent
"/>.</summary>
1123
private static List<
AIContent
> ToAIContents(IEnumerable<ResponseContentPart> contents)
1125
List<
AIContent
> results = [];
1175
private static void PopulateAnnotations(ResponseContentPart source,
AIContent
destination)
1215
/// <summary>Adds new <see cref="
AIContent
"/> for the specified <paramref name="mtci"/> into <paramref name="contents"/>.</summary>
1216
private static void AddMcpToolCallContent(McpToolCallItem mtci, IList<
AIContent
> contents)
1245
/// <summary>Adds new <see cref="
AIContent
"/> for the specified <paramref name="cicri"/> into <paramref name="contents"/>.</summary>
1246
private static void AddCodeInterpreterContents(CodeInterpreterCallResponseItem cicri, IList<
AIContent
> contents)
1261
Outputs = cicri.Outputs is { Count: > 0 } outputs ? outputs.Select<CodeInterpreterCallOutput,
AIContent
?>(o =>
1267
}).OfType<
AIContent
>().ToList() : null,
1272
private static void AddImageGenerationContents(ImageGenerationCallResponseItem outputItem, ResponseCreationOptions? options, IList<
AIContent
> contents)
1286
Outputs = new List<
AIContent
>
1302
Outputs = new List<
AIContent
>
1370
private static ResponseImageDetailLevel? GetImageDetail(
AIContent
content)
Microsoft.Extensions.AI.OpenAI.Tests (7)
OpenAIResponseClientIntegrationTests.cs (2)
456
Tools = [AIFunctionFactory.Create((string city) => new List<
AIContent
>
532
Tools = [AIFunctionFactory.Create(() => new List<
AIContent
>
OpenAIResponseClientTests.cs (3)
3720
new FunctionResultContent("call_456", new List<
AIContent
>
3955
new FunctionResultContent("call_mixed", new List<
AIContent
>
5096
static bool HasCorrectImageData(
AIContent
o, int index)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (2)
33
var
expectedItem = expectedMessage.Contents[j];
34
var
chatItem = chatMessage.Contents[j];
Microsoft.Extensions.AI.Tests (35)
ChatCompletion\DistributedCachingChatClientTest.cs (5)
694
if (typeInfo.Type == typeof(
AIContent
))
811
var
expectedItem = expectedMessage.Contents[itemIndex];
812
var
actualItem = actualMessage.Contents[itemIndex];
845
var
expectedItemItem = expectedItem.Contents[itemIndex];
846
var
actualItemItem = actualItem.Contents[itemIndex];
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
568
IEnumerable<
AIContent
> content = finalChat.SelectMany(m => m.Contents);
929
AIContent
[] resultContents = existingSearchResult is not null && existingSearchResult.Contents.OfType<FunctionResultContent>().ToList() is { } frcs
Functions\AIFunctionFactoryTest.cs (25)
931
AIFunctionFactory.Create(() => (
AIContent
)new TextContent("text")),
932
AIFunctionFactory.Create(async () => (
AIContent
)new TextContent("text")),
933
AIFunctionFactory.Create(async ValueTask<
AIContent
> () => (
AIContent
)new TextContent("text")),
936
AIFunctionFactory.Create(async ValueTask<
AIContent
> () => new TextContent("text")),
946
await ValidateAsync<IEnumerable<
AIContent
>>(
948
AIFunctionFactory.Create(() => (IEnumerable<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
949
AIFunctionFactory.Create(async () => (IEnumerable<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
950
AIFunctionFactory.Create(async ValueTask<IEnumerable<
AIContent
>> () => (IEnumerable<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
953
await ValidateAsync<
AIContent
[]>(
955
AIFunctionFactory.Create(() => (
AIContent
[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
956
AIFunctionFactory.Create(async () => (
AIContent
[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
957
AIFunctionFactory.Create(async ValueTask<
AIContent
[]> () => (
AIContent
[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
960
await ValidateAsync<List<
AIContent
>>(
962
AIFunctionFactory.Create(() => (List<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
963
AIFunctionFactory.Create(async () => (List<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
964
AIFunctionFactory.Create(async ValueTask<List<
AIContent
>> () => (List<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
967
await ValidateAsync<IEnumerable<
AIContent
>>(
969
AIFunctionFactory.Create(() => (IList<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
970
AIFunctionFactory.Create(async () => (IList<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
971
AIFunctionFactory.Create(async ValueTask<IList<
AIContent
>> () => (List<
AIContent
>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Image\LoggingImageGeneratorTests.cs (1)
116
AIContent
[] originalImages = [new DataContent((byte[])[1, 2, 3, 4], "image/png")];
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\AssertExtensions.cs (2)
33
var
expectedItem = expectedMessage.Contents[j];
34
var
chatItem = chatMessage.Contents[j];
Microsoft.Extensions.DataIngestion (2)
Processors\ImageAlternativeTextEnricher.cs (1)
90
List<
AIContent
> contents = new(batch.Count);
Utils\Batching.cs (1)
30
List<
AIContent
> contents = new(batch.Length);