Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Jul 21, 2025

We're already exposing the non-streaming response conversions. Expose the streaming ones as well.

Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 13:39
@stephentoub stephentoub requested a review from a team as a code owner July 21, 2025 13:39
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Jul 21, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR exposes streaming conversion utility methods for both OpenAI Chat and Responses APIs, mirroring the existing non-streaming conversion methods. The changes primarily add public extension methods to convert streaming OpenAI responses to Microsoft.Extensions.AI types.

  • Adds AsChatResponseUpdatesAsync methods to both chat and responses extension classes
  • Updates existing conversion methods to accept optional ChatOptions parameters
  • Modifies visibility of internal streaming conversion methods to support the new public APIs

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
MicrosoftExtensionsAIChatExtensions.cs Adds streaming chat completion conversion method and updates existing method signatures
MicrosoftExtensionsAIResponsesExtensions.cs Adds streaming response conversion method and updates existing method signatures
OpenAIChatClient.cs Changes visibility of streaming conversion method from private to internal
OpenAIResponsesChatClient.cs Refactors streaming logic and changes method visibility to support new public APIs
OpenAIConversionTests.cs Adds comprehensive tests for the new streaming conversion methods
Comments suppressed due to low confidence (2)

test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs:288

  • The test method AsChatResponse_ConvertsOpenAIResponse only validates null argument handling but doesn't test the actual conversion logic due to OpenAI library limitations. Consider using mocking or test doubles to provide meaningful test coverage.
        // The OpenAI library currently doesn't provide any way to create an OpenAIResponse instance,

test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs:297

  • The test method AsChatResponseUpdatesAsync_ConvertsOpenAIStreamingResponseUpdates only validates null argument handling but doesn't test the actual streaming conversion logic. Consider using mocking or test doubles to provide comprehensive test coverage for the streaming functionality.
        // The OpenAI library currently doesn't provide any way to create a StreamingResponseUpdate instance,

@stephentoub stephentoub enabled auto-merge (squash) July 24, 2025 20:54
We're already exposing the non-streaming response conversions. Expose the streaming ones as well.
@stephentoub stephentoub merged commit 11e16a9 into dotnet:main Jul 31, 2025
6 checks passed
This was referenced Aug 14, 2025
This was referenced Aug 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants