// Copyright (c) Microsoft. All rights reserved. #pragma warning disable OPENAI001 // Experimental OpenAI features using System.ClientModel; using OpenAI.Chat; namespace Microsoft.Agents.AI.OpenAI; internal sealed class AsyncStreamingChatCompletionUpdateCollectionResult : AsyncCollectionResult { private readonly IAsyncEnumerable _updates; internal AsyncStreamingChatCompletionUpdateCollectionResult(IAsyncEnumerable updates) { this._updates = updates; } public override ContinuationToken? GetContinuationToken(ClientResult page) => null; public override async IAsyncEnumerable GetRawPagesAsync() { yield return ClientResult.FromValue(this._updates, new StreamingUpdatePipelineResponse(this._updates)); } protected override IAsyncEnumerable GetValuesFromPageAsync(ClientResult page) { var updates = ((ClientResult>)page).Value; return updates.AsChatResponseUpdatesAsync().AsOpenAIStreamingChatCompletionUpdatesAsync(); } }