-
Notifications
You must be signed in to change notification settings - Fork 840
Expose response format conversions for OpenAI types #6806
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
Conversation
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 response format conversions for OpenAI types by adding public extension methods to convert Microsoft.Extensions.AI response formats to OpenAI-specific format types. This enables ChatResponseFormat.ForJsonSchema<T> to be used with OpenAI response format properties.
Key changes:
- Added public extension methods for converting between Microsoft.Extensions.AI and OpenAI response format types
- Refactored existing internal conversion logic into reusable internal static methods
- Added comprehensive test coverage for the new conversion methods
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| MicrosoftExtensionsAIChatExtensions.cs | Added public extension method to convert ChatResponseFormat to OpenAI ChatResponseFormat |
| MicrosoftExtensionsAIResponsesExtensions.cs | Added public extension method to convert ChatResponseFormat to OpenAI ResponseTextFormat |
| OpenAIChatClient.cs | Refactored response format conversion logic into reusable internal static method |
| OpenAIResponsesChatClient.cs | Refactored response format conversion logic into reusable internal static method |
| OpenAIConversionTests.cs | Added comprehensive tests for both new conversion extension methods |
| CHANGELOG.md | Added entry documenting the new response format conversion functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs
Outdated
Show resolved
Hide resolved
5def8e3 to
ac4a543
Compare
Primarily to enable
ChatResponseFormat.ForJsonSchema<T>to be used with the OpenAI response format propertiesMicrosoft Reviewers: Open in CodeFlow