StreamingChatCompletionUpdateExtensions.ToChatCompletionAsync Method

Definition

Combines StreamingChatCompletionUpdate instances into a single ChatCompletion.

public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion> ToChatCompletionAsync (this System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.StreamingChatCompletionUpdate> updates, bool coalesceContent = true, System.Threading.CancellationToken cancellationToken = default);
static member ToChatCompletionAsync : System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.StreamingChatCompletionUpdate> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatCompletion>
<Extension()>
Public Function ToChatCompletionAsync (updates As IAsyncEnumerable(Of StreamingChatCompletionUpdate), Optional coalesceContent As Boolean = true, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatCompletion)

Parameters

updates
IAsyncEnumerable<StreamingChatCompletionUpdate>

The updates to be combined.

coalesceContent
Boolean

true to attempt to coalesce contiguous AIContent items, where applicable, into a single AIContent, in order to reduce the number of individual content items that are included in the manufactured ChatMessage instances. When false, the original content items are used. The default is true.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The combined ChatCompletion.

Applies to