29 instantiations of StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatCompletion.cs (2)
117extra = new StreamingChatCompletionUpdate 134updates[choiceIndex] = new StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatClientExtensionsTests.cs (1)
94return YieldAsync([new StreamingChatCompletionUpdate { Text = "world" }]);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (5)
153updates.Add(new() { Text = text }); 174updates.Add(new() { Contents = [new ImageContent("https://uri")] }); 197new() { Text = "Hello, " }, 198new() { Text = "world!" }, 199new() { Contents = [new UsageContent(new() { TotalTokenCount = 42 })] },
ChatCompletion\StreamingChatCompletionUpdateTests.cs (6)
16StreamingChatCompletionUpdate update = new(); 33StreamingChatCompletionUpdate update = new(); 89StreamingChatCompletionUpdate update = new() 118StreamingChatCompletionUpdate update = new() 135StreamingChatCompletionUpdate update = new() 165StreamingChatCompletionUpdate original = new()
Microsoft.Extensions.AI.AzureAIInference (2)
AzureAIInferenceChatClient.cs (2)
170StreamingChatCompletionUpdate completionUpdate = new() 231var completionUpdate = new StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Ollama (1)
OllamaChatClient.cs (1)
152StreamingChatCompletionUpdate update = new()
Microsoft.Extensions.AI.OpenAI (2)
OpenAIChatClient.cs (2)
226StreamingChatCompletionUpdate completionUpdate = new() 320StreamingChatCompletionUpdate completionUpdate = new()
Microsoft.Extensions.AI.Tests (9)
ChatCompletion\ConfigureOptionsChatClientTests.cs (1)
38var expectedUpdates = Enumerable.Range(0, 3).Select(i => new StreamingChatCompletionUpdate()).ToArray();
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
65yield return new StreamingChatCompletionUpdate 73yield return new StreamingChatCompletionUpdate 78yield return new StreamingChatCompletionUpdate
ChatCompletion\UseDelegateChatClientTests.cs (5)
59return YieldUpdates(new StreamingChatCompletionUpdate { Text = "world" }); 141return YieldUpdates(new StreamingChatCompletionUpdate { Text = "hello" }); 162yield return new() { Text = " world" }; 201return YieldUpdates(new StreamingChatCompletionUpdate { Text = "streaming hello" }); 233yield return new() { Text = " world (streaming)" };
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
72yield return new StreamingChatCompletionUpdate
129 references to StreamingChatCompletionUpdate
Microsoft.Extensions.AI (35)
ChatCompletion\AnonymousDelegatingChatClient.cs (7)
28private readonly Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? _completeStreamingFunc; 75Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? completeStreamingFunc) 123public override IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 130var updates = Channel.CreateBounded<StreamingChatCompletionUpdate>(1); 141await foreach (var update in InnerClient.CompleteStreamingAsync(chatMessages, options, cancellationToken).ConfigureAwait(false)) 169static async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsyncViaCompleteAsync(Task<ChatCompletion> task) 172foreach (var update in completion.ToStreamingChatCompletionUpdates())
ChatCompletion\CachingChatClient.cs (11)
67public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 82foreach (var chunk in chatCompletion.ToStreamingChatCompletionUpdates()) 90List<StreamingChatCompletionUpdate> capturedItems = []; 91await foreach (var chunk in base.CompleteStreamingAsync(chatMessages, options, cancellationToken).ConfigureAwait(false)) 107foreach (var chunk in existingChunks) 115List<StreamingChatCompletionUpdate> capturedItems = []; 116await foreach (var chunk in base.CompleteStreamingAsync(chatMessages, options, cancellationToken).ConfigureAwait(false)) 143/// Returns a previously cached list of <see cref="StreamingChatCompletionUpdate"/> values, if available. 149protected abstract Task<IReadOnlyList<StreamingChatCompletionUpdate>?> ReadCacheStreamingAsync(string key, CancellationToken cancellationToken); 162/// Stores a list of <see cref="StreamingChatCompletionUpdate"/> values in the underlying cache. 169protected abstract Task WriteCacheStreamingAsync(string key, IReadOnlyList<StreamingChatCompletionUpdate> value, CancellationToken cancellationToken);
ChatCompletion\ChatClientBuilder.cs (1)
133Func<IList<ChatMessage>, ChatOptions?, IChatClient, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? completeStreamingFunc)
ChatCompletion\ConfigureOptionsChatClient.cs (2)
43public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 46await foreach (var update in base.CompleteStreamingAsync(chatMessages, Configure(options), cancellationToken).ConfigureAwait(false))
ChatCompletion\DistributedCachingChatClient.cs (5)
60protected override async Task<IReadOnlyList<StreamingChatCompletionUpdate>?> ReadCacheStreamingAsync(string key, CancellationToken cancellationToken) 67return (IReadOnlyList<StreamingChatCompletionUpdate>?)JsonSerializer.Deserialize(existingJson, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<StreamingChatCompletionUpdate>))); 85protected override async Task WriteCacheStreamingAsync(string key, IReadOnlyList<StreamingChatCompletionUpdate> value, CancellationToken cancellationToken) 91var newJson = JsonSerializer.SerializeToUtf8Bytes(value, _jsonSerializerOptions.GetTypeInfo(typeof(IReadOnlyList<StreamingChatCompletionUpdate>)));
ChatCompletion\FunctionInvokingChatClient.cs (2)
298public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 312await foreach (var update in base.CompleteStreamingAsync(chatMessages, options, cancellationToken).ConfigureAwait(false))
ChatCompletion\LoggingChatClient.cs (3)
92public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 107IAsyncEnumerator<StreamingChatCompletionUpdate> e; 125StreamingChatCompletionUpdate? update = null;
ChatCompletion\OpenTelemetryChatClient.cs (4)
152public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 164IAsyncEnumerable<StreamingChatCompletionUpdate> updates; 176List<StreamingChatCompletionUpdate> trackedUpdates = []; 182StreamingChatCompletionUpdate update;
Microsoft.Extensions.AI.Abstractions (27)
ChatCompletion\ChatClientExtensions.cs (1)
54public static IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
ChatCompletion\ChatCompletion.cs (5)
110/// <summary>Creates an array of <see cref="StreamingChatCompletionUpdate" /> instances that represent this <see cref="ChatCompletion" />.</summary> 111/// <returns>An array of <see cref="StreamingChatCompletionUpdate" /> instances that may be used to represent this <see cref="ChatCompletion" />.</returns> 112public StreamingChatCompletionUpdate[] ToStreamingChatCompletionUpdates() 114StreamingChatCompletionUpdate? extra = null; 129var updates = new StreamingChatCompletionUpdate[choicesCount + (extra is null ? 0 : 1)];
ChatCompletion\DelegatingChatClient.cs (1)
60public virtual IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(IList<ChatMessage> chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default)
ChatCompletion\IChatClient.cs (1)
51IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
ChatCompletion\StreamingChatCompletionUpdate.cs (6)
22/// <see cref="StreamingChatCompletionUpdate"/> is so named because it represents streaming updates 25/// the same completion may have a <see langword="null"/> <see cref="StreamingChatCompletionUpdate.Role"/> 28/// that one <see cref="StreamingChatCompletionUpdate"/> in a completion has a role of <see cref="ChatRole.Assistant"/> 32/// The relationship between <see cref="ChatCompletion"/> and <see cref="StreamingChatCompletionUpdate"/> is 36/// all have different <see cref="StreamingChatCompletionUpdate.RawRepresentation"/> objects whereas there's 92/// If a <see cref="StreamingChatCompletionUpdate"/> is created to represent some underlying object from another object
ChatCompletion\StreamingChatCompletionUpdateExtensions.cs (11)
20/// Provides extension methods for working with <see cref="StreamingChatCompletionUpdate"/> instances. 24/// <summary>Combines <see cref="StreamingChatCompletionUpdate"/> instances into a single <see cref="ChatCompletion"/>.</summary> 34this IEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent = true) 41foreach (var update in updates) 51/// <summary>Combines <see cref="StreamingChatCompletionUpdate"/> instances into a single <see cref="ChatCompletion"/>.</summary> 62this IAsyncEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent = true, CancellationToken cancellationToken = default) 69IAsyncEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent, CancellationToken cancellationToken) 74await foreach (var update in updates.WithCancellation(cancellationToken).ConfigureAwait(false)) 85/// <summary>Processes the <see cref="StreamingChatCompletionUpdate"/>, incorporating its contents into <paramref name="messages"/> and <paramref name="completion"/>.</summary> 87/// <param name="messages">The dictionary mapping <see cref="StreamingChatCompletionUpdate.ChoiceIndex"/> to the <see cref="ChatMessage"/> being built for that choice.</param> 89private static void ProcessUpdate(StreamingChatCompletionUpdate update, Dictionary<int, ChatMessage> messages, ChatCompletion completion)
Utilities\AIJsonUtilities.Defaults.cs (2)
59[JsonSerializable(typeof(StreamingChatCompletionUpdate))] 60[JsonSerializable(typeof(IReadOnlyList<StreamingChatCompletionUpdate>))]
Microsoft.Extensions.AI.Abstractions.Tests (25)
ChatCompletion\ChatCompletionTests.cs (7)
217StreamingChatCompletionUpdate[] updates = completion.ToStreamingChatCompletionUpdates(); 221StreamingChatCompletionUpdate update0 = updates[0]; 229StreamingChatCompletionUpdate update1 = updates[1]; 267StreamingChatCompletionUpdate[] updates = completion.ToStreamingChatCompletionUpdates(); 271StreamingChatCompletionUpdate update0 = updates[0]; 282StreamingChatCompletionUpdate update1 = updates[1]; 292StreamingChatCompletionUpdate update2 = updates[2];
ChatCompletion\DelegatingChatClientTests.cs (1)
68StreamingChatCompletionUpdate[] expectedResults =
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (7)
21Assert.Throws<ArgumentNullException>("updates", () => ((List<StreamingChatCompletionUpdate>)null!).ToChatCompletion()); 39StreamingChatCompletionUpdate[] updates = 138List<StreamingChatCompletionUpdate> updates = []; 195StreamingChatCompletionUpdate[] updates = 212private static async IAsyncEnumerable<StreamingChatCompletionUpdate> YieldAsync(IEnumerable<StreamingChatCompletionUpdate> updates) 214foreach (StreamingChatCompletionUpdate update in updates)
ChatCompletion\StreamingChatCompletionUpdateTests.cs (7)
16StreamingChatCompletionUpdate update = new(); 33StreamingChatCompletionUpdate update = new(); 89StreamingChatCompletionUpdate update = new() 118StreamingChatCompletionUpdate update = new() 135StreamingChatCompletionUpdate update = new() 165StreamingChatCompletionUpdate original = new() 187StreamingChatCompletionUpdate? result = JsonSerializer.Deserialize(json, TestJsonSerializerContext.Default.StreamingChatCompletionUpdate);
TestChatClient.cs (2)
19public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 26public IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(IList<ChatMessage> chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default)
TestJsonSerializerContext.cs (1)
18[JsonSerializable(typeof(StreamingChatCompletionUpdate))]
Microsoft.Extensions.AI.AzureAIInference (3)
AzureAIInferenceChatClient.cs (3)
145public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 170StreamingChatCompletionUpdate completionUpdate = new() 231var completionUpdate = new StreamingChatCompletionUpdate
Microsoft.Extensions.AI.AzureAIInference.Tests (4)
AzureAIInferenceChatClientTests.cs (4)
201List<StreamingChatCompletionUpdate> updates = []; 202await foreach (var update in client.CompleteStreamingAsync("hello", new() 601List<StreamingChatCompletionUpdate> updates = []; 602await foreach (var update in client.CompleteStreamingAsync("How old is Alice?", new()
Microsoft.Extensions.AI.Integration.Tests (7)
CallCountingChatClient.cs (1)
26public override IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
ChatClientIntegrationTests.cs (4)
85await foreach (var chunk in _chatClient.CompleteStreamingAsync(chatHistory)) 124List<StreamingChatCompletionUpdate> chunks = []; 125await foreach (var chunk in response) 218await foreach (var chunk in response)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (2)
19public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 26public IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(IList<ChatMessage> chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
110public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 152StreamingChatCompletionUpdate update = new()
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
172List<StreamingChatCompletionUpdate> updates = []; 173await foreach (var update in client.CompleteStreamingAsync("hello", new()
Microsoft.Extensions.AI.OpenAI (3)
OpenAIChatClient.cs (3)
199public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 226StreamingChatCompletionUpdate completionUpdate = new() 320StreamingChatCompletionUpdate completionUpdate = new()
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAIChatClientTests.cs (4)
248List<StreamingChatCompletionUpdate> updates = []; 249await foreach (var update in client.CompleteStreamingAsync("hello", new() 752List<StreamingChatCompletionUpdate> updates = []; 753await foreach (var update in client.CompleteStreamingAsync("How old is Alice?", new()
Microsoft.Extensions.AI.Tests (14)
ChatCompletion\ConfigureOptionsChatClientTests.cs (3)
89static async IAsyncEnumerable<StreamingChatCompletionUpdate> YieldUpdates(StreamingChatCompletionUpdate[] updates) 91foreach (var update in updates)
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
57async static IAsyncEnumerable<StreamingChatCompletionUpdate> CallbackAsync(
ChatCompletion\UseDelegateChatClientTests.cs (7)
154static async IAsyncEnumerable<StreamingChatCompletionUpdate> Impl( 157await foreach (var update in innerClient.CompleteStreamingAsync(chatMessages, options, cancellationToken)) 225static async IAsyncEnumerable<StreamingChatCompletionUpdate> Impl( 228await foreach (var update in innerClient.CompleteStreamingAsync(chatMessages, options, cancellationToken)) 247private static async IAsyncEnumerable<StreamingChatCompletionUpdate> YieldUpdates(params StreamingChatCompletionUpdate[] updates) 249foreach (var update in updates)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (2)
19public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 26public IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(IList<ChatMessage> chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default)
TestJsonSerializerContext.cs (1)
15[JsonSerializable(typeof(IReadOnlyList<StreamingChatCompletionUpdate>))]
Microsoft.ML.GenAI.Core (1)
CausalLMPipelineChatClient.cs (1)
57public virtual async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
Microsoft.ML.GenAI.LLaMA (1)
Llama3CausalLMChatClient.cs (1)
46public override IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
Microsoft.ML.GenAI.Phi (1)
Phi3\Phi3CausalLMChatClient.cs (1)
51public override IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(