-
Notifications
You must be signed in to change notification settings - Fork 821
Expose streaming conversion utility methods #6636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
We're already exposing the non-streaming response conversions. Expose the streaming ones as well.
There was a problem hiding this 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,
internal static IEnumerable<ResponseItem> ToOpenAIResponseItems(IEnumerable<ChatMessage> inputs, ChatOptions? options) | ||
{ | ||
_ = options; // currently unused | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment indicates that the options
parameter is currently unused. Consider either implementing the options handling or removing the parameter if it's not needed yet.
internal static IEnumerable<ResponseItem> ToOpenAIResponseItems(IEnumerable<ChatMessage> inputs, ChatOptions? options) | |
{ | |
_ = options; // currently unused | |
internal static IEnumerable<ResponseItem> ToOpenAIResponseItems(IEnumerable<ChatMessage> inputs) | |
{ |
Copilot uses AI. Check for mistakes.
We're already exposing the non-streaming response conversions. Expose the streaming ones as well.
Microsoft Reviewers: Open in CodeFlow