-
Notifications
You must be signed in to change notification settings - Fork 827
Add more openai conversion helpers #6662
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 adds several OpenAI conversion helper methods to enable bidirectional conversion between Microsoft.Extensions.AI types and OpenAI types. The changes enhance interoperability by providing methods to convert chat messages, responses, and completions in both directions.
Key changes include:
- Added conversion methods for ChatMessage collections to/from OpenAI types
- Added conversion from ChatResponse to OpenAI ChatCompletion
- Refactored common conversion logic into shared helper methods
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
OpenAIConversionTests.cs |
Comprehensive test coverage for new conversion methods including edge cases and error handling |
OpenAIResponsesChatClient.cs |
Refactored message conversion logic into reusable methods and improved raw representation handling |
OpenAIClientExtensions.cs |
Added shared helper methods for parsing function call content from JSON |
OpenAIChatClient.cs |
Enhanced content conversion methods and improved raw representation processing |
OpenAIAssistantsChatClient.cs |
Updated to use new shared function call parsing methods |
MicrosoftExtensionsAIResponsesExtensions.cs |
Added new extension methods for converting between response types |
MicrosoftExtensionsAIChatExtensions.cs |
Added comprehensive bidirectional conversion methods for chat messages and completions |
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
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIChatExtensions.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIResponsesExtensions.cs
Show resolved
Hide resolved
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.
LGTM
Microsoft Reviewers: Open in CodeFlow