38 instantiations of StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Abstractions (2)
ChatCompletion\ChatCompletion.cs (2)
127extra = new StreamingChatCompletionUpdate 144updates[choiceIndex] = new StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatClientExtensionsTests.cs (1)
94return YieldAsync([new StreamingChatCompletionUpdate { Text = "world" }]);
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (5)
156updates.Add(new() { Text = text }); 177updates.Add(new() { Contents = [new DataContent("https://uri", mediaType: "image/png")] }); 200new() { Text = "Hello, " }, 201new() { Text = "world!" }, 202new() { 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)
155StreamingChatCompletionUpdate update = new()
Microsoft.Extensions.AI.OpenAI (4)
OpenAIAssistantClient.cs (2)
120yield return new() 136StreamingChatCompletionUpdate ruUpdate = new()
OpenAIModelMappers.StreamingChatCompletion.cs (2)
89StreamingChatCompletionUpdate completionUpdate = new() 167StreamingChatCompletionUpdate completionUpdate = new()
Microsoft.Extensions.AI.OpenAI.Tests (4)
OpenAISerializationTests.cs (4)
629yield return new StreamingChatCompletionUpdate 681yield return new StreamingChatCompletionUpdate(); 698yield return new StreamingChatCompletionUpdate(); 735yield return new StreamingChatCompletionUpdate
Microsoft.Extensions.AI.Tests (12)
ChatCompletion\ConfigureOptionsChatClientTests.cs (1)
38var expectedUpdates = Enumerable.Range(0, 3).Select(i => new StreamingChatCompletionUpdate()).ToArray();
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
538new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId1", "Func1", new Dictionary<string, object?> { ["text"] = "Input 1" })] }, 539new StreamingChatCompletionUpdate { Contents = [new FunctionCallContent("callId2", "Func1", new Dictionary<string, object?> { ["text"] = "Input 2" })] }) 541new StreamingChatCompletionUpdate { Contents = [new TextContent("OK bye")] });
ChatCompletion\OpenTelemetryChatClientTests.cs (3)
72yield return new StreamingChatCompletionUpdate 80yield return new StreamingChatCompletionUpdate 85yield 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
143 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)
325public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 342await 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)
154public override async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 166IAsyncEnumerable<StreamingChatCompletionUpdate> updates; 178List<StreamingChatCompletionUpdate> trackedUpdates = []; 184StreamingChatCompletionUpdate update;
Microsoft.Extensions.AI.Abstractions (28)
ChatCompletion\ChatClientExtensions.cs (2)
72public static IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 90public static IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
ChatCompletion\ChatCompletion.cs (5)
120/// <summary>Creates an array of <see cref="StreamingChatCompletionUpdate" /> instances that represent this <see cref="ChatCompletion" />.</summary> 121/// <returns>An array of <see cref="StreamingChatCompletionUpdate" /> instances that may be used to represent this <see cref="ChatCompletion" />.</returns> 122public StreamingChatCompletionUpdate[] ToStreamingChatCompletionUpdates() 124StreamingChatCompletionUpdate? extra = null; 139var updates = new StreamingChatCompletionUpdate[choicesCount + (extra is null ? 0 : 1)];
ChatCompletion\DelegatingChatClient.cs (1)
47public 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)
21/// Provides extension methods for working with <see cref="StreamingChatCompletionUpdate"/> instances. 25/// <summary>Combines <see cref="StreamingChatCompletionUpdate"/> instances into a single <see cref="ChatCompletion"/>.</summary> 35this IEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent = true) 42foreach (var update in updates) 52/// <summary>Combines <see cref="StreamingChatCompletionUpdate"/> instances into a single <see cref="ChatCompletion"/>.</summary> 63this IAsyncEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent = true, CancellationToken cancellationToken = default) 70IAsyncEnumerable<StreamingChatCompletionUpdate> updates, bool coalesceContent, CancellationToken cancellationToken) 75await foreach (var update in updates.WithCancellation(cancellationToken).ConfigureAwait(false)) 86/// <summary>Processes the <see cref="StreamingChatCompletionUpdate"/>, incorporating its contents into <paramref name="messages"/> and <paramref name="completion"/>.</summary> 88/// <param name="messages">The dictionary mapping <see cref="StreamingChatCompletionUpdate.ChoiceIndex"/> to the <see cref="ChatMessage"/> being built for that choice.</param> 90private static void ProcessUpdate(StreamingChatCompletionUpdate update, Dictionary<int, ChatMessage> messages, ChatCompletion completion)
Utilities\AIJsonUtilities.Defaults.cs (2)
86[JsonSerializable(typeof(StreamingChatCompletionUpdate))] 87[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)
59StreamingChatCompletionUpdate[] expectedResults =
ChatCompletion\StreamingChatCompletionUpdateExtensionsTests.cs (7)
21Assert.Throws<ArgumentNullException>("updates", () => ((List<StreamingChatCompletionUpdate>)null!).ToChatCompletion()); 39StreamingChatCompletionUpdate[] updates = 141List<StreamingChatCompletionUpdate> updates = []; 198StreamingChatCompletionUpdate[] updates = 215private static async IAsyncEnumerable<StreamingChatCompletionUpdate> YieldAsync(IEnumerable<StreamingChatCompletionUpdate> updates) 217foreach (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)
22public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 32public 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)
221List<StreamingChatCompletionUpdate> updates = []; 222await foreach (var update in client.CompleteStreamingAsync(chatMessages, new() 856List<StreamingChatCompletionUpdate> updates = []; 857await 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)
84await foreach (var chunk in _chatClient.CompleteStreamingAsync(chatHistory)) 123List<StreamingChatCompletionUpdate> chunks = []; 124await foreach (var chunk in response) 228await foreach (var chunk in response)
test\Libraries\Microsoft.Extensions.AI.Abstractions.Tests\TestChatClient.cs (2)
22public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 32public IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(IList<ChatMessage> chatMessages, ChatOptions? options = null, CancellationToken cancellationToken = default)
Microsoft.Extensions.AI.Ollama (2)
OllamaChatClient.cs (2)
116public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 155StreamingChatCompletionUpdate update = new()
Microsoft.Extensions.AI.Ollama.Tests (2)
OllamaChatClientTests.cs (2)
173List<StreamingChatCompletionUpdate> updates = []; 174await foreach (var update in client.CompleteStreamingAsync("hello", new()
Microsoft.Extensions.AI.OpenAI (9)
OpenAIAssistantClient.cs (2)
77public async IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync( 136StreamingChatCompletionUpdate ruUpdate = new()
OpenAIChatClient.cs (1)
117public IAsyncEnumerable<StreamingChatCompletionUpdate> CompleteStreamingAsync(
OpenAIModelMappers.StreamingChatCompletion.cs (5)
22IAsyncEnumerable<StreamingChatCompletionUpdate> chatCompletions, 26await foreach (var chatCompletionUpdate in chatCompletions.WithCancellation(cancellationToken).ConfigureAwait(false)) 64public static async IAsyncEnumerable<StreamingChatCompletionUpdate> FromOpenAIStreamingChatCompletionAsync( 89StreamingChatCompletionUpdate completionUpdate = new() 167StreamingChatCompletionUpdate completionUpdate = new()
OpenAISerializationHelpers.cs (1)
71IAsyncEnumerable<StreamingChatCompletionUpdate> streamingChatCompletionUpdates,
Microsoft.Extensions.AI.OpenAI.Tests (8)
OpenAIChatClientTests.cs (4)
270List<StreamingChatCompletionUpdate> updates = []; 271await foreach (var update in client.CompleteStreamingAsync("hello", new() 872List<StreamingChatCompletionUpdate> updates = []; 873await foreach (var update in client.CompleteStreamingAsync("How old is Alice?", new()
OpenAISerializationTests.cs (4)
590static async IAsyncEnumerable<StreamingChatCompletionUpdate> CreateStreamingCompletion() 679static async IAsyncEnumerable<StreamingChatCompletionUpdate> GetStreamingChatCompletion() 696static async IAsyncEnumerable<StreamingChatCompletionUpdate> GetStreamingChatCompletion() 733async IAsyncEnumerable<StreamingChatCompletionUpdate> GetStreamingCompletion()
Microsoft.Extensions.AI.Tests (17)
ChatCompletion\ConfigureOptionsChatClientTests.cs (3)
89static async IAsyncEnumerable<StreamingChatCompletionUpdate> YieldUpdates(StreamingChatCompletionUpdate[] updates) 91foreach (var update in updates)
ChatCompletion\FunctionInvokingChatClientTests.cs (2)
547var updates = new List<StreamingChatCompletionUpdate>(); 548await foreach (var update in client.CompleteStreamingAsync(messages, options, CancellationToken.None))
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
64async static IAsyncEnumerable<StreamingChatCompletionUpdate> CallbackAsync( 141await foreach (var update in chatClient.CompleteStreamingAsync(chatMessages, options))
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)
22public Func<IList<ChatMessage>, ChatOptions?, CancellationToken, IAsyncEnumerable<StreamingChatCompletionUpdate>>? CompleteStreamingAsyncCallback { get; set; } 32public 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(