語言

ChatResponseExtensions.ToChatResponseAsync 方法

定義

將多個實例合併 ChatResponseUpdate 成一個 ChatResponse。

public static System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse> ToChatResponseAsync(this System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.ChatResponseUpdate> updates, System.Threading.CancellationToken cancellationToken = default);
static member ToChatResponseAsync : System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.ChatResponseUpdate> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Extensions.AI.ChatResponse>
<Extension()>
Public Function ToChatResponseAsync (updates As IAsyncEnumerable(Of ChatResponseUpdate), Optional cancellationToken As CancellationToken = Nothing) As Task(Of ChatResponse)

參數

updates
IAsyncEnumerable<ChatResponseUpdate>

這些更新將合併。

cancellationToken
CancellationToken

CancellationToken他們需要監控取消申請。 預設值為 None。

傳回

合併 ChatResponse後的 .

例外狀況

updates 是 null。

備註

作為合併 updates 為單一 ChatResponse的一部分,該方法將嘗試重建 ChatMessage 實例。 這包括用來 MessageId 確定訊息邊界,以及在適用時合併連續 AIContent 項目,例如連續多個 TextContent 實例可以合併成一個 TextContent。

適用於