49 instantiations of ChatResponseUpdate
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (2)
Microsoft.Extensions.AI.Abstractions.Tests (26)
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (21)
107updates.Add(new(null, text));
128updates.Add(new() { Contents = [new DataContent("data:image/png;base64,aGVsbG8=")] });
155new(null, "A"),
156new(null, "B"),
157new(null, "C"),
158new() { Contents = [new TextReasoningContent("D")] },
159new() { Contents = [new TextReasoningContent("E")] },
160new() { Contents = [new TextReasoningContent("F")] },
161new(null, "G"),
162new(null, "H"),
163new() { Contents = [new TextReasoningContent("I")] },
164new() { Contents = [new TextReasoningContent("J")] },
165new(null, "K"),
166new() { Contents = [new TextReasoningContent("L")] },
167new(null, "M"),
168new(null, "N"),
169new() { Contents = [new TextReasoningContent("O")] },
170new() { Contents = [new TextReasoningContent("P")] },
191new(null, "Hello, "),
192new(null, "world!"),
193new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
Microsoft.Extensions.AI.AzureAIInference (2)
Microsoft.Extensions.AI.Evaluation.Safety (1)
Microsoft.Extensions.AI.Ollama (1)
Microsoft.Extensions.AI.OpenAI (4)
Microsoft.Extensions.AI.Tests (11)
Microsoft.ML.GenAI.Core (1)
179 references to ChatResponseUpdate
Microsoft.Extensions.AI (43)
ChatCompletion\AnonymousDelegatingChatClient.cs (10)
31private readonly Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? _getStreamingResponseFunc;
80Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
129public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
136var updates = Channel.CreateBounded<ChatResponseUpdate>(1);
146await foreach (var update in InnerClient.GetStreamingResponseAsync(messages, options, cancellationToken))
167static async IAsyncEnumerable<ChatResponseUpdate> ReadAllAsync(
168ChannelReader<ChatResponseUpdate> channel, [EnumeratorCancellation] CancellationToken cancellationToken)
172while (channel.TryRead(out var update))
189static async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsyncViaGetResponseAsync(Task<ChatResponse> task)
192foreach (var update in response.ToChatResponseUpdates())
Microsoft.Extensions.AI.Abstractions (42)
ChatCompletion\ChatResponseExtensions.cs (23)
18/// Provides extension methods for working with <see cref="ChatResponse"/> and <see cref="ChatResponseUpdate"/> instances.
47/// <param name="updates">The <see cref="ChatResponseUpdate"/> instances to convert to messages and add to the list.</param>
52/// method may use <see cref="ChatResponseUpdate.MessageId"/> to determine message boundaries, as well as coalesce
56public static void AddMessages(this IList<ChatMessage> list, IEnumerable<ChatResponseUpdate> updates)
61if (updates is ICollection<ChatResponseUpdate> { Count: 0 })
71/// <param name="update">The <see cref="ChatResponseUpdate"/> instance to convert to a message and add to the list.</param>
76/// If the <see cref="ChatResponseUpdate"/> has no content, or all its content gets excluded by <paramref name="filter"/>, then
79public 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))
249/// <summary>Processes the <see cref="ChatResponseUpdate"/>, incorporating its contents into <paramref name="response"/>.</summary>
252private static void ProcessUpdate(ChatResponseUpdate update, ChatResponse response)
Microsoft.Extensions.AI.Abstractions.Tests (20)
Microsoft.Extensions.AI.AzureAIInference (3)
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
Microsoft.Extensions.AI.Evaluation.Reporting (6)
Microsoft.Extensions.AI.Evaluation.Safety (2)
Microsoft.Extensions.AI.Integration.Tests (10)
Microsoft.Extensions.AI.Ollama (2)
Microsoft.Extensions.AI.Ollama.Tests (2)
Microsoft.Extensions.AI.OpenAI (5)
Microsoft.Extensions.AI.OpenAI.Tests (6)
Microsoft.Extensions.AI.Tests (31)
Microsoft.ML.GenAI.Core (1)
Microsoft.ML.GenAI.LLaMA (1)
Microsoft.ML.GenAI.Phi (1)