17 types derived from AIContent
Microsoft.AspNetCore.Components.AI (1)
Microsoft.Extensions.AI.Abstractions (12)
Microsoft.Extensions.AI.Abstractions.Tests (1)
Microsoft.Extensions.AI.Tests (3)
12 instantiations of AIContent
Microsoft.Extensions.AI.Abstractions.Tests (3)
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
Microsoft.Extensions.AI.OpenAI (4)
Microsoft.Extensions.AI.OpenAI.Tests (4)
504 references to AIContent
Microsoft.AspNetCore.Components.AI (24)
Microsoft.Extensions.AI (37)
Microsoft.Extensions.AI.Abstractions (104)
ChatCompletion\ChatResponseExtensions.cs (22)
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>
82public 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.
192private static void CoalesceImageResultContent(IList<AIContent> contents)
229/// Coalesces web search tool call content elements in the provided list of <see cref="AIContent"/> items.
233private static void CoalesceWebSearchToolCallContent(IList<AIContent> contents)
281/// <summary>Coalesces sequential <see cref="AIContent"/> content elements.</summary>
282internal static void CoalesceContent(IList<AIContent> contents)
366List<AIContent>? inputs = null;
403List<AIContent>? output = null;
422static string MergeText(IList<AIContent> contents, int start, int end)
436IList<AIContent> contents,
439Func<IList<AIContent>, int, int, TContent> merge)
440where TContent : AIContent
479static bool TryAsCoalescable(AIContent content, [NotNullWhen(true)] out TContent? coalescable)
500if (contents is List<AIContent> contentsList)
531CoalesceContent((List<AIContent>)response.Messages[i].Contents);
620foreach (var content in update.Contents)
Functions\AIFunctionFactory.cs (14)
110/// However, return values whose declared type is <see cref="AIContent"/>, a derived type of <see cref="AIContent"/>, or
190/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. However, return values whose declared type is <see cref="AIContent"/>, a
191/// derived type of <see cref="AIContent"/>, or any type assignable from <see cref="IEnumerable{AIContent}"/> are not serialized;
281/// However, return values whose declared type is <see cref="AIContent"/>, a derived type of <see cref="AIContent"/>, or
369/// or else using <see cref="AIJsonUtilities.DefaultOptions"/>. However, return values whose declared type is <see cref="AIContent"/>, a
370/// derived type of <see cref="AIContent"/>, or any type assignable from <see cref="IEnumerable{AIContent}"/> are returned
473/// However, return values whose declared type is <see cref="AIContent"/>, a derived type of <see cref="AIContent"/>, or any type
1223typeof(AIContent).IsAssignableFrom(type) ||
1224typeof(IEnumerable<AIContent>).IsAssignableFrom(type);
1253if (typeof(IEnumerable<AIContent>).IsAssignableFrom(type))
1255return typeof(IEnumerable<AIContent>);
Microsoft.Extensions.AI.Abstractions.Tests (138)
Utilities\AIJsonUtilitiesTests.cs (21)
706JsonElement schema = AIJsonUtilities.CreateJsonSchema(typeof(AIContent), serializerOptions: options);
1240AIContent c = new DerivedAIContent { DerivedValue = 42 };
1244AIContent? deserialized = JsonSerializer.Deserialize<AIContent>(json, options);
1267Assert.Throws<ArgumentException>("contentType", () => options.AddAIContentType<AIContent>("discriminator"));
1281AIContent c = new DerivedAIContent();
1317var aiContentTypes = options.GetTypeInfo(typeof(AIContent)).PolymorphismOptions!.DerivedTypes;
1333AIContent ac = new LeafContent { DerivedValue = 2, LeafValue = 99 };
1339LeafContent deserializedAc = Assert.IsType<LeafContent>(JsonSerializer.Deserialize<AIContent>(json2, options));
1369var aiContentTypes = options.GetTypeInfo(typeof(AIContent)).PolymorphismOptions!.DerivedTypes;
1383AIContent ac = new DerivedToolCallContent { CustomValue = 99 };
1388DerivedToolCallContent deserializedAc = Assert.IsType<DerivedToolCallContent>(JsonSerializer.Deserialize<AIContent>(json2, options));
1407var aiContentDerivedTypes = options.GetTypeInfo(typeof(AIContent)).PolymorphismOptions!.DerivedTypes;
1414AIContent ac = new DerivedAIContent { DerivedValue = 1 };
1417DerivedAIContent deserializedDc = Assert.IsType<DerivedAIContent>(JsonSerializer.Deserialize<AIContent>(json, options));
1429AIContent ac2 = new LeafContent { DerivedValue = 3, LeafValue = 99 };
1432LeafContent deserializedAc = Assert.IsType<LeafContent>(JsonSerializer.Deserialize<AIContent>(json3, options));
1453var aiContentDerivedTypes = options.GetTypeInfo(typeof(AIContent)).PolymorphismOptions!.DerivedTypes;
1460AIContent ac = new LeafContent { DerivedValue = 1, LeafValue = 42 };
1463Assert.IsType<LeafContent>(JsonSerializer.Deserialize<AIContent>(json, options));
1466AIContent unregistered = new DerivedAIContent { DerivedValue = 99 };
Microsoft.Extensions.AI.Evaluation (14)
Microsoft.Extensions.AI.Evaluation.Quality (1)
Microsoft.Extensions.AI.Evaluation.Reporting (5)
Microsoft.Extensions.AI.Evaluation.Reporting.Azure (5)
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (7)
Microsoft.Extensions.AI.Evaluation.Safety (5)
Microsoft.Extensions.AI.Integration.Tests (12)
Microsoft.Extensions.AI.OpenAI (52)
Microsoft.Extensions.AI.OpenAI.Tests (20)
Microsoft.Extensions.AI.Stabilization.Tests (33)
Microsoft.Extensions.AI.Tests (45)
Functions\AIFunctionFactoryTest.cs (25)
1162AIFunctionFactory.Create(() => (AIContent)new TextContent("text")),
1163AIFunctionFactory.Create(async () => (AIContent)new TextContent("text")),
1164AIFunctionFactory.Create(async ValueTask<AIContent> () => (AIContent)new TextContent("text")),
1167AIFunctionFactory.Create(async ValueTask<AIContent> () => new TextContent("text")),
1177await ValidateAsync<IEnumerable<AIContent>>(
1179AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1180AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1181AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1184await ValidateAsync<AIContent[]>(
1186AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1187AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1188AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1191await ValidateAsync<List<AIContent>>(
1193AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1194AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1195AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1198await ValidateAsync<IEnumerable<AIContent>>(
1200AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1201AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
1202AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]),
Microsoft.Extensions.DataIngestion (2)