135 instantiations of ChatResponseUpdate
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
628new()
Microsoft.Extensions.AI.Abstractions (2)
Microsoft.Extensions.AI.Abstractions.Tests (73)
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (66)
30new(ChatRole.Assistant, "Hello") { ResponseId = "someResponse", MessageId = "12345", CreatedAt = new DateTimeOffset(1, 2, 3, 4, 5, 6, TimeSpan.Zero), ModelId = "model123" },
31new(ChatRole.Assistant, ", ") { AuthorName = "Someone", AdditionalProperties = new() { ["a"] = "b" } },
32new(null, "world!") { CreatedAt = new DateTimeOffset(2, 2, 3, 4, 5, 6, TimeSpan.Zero), ConversationId = "123", AdditionalProperties = new() { ["c"] = "d" } },
34new() { Contents = [new UsageContent(new() { InputTokenCount = 1, OutputTokenCount = 2 })] },
35new() { Contents = [new UsageContent(new() { InputTokenCount = 4, OutputTokenCount = 5 })] },
74new(null, "!") { MessageId = "1" },
75new(ChatRole.Assistant, "a") { MessageId = "1" },
76new(ChatRole.Assistant, "b") { MessageId = "2" },
77new(ChatRole.User, "c") { MessageId = "2" },
78new(ChatRole.User, "d") { MessageId = "2" },
79new(ChatRole.Assistant, "e") { MessageId = "3" },
80new(ChatRole.Tool, "f") { MessageId = "4" },
81new(ChatRole.Tool, "g") { MessageId = "4" },
82new(ChatRole.Tool, "h") { MessageId = "5" },
83new(new("human"), "i") { MessageId = "6" },
84new(new("human"), "j") { MessageId = "7" },
85new(new("human"), "k") { MessageId = "7" },
86new(null, "l") { MessageId = "7" },
87new(null, "m") { MessageId = "8" },
132new(null, "Hi! ") { CreatedAt = new DateTimeOffset(2023, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" },
133new(ChatRole.Assistant, "Hello") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 0, 0, TimeSpan.Zero), AuthorName = "Assistant" },
134new(null, " from") { MessageId = "msg1", CreatedAt = new DateTimeOffset(2024, 1, 1, 10, 1, 0, TimeSpan.Zero) }, // Later CreatedAt should win
135new(null, " AI") { MessageId = "msg1", AuthorName = "AI Assistant" }, // Later AuthorName should win
138new(ChatRole.User, "How") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 0, 0, TimeSpan.Zero), AuthorName = "User" },
139new(null, " are") { MessageId = "msg2", CreatedAt = new DateTimeOffset(2024, 1, 1, 11, 1, 0, TimeSpan.Zero) },
140new(null, " you?") { MessageId = "msg2", AuthorName = "Human User" }, // Later AuthorName should win
143new(ChatRole.Assistant, "I'm doing well,") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 0, 0, TimeSpan.Zero) },
144new(null, " thank you!") { MessageId = "msg3", CreatedAt = new DateTimeOffset(2024, 1, 1, 12, 2, 0, TimeSpan.Zero) }, // Later CreatedAt should win
147new(null, " How can I help?"),
221updates.Add(new(null, text));
242updates.Add(new() { Contents = [new DataContent("data:image/png;base64,aGVsbG8=")] });
269new(null, "A"),
270new(null, "B"),
271new(null, "C"),
272new() { Contents = [new TextReasoningContent("D")] },
273new() { Contents = [new TextReasoningContent("E")] },
274new() { Contents = [new TextReasoningContent("F")] },
275new(null, "G"),
276new(null, "H"),
277new() { Contents = [new TextReasoningContent("I")] },
278new() { Contents = [new TextReasoningContent("J")] },
279new(null, "K"),
280new() { Contents = [new TextReasoningContent("L")] },
281new(null, "M"),
282new(null, "N"),
283new() { Contents = [new TextReasoningContent("O")] },
284new() { Contents = [new TextReasoningContent("P")] },
307new(null, "A"),
308new(null, "B"),
309new(null, "C"),
310new() { Contents = [new TextContent("D") { Annotations = [new()] }] },
311new() { Contents = [new TextContent("E") { Annotations = [new()] }] },
312new() { Contents = [new TextContent("F") { Annotations = [new()] }] },
313new() { Contents = [new TextContent("G") { Annotations = [] }] },
314new() { Contents = [new TextContent("H") { Annotations = [] }] },
315new() { Contents = [new TextContent("I") { Annotations = [new()] }] },
316new() { Contents = [new TextContent("J") { Annotations = [new()] }] },
317new(null, "K"),
318new() { Contents = [new TextContent("L") { Annotations = [new()] }] },
319new(null, "M"),
320new(null, "N"),
321new() { Contents = [new TextContent("O") { Annotations = [new()] }] },
322new() { Contents = [new TextContent("P") { Annotations = [new()] }] },
347new(null, "Hello, "),
348new(null, "world!"),
349new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
Microsoft.Extensions.AI.AzureAIInference (2)
Microsoft.Extensions.AI.Evaluation.Safety (1)
Microsoft.Extensions.AI.OpenAI (6)
Microsoft.Extensions.AI.OpenAI.Tests (10)
OpenAIConversionTests.cs (10)
646var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello")
664var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Hello, world!")
693var responseUpdate = new ChatResponseUpdate
732var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, [functionCallContent])
767var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, [functionCall1, functionCall2])
795var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant,
843var responseUpdate = new ChatResponseUpdate(inputRole, "Test message");
869var responseUpdate = new ChatResponseUpdate(ChatRole.Assistant, "Test")
890new ChatResponseUpdate(ChatRole.Assistant, "Hello, ")
897new ChatResponseUpdate(ChatRole.Assistant, "world!")
Microsoft.Extensions.AI.Tests (39)
ChatCompletion\DistributedCachingChatClientTest.cs (16)
249new()
262new()
267new()
313new(ChatRole.Assistant, "This"),
314new(ChatRole.Assistant, " becomes one chunk"),
315new() { Role = ChatRole.Assistant, Contents = [new FunctionCallContent("callId1", "separator")] },
316new(ChatRole.Assistant, "... and this"),
317new(ChatRole.Assistant, " becomes another"),
318new(ChatRole.Assistant, " one."),
368new() { Role = ChatRole.Assistant, Contents = [new TextContent("Hello")] },
369new() { Role = ChatRole.Assistant, Contents = [new TextContent(" world, ")] },
370new()
381new()
436new(ChatRole.Assistant, "Chunk 1"),
484() => new(ChatRole.Assistant, "Chunk 1"),
523[() => new(ChatRole.Assistant, "A good result")]);
Microsoft.ML.GenAI.Core (1)
240 references to ChatResponseUpdate
Aspire.Dashboard (2)
Microsoft.Extensions.AI (44)
ChatCompletion\AnonymousDelegatingChatClient.cs (7)
29private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
78Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
127public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
134var updates = Channel.CreateBounded<ChatResponseUpdate>(1);
144await foreach (var update in InnerClient.GetStreamingResponseAsync(messages, options, cancellationToken))
187static async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsyncViaGetResponseAsync(Task<ChatResponse> task)
190foreach (var update in response.ToChatResponseUpdates())
Microsoft.Extensions.AI.Abstractions (42)
ChatCompletion\ChatResponseExtensions.cs (23)
17/// Provides extension methods for working with <see cref="ChatResponse"/> and <see cref="ChatResponseUpdate"/> instances.
46/// <param name="updates">The <see cref="ChatResponseUpdate"/> instances to convert to messages and add to the list.</param>
51/// method may use <see cref="ChatResponseUpdate.MessageId"/> to determine message boundaries, as well as coalesce
55public static void AddMessages(this IList<ChatMessage> list, IEnumerable<ChatResponseUpdate> updates)
60if (updates is ICollection<ChatResponseUpdate> { Count: 0 })
70/// <param name="update">The <see cref="ChatResponseUpdate"/> instance to convert to a message and add to the list.</param>
75/// If the <see cref="ChatResponseUpdate"/> has no content, or all its content gets excluded by <paramref name="filter"/>, then
78public static void AddMessages(this IList<ChatMessage> list, ChatResponseUpdate update, Func<AIContent, bool>? filter = null)
98/// <param name="updates">The <see cref="ChatResponseUpdate"/> instances to convert to messages and add to the list.</param>
105/// method may use <see cref="ChatResponseUpdate.MessageId"/> to determine message boundaries, as well as coalesce
110this IList<ChatMessage> list, IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken = default)
118IList<ChatMessage> list, IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken) =>
122/// <summary>Combines <see cref="ChatResponseUpdate"/> instances into a single <see cref="ChatResponse"/>.</summary>
128/// <see cref="ChatMessage"/> instances. This includes using <see cref="ChatResponseUpdate.MessageId"/> to determine
133this IEnumerable<ChatResponseUpdate> updates)
139foreach (var update in updates)
149/// <summary>Combines <see cref="ChatResponseUpdate"/> instances into a single <see cref="ChatResponse"/>.</summary>
156/// <see cref="ChatMessage"/> instances. This includes using <see cref="ChatResponseUpdate.MessageId"/> to determine
161this IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken = default)
168IAsyncEnumerable<ChatResponseUpdate> updates, CancellationToken cancellationToken)
172await foreach (var update in updates.WithCancellation(cancellationToken).ConfigureAwait(false))
303/// <summary>Processes the <see cref="ChatResponseUpdate"/>, incorporating its contents into <paramref name="response"/>.</summary>
306private static void ProcessUpdate(ChatResponseUpdate update, ChatResponse response)
Microsoft.Extensions.AI.Abstractions.Tests (31)
Microsoft.Extensions.AI.AzureAIInference (3)
Microsoft.Extensions.AI.AzureAIInference.Tests (7)
Microsoft.Extensions.AI.Evaluation.Reporting (6)
Microsoft.Extensions.AI.Evaluation.Safety (2)
Microsoft.Extensions.AI.Integration.Tests (16)
Microsoft.Extensions.AI.OpenAI (22)
Microsoft.Extensions.AI.OpenAI.Tests (22)
Microsoft.Extensions.AI.Tests (38)
Microsoft.ML.GenAI.Core (1)
Microsoft.ML.GenAI.LLaMA (1)
Microsoft.ML.GenAI.Phi (1)
Microsoft.ML.GenAI.Samples (2)