135 instantiations of ChatResponseUpdate
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
628new()
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatResponse.cs (2)
113extra = new ChatResponseUpdate 131updates[i] = new ChatResponseUpdate
Microsoft.Extensions.AI.Abstractions.Tests (73)
ChatCompletion\ChatClientExtensionsTests.cs (1)
146return YieldAsync([new ChatResponseUpdate(ChatRole.Assistant, "world")]);
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 })] },
ChatCompletion\ChatResponseUpdateTests.cs (4)
16ChatResponseUpdate update = new(); 33ChatResponseUpdate update = new(); 87ChatResponseUpdate update = new() 115ChatResponseUpdate original = new()
ChatCompletion\DelegatingChatClientTests.cs (2)
61new(ChatRole.User, "Message 1"), 62new(ChatRole.User, "Message 2")
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceChatClient.cs (2)
165ChatResponseUpdate responseUpdate = new() 220var responseUpdate = new ChatResponseUpdate
Microsoft.Extensions.AI.Evaluation.Safety (1)
ContentSafetyChatClient.cs (1)
100yield return new ChatResponseUpdate(ChatRole.Assistant, annotationResult)
Microsoft.Extensions.AI.OpenAI (6)
OpenAIAssistantsChatClient.cs (3)
168ChatResponseUpdate ruUpdate = new() 204ChatResponseUpdate textUpdate = new(mcu.Role == MessageRole.User ? ChatRole.User : ChatRole.Assistant, mcu.Text) 253yield return new()
OpenAIChatClient.cs (2)
349ChatResponseUpdate responseUpdate = new() 416ChatResponseUpdate responseUpdate = new()
OpenAIResponsesChatClient.cs (1)
245new(lastRole, content is not null ? [content] : null)
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\ConfigureOptionsChatClientTests.cs (1)
38var expectedUpdates = Enumerable.Range(0, 3).Select(i => new ChatResponseUpdate()).ToArray();
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")]);
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (7)
643yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = messageId }; 646new ChatResponseUpdate( 716yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 1")]) { MessageId = messageId }; 718yield return new ChatResponseUpdate(ChatRole.Assistant, [new TextContent("Text 2")]) { MessageId = messageId }; 720yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func1")]) { MessageId = messageId }; 722yield return new ChatResponseUpdate( 729yield return new ChatResponseUpdate(ChatRole.Assistant, [new FunctionCallContent("callId1", "Func3")]) { MessageId = messageId };
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
760new() { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 761new() { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] } 766updates = [new() { Contents = [new TextContent("OK bye")] }];
ChatCompletion\LoggingChatClientTests.cs (2)
108yield return new(ChatRole.Assistant, "blue "); 109yield return new(ChatRole.Assistant, "whale");
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
69yield return new ChatResponseUpdate(ChatRole.Assistant, text) 75yield return new ChatResponseUpdate 80yield return new ChatResponseUpdate
ChatCompletion\ReducingChatClientTests.cs (2)
50var expectedUpdates = new[] { new ChatResponseUpdate(ChatRole.Assistant, "It's"), new ChatResponseUpdate(null, " sunny!") };
ChatCompletion\UseDelegateChatClientTests.cs (5)
51return YieldUpdates(new ChatResponseUpdate(null, "world")); 133return YieldUpdates(new ChatResponseUpdate(null, "hello")); 154yield return new(null, " world"); 193return YieldUpdates(new ChatResponseUpdate(null, "streaming hello")); 225yield return new(null, " world (streaming)");
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
73yield return new(ChatRole.Assistant, output)
240 references to ChatResponseUpdate
Aspire.Dashboard (2)
Model\Assistant\AIHelpers.cs (2)
360await foreach (var update in response.WithCancellation(responseCts.Token).ConfigureAwait(false)) 391public static IList<ChatMessage> GetMessages(ChatResponseUpdate update, Func<AIContent, bool>? filter = null)
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())
ChatCompletion\CachingChatClient.cs (12)
74public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 84private async IAsyncEnumerable<ChatResponseUpdate> GetCachedStreamingResponseAsync( 97foreach (var chunk in chatResponse.ToChatResponseUpdates()) 105List<ChatResponseUpdate> capturedItems = []; 106await foreach (var chunk in base.GetStreamingResponseAsync(messages, options, cancellationToken)) 123foreach (var chunk in existingChunks) 132List<ChatResponseUpdate> capturedItems = []; 133await foreach (var chunk in base.GetStreamingResponseAsync(messages, options, cancellationToken)) 163/// Returns a previously cached list of <see cref="ChatResponseUpdate"/> values, if available. 170protected abstract Task<IReadOnlyList<ChatResponseUpdate>?> ReadCacheStreamingAsync(string key, CancellationToken cancellationToken); 185/// Stores a list of <see cref="ChatResponseUpdate"/> values in the underlying cache. 194protected abstract Task WriteCacheStreamingAsync(string key, IReadOnlyList<ChatResponseUpdate> value, CancellationToken cancellationToken);
ChatCompletion\ChatClientBuilder.cs (1)
144Func<IEnumerable<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? getStreamingResponseFunc)
ChatCompletion\ConfigureOptionsChatClient.cs (2)
42public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 45await foreach (var update in base.GetStreamingResponseAsync(messages, Configure(options), cancellationToken))
ChatCompletion\DistributedCachingChatClient.cs (6)
24/// the object models used by <see cref="ChatMessage"/>, <see cref="ChatOptions"/>, <see cref="ChatResponse"/>, <see cref="ChatResponseUpdate"/>, 89protected override async Task<IReadOnlyList<ChatResponseUpdate>?> ReadCacheStreamingAsync(string key, CancellationToken cancellationToken) 96return (IReadOnlyList<ChatResponseUpdate>?)JsonSerializer.Deserialize(existingJson, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<ChatResponseUpdate>))); 114protected override async Task WriteCacheStreamingAsync(string key, IReadOnlyList<ChatResponseUpdate> value, CancellationToken cancellationToken) 120var newJson = JsonSerializer.SerializeToUtf8Bytes(value, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<ChatResponseUpdate>)));
ChatCompletion\DistributedCachingChatClientBuilderExtensions.cs (1)
29/// the object models used by <see cref="ChatMessage"/>, <see cref="ChatOptions"/>, <see cref="ChatResponse"/>, <see cref="ChatResponseUpdate"/>,
ChatCompletion\FunctionInvokingChatClient.cs (6)
412public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 432List<ChatResponseUpdate> updates = []; // updates from the current response 498await foreach (var update in base.GetStreamingResponseAsync(messages, options, cancellationToken)) 502Throw.InvalidOperationException($"The inner {nameof(IChatClient)} streamed a null {nameof(ChatResponseUpdate)}."); 566var updateToYield = updates[lastYieldedUpdateIndex]; 627private static ChatResponseUpdate ConvertToolResultMessageToUpdate(ChatMessage message, string? conversationId, string? messageId) =>
ChatCompletion\LoggingChatClient.cs (3)
100public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 115IAsyncEnumerator<ChatResponseUpdate> e; 133ChatResponseUpdate? update = null;
ChatCompletion\OpenTelemetryChatClient.cs (4)
160public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 172IAsyncEnumerable<ChatResponseUpdate> updates; 184List<ChatResponseUpdate> trackedUpdates = []; 190ChatResponseUpdate update;
ChatCompletion\ReducingChatClient.cs (2)
40public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 45await foreach (var update in base.GetStreamingResponseAsync(messages, options, cancellationToken).ConfigureAwait(false))
Microsoft.Extensions.AI.Abstractions (42)
ChatCompletion\ChatClientExtensions.cs (2)
131public static IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 151public static IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
ChatCompletion\ChatResponse.cs (5)
106/// <summary>Creates an array of <see cref="ChatResponseUpdate" /> instances that represent this <see cref="ChatResponse" />.</summary> 107/// <returns>An array of <see cref="ChatResponseUpdate" /> instances that may be used to represent this <see cref="ChatResponse" />.</returns> 108public ChatResponseUpdate[] ToChatResponseUpdates() 110ChatResponseUpdate? extra = null; 125var updates = new ChatResponseUpdate[messageCount + (extra is not null ? 1 : 0)];
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)
ChatCompletion\ChatResponseUpdate.cs (8)
17/// <see cref="ChatResponseUpdate"/> is so named because it represents updates 22/// The relationship between <see cref="ChatResponse"/> and <see cref="ChatResponseUpdate"/> is 41/// <summary>Initializes a new instance of the <see cref="ChatResponseUpdate"/> class.</summary> 47/// <summary>Initializes a new instance of the <see cref="ChatResponseUpdate"/> class.</summary> 55/// <summary>Initializes a new instance of the <see cref="ChatResponseUpdate"/> class.</summary> 91/// If a <see cref="ChatResponseUpdate"/> is created to represent some underlying object from another object 112/// This value is used when <see cref="ChatResponseExtensions.ToChatResponseAsync(IAsyncEnumerable{ChatResponseUpdate}, System.Threading.CancellationToken)"/> 113/// groups <see cref="ChatResponseUpdate"/> instances into <see cref="ChatMessage"/> instances.
ChatCompletion\DelegatingChatClient.cs (1)
48public virtual IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
ChatCompletion\IChatClient.cs (1)
54IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
Utilities\AIJsonUtilities.Defaults.cs (2)
83[JsonSerializable(typeof(ChatResponseUpdate))] 84[JsonSerializable(typeof(IReadOnlyList<ChatResponseUpdate>))]
Microsoft.Extensions.AI.Abstractions.Tests (31)
ChatCompletion\ChatClientExtensionsTests.cs (4)
151await foreach (var update in client.GetStreamingResponseAsync("hello", expectedOptions, cts.Token)) 161private static async IAsyncEnumerable<ChatResponseUpdate> YieldAsync(params ChatResponseUpdate[] updates) 164foreach (var update in updates)
ChatCompletion\ChatResponseTests.cs (7)
139ChatResponseUpdate[] updates = response.ToChatResponseUpdates(); 143ChatResponseUpdate update0 = updates[0]; 152ChatResponseUpdate update1 = updates[1]; 181ChatResponseUpdate[] updates = response.ToChatResponseUpdates(); 185ChatResponseUpdate update0 = updates[0]; 194ChatResponseUpdate update1 = updates[1]; 203ChatResponseUpdate update2 = updates[2];
ChatCompletion\ChatResponseUpdateExtensionsTests.cs (11)
20Assert.Throws<ArgumentNullException>("updates", () => ((List<ChatResponseUpdate>)null!).ToChatResponse()); 28ChatResponseUpdate[] updates = 72ChatResponseUpdate[] updates = 128ChatResponseUpdate[] updates = 206List<ChatResponseUpdate> updates = []; 267ChatResponseUpdate[] updates = 305ChatResponseUpdate[] updates = 345ChatResponseUpdate[] updates = 362private static async IAsyncEnumerable<ChatResponseUpdate> YieldAsync(IEnumerable<ChatResponseUpdate> updates) 364foreach (ChatResponseUpdate update in updates)
ChatCompletion\ChatResponseUpdateTests.cs (5)
16ChatResponseUpdate update = new(); 33ChatResponseUpdate update = new(); 87ChatResponseUpdate update = new() 115ChatResponseUpdate original = new() 137ChatResponseUpdate? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.ChatResponseUpdate);
ChatCompletion\DelegatingChatClientTests.cs (1)
59ChatResponseUpdate[] expectedResults =
TestChatClient.cs (2)
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; } 32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
TestJsonSerializerContext.cs (1)
18[JsonSerializable(typeof(ChatResponseUpdate))]
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
140public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 165ChatResponseUpdate responseUpdate = new() 220var responseUpdate = new ChatResponseUpdate
Microsoft.Extensions.AI.AzureAIInference.Tests (7)
AzureAIInferenceChatClientTests.cs (7)
221List<ChatResponseUpdate> updates = []; 222await foreach (var update in client.GetStreamingResponseAsync(messages, new() 272await foreach (var update in client.GetStreamingResponseAsync("hello", new ChatOptions 453await foreach (var update in client.GetStreamingResponseAsync("hello", chatOptions)) 611await foreach (var update in client.GetStreamingResponseAsync("hello", chatOptions)) 1335List<ChatResponseUpdate> updates = []; 1336await foreach (var update in client.GetStreamingResponseAsync("How old is Alice?", new()
Microsoft.Extensions.AI.Evaluation.Reporting (6)
ResponseCachingChatClient.cs (3)
64protected override async Task<IReadOnlyList<ChatResponseUpdate>?> ReadCacheStreamingAsync( 70IReadOnlyList<ChatResponseUpdate>? updates = 122IReadOnlyList<ChatResponseUpdate> value,
SimpleChatClient.cs (3)
58public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 63List<ChatResponseUpdate>? updates = null; 68await foreach (ChatResponseUpdate update in
Microsoft.Extensions.AI.Evaluation.Safety (2)
ContentSafetyChatClient.cs (2)
83public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 109await foreach (var update in
Microsoft.Extensions.AI.Integration.Tests (16)
CallCountingChatClient.cs (1)
26public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
ChatClientIntegrationTests.cs (11)
107await foreach (var chunk in ChatClient.GetStreamingResponseAsync(chatHistory)) 142List<ChatResponseUpdate> chunks = []; 143await foreach (var chunk in response) 272await foreach (var chunk in response) 683await foreach (var update in chatClient.GetStreamingResponseAsync([message])) 692await foreach (var update in chatClient.GetStreamingResponseAsync([message])) 703await foreach (var update in chatClient.GetStreamingResponseAsync([message])) 861await foreach (var update in chatClient.GetStreamingResponseAsync("What's the biggest animal?")) 912await foreach (var update in chatClient.GetStreamingResponseAsync( 1283await foreach (var chunk in chatClient.GetStreamingResponseAsync(messages)) 1385public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
PromptBasedFunctionCallingChatClient.cs (2)
137public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 141foreach (var update in response.ToChatResponseUpdates())
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (2)
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; } 32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.OpenAI (22)
MicrosoftExtensionsAIChatExtensions.cs (7)
124/// sequence of <see cref="ChatResponseUpdate"/> instances. 128/// <returns>A sequence of converted <see cref="ChatResponseUpdate"/> instances.</returns> 131this IAsyncEnumerable<ChatResponseUpdate> responseUpdates, [EnumeratorCancellation] CancellationToken cancellationToken = default) 135await foreach (var update in responseUpdates.WithCancellation(cancellationToken).ConfigureAwait(false)) 251/// Creates a sequence of Microsoft.Extensions.AI <see cref="ChatResponseUpdate"/> instances from the specified 257/// <returns>A sequence of converted <see cref="ChatResponseUpdate"/> instances.</returns> 259public static IAsyncEnumerable<ChatResponseUpdate> AsChatResponseUpdatesAsync(
MicrosoftExtensionsAIResponsesExtensions.cs (3)
57/// Creates a sequence of Microsoft.Extensions.AI <see cref="ChatResponseUpdate"/> instances from the specified 63/// <returns>A sequence of converted <see cref="ChatResponseUpdate"/> instances.</returns> 65public static IAsyncEnumerable<ChatResponseUpdate> AsChatResponseUpdatesAsync(
OpenAIAssistantsChatClient.cs (3)
73public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 168ChatResponseUpdate ruUpdate = new() 204ChatResponseUpdate textUpdate = new(mcu.Role == MessageRole.User ? ChatRole.User : ChatRole.Assistant, mcu.Text)
OpenAIChatClient.cs (4)
98public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 325internal static async IAsyncEnumerable<ChatResponseUpdate> FromOpenAIStreamingChatCompletionAsync( 349ChatResponseUpdate responseUpdate = new() 416ChatResponseUpdate responseUpdate = new()
OpenAIResponsesChatClient.cs (5)
215public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync( 230internal static async IAsyncEnumerable<ChatResponseUpdate> FromOpenAIStreamingResponseUpdatesAsync( 244ChatResponseUpdate CreateUpdate(AIContent? content = null) => 266var update = CreateUpdate(ToUsageDetails(completedUpdate.Response) is { } usage ? new UsageContent(usage) : null); 300var mcpUpdate = CreateUpdate();
Microsoft.Extensions.AI.OpenAI.Tests (22)
OpenAIChatClientTests.cs (6)
232List<ChatResponseUpdate> updates = []; 233await foreach (var update in client.GetStreamingResponseAsync("hello", new() 494await foreach (var update in client.GetStreamingResponseAsync("hello", chatOptions)) 649await foreach (var update in client.GetStreamingResponseAsync("hello", chatOptions)) 1322List<ChatResponseUpdate> updates = []; 1323await foreach (var update in client.GetStreamingResponseAsync("How old is Alice?", new()
OpenAIConversionTests.cs (12)
316List<ChatResponseUpdate> updates = []; 317await foreach (var update in CreateUpdates().AsChatResponseUpdatesAsync()) 617var asyncEnumerable = ((IAsyncEnumerable<ChatResponseUpdate>)null!).AsOpenAIStreamingChatCompletionUpdatesAsync(); 624var updates = new List<ChatResponseUpdate>(); 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")
OpenAIResponseClientTests.cs (4)
292List<ChatResponseUpdate> updates = []; 293await foreach (var update in client.GetStreamingResponseAsync("Calculate the sum of the first 5 positive integers.", new() 429List<ChatResponseUpdate> updates = []; 430await foreach (var update in client.GetStreamingResponseAsync("hello", new()
Microsoft.Extensions.AI.Tests (38)
ChatCompletion\ConfigureOptionsChatClientTests.cs (3)
89static async IAsyncEnumerable<ChatResponseUpdate> YieldUpdates(ChatResponseUpdate[] updates) 91foreach (var update in updates)
ChatCompletion\DistributedCachingChatClientTest.cs (13)
247List<ChatResponseUpdate> actualUpdate = 260List<ChatResponseUpdate> expectedCachedResponse = 311List<ChatResponseUpdate> expectedResponse = 344ChatResponseUpdate update = Assert.Single(await ToListAsync(result2)); 366List<ChatResponseUpdate> expectedResponse = 416var item = Assert.Single(items); 434List<ChatResponseUpdate> expectedResponse = 482return ToAsyncEnumerableAsync<ChatResponseUpdate>(Task.CompletedTask, 521return ToAsyncEnumerableAsync<ChatResponseUpdate>( 833private static async Task AssertResponsesEqualAsync(IReadOnlyList<ChatResponseUpdate> expected, IAsyncEnumerable<ChatResponseUpdate> actual) 837foreach (var expectedItem in expected) 841var actualItem = actualEnumerator.Current;
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (4)
635async IAsyncEnumerable<ChatResponseUpdate> YieldInnerClientUpdates( 660await foreach (var update in updates) 708async IAsyncEnumerable<ChatResponseUpdate> YieldInnerClientUpdates( 738await foreach (var update in updates)
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
754List<ChatResponseUpdate> updates; 769foreach (var update in updates)
ChatCompletion\LoggingChatClientTests.cs (2)
105static async IAsyncEnumerable<ChatResponseUpdate> GetUpdatesAsync() 117await foreach (var update in client.GetStreamingResponseAsync(
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
61async static IAsyncEnumerable<ChatResponseUpdate> CallbackAsync( 143await foreach (var update in chatClient.GetStreamingResponseAsync(messages, options))
ChatCompletion\ReducingChatClientTests.cs (2)
72var updates = new List<ChatResponseUpdate>(); 73await foreach (var update in client.GetStreamingResponseAsync(originalMessages))
ChatCompletion\UseDelegateChatClientTests.cs (7)
146static async IAsyncEnumerable<ChatResponseUpdate> Impl( 149await foreach (var update in innerClient.GetStreamingResponseAsync(messages, options, cancellationToken)) 217static async IAsyncEnumerable<ChatResponseUpdate> Impl( 220await foreach (var update in innerClient.GetStreamingResponseAsync(messages, options, cancellationToken)) 239private static async IAsyncEnumerable<ChatResponseUpdate> YieldUpdates(params ChatResponseUpdate[] updates) 241foreach (var update in updates)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (2)
22public Func<IEnumerable<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<ChatResponseUpdate>>? GetStreamingResponseAsyncCallback { get; set; } 32public IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(IEnumerable<ChatMessage> messages, ChatOptions? options = null, CancellationToken cancellationToken = default)
TestJsonSerializerContext.cs (1)
15[JsonSerializable(typeof(IReadOnlyList<ChatResponseUpdate>))]
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
57public virtual async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
Microsoft.ML.GenAI.LLaMA (1)
Llama3CausalLMChatClient.cs (1)
46public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
Microsoft.ML.GenAI.Phi (1)
Phi3\Phi3CausalLMChatClient.cs (1)
51public override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
Microsoft.ML.GenAI.Samples (2)
MEAI\Llama3_1.cs (1)
49await foreach (var response in client.GetStreamingResponseAsync([chatMessage]))
MEAI\Phi3.cs (1)
39await foreach (var response in client.GetStreamingResponseAsync([chatMessage]))