Dela via


OpenAISerializationHelpers.SerializeStreamingAsync Method

Definition

Serializes a Microsoft.Extensions.AI streaming response using the OpenAI wire format.

public static System.Threading.Tasks.Task SerializeStreamingAsync(System.IO.Stream stream, System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.ChatResponseUpdate> updates, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member SerializeStreamingAsync : System.IO.Stream * System.Collections.Generic.IAsyncEnumerable<Microsoft.Extensions.AI.ChatResponseUpdate> * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function SerializeStreamingAsync (stream As Stream, updates As IAsyncEnumerable(Of ChatResponseUpdate), Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

stream
Stream

The stream to write the value.

updates
IAsyncEnumerable<ChatResponseUpdate>

The chat response updates to serialize.

options
JsonSerializerOptions

The JsonSerializerOptions governing function call content serialization.

cancellationToken
CancellationToken

A token used to cancel the serialization operation.

Returns

A task tracking the serialization operation.

Applies to