- Notifications
You must be signed in to change notification settings - Fork845
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIChatExtensions.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Libraries/Microsoft.Extensions.AI.OpenAI/MicrosoftExtensionsAIResponsesExtensions.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
rogerbarreto left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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
65c679b intodotnet:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Microsoft Reviewers:Open in CodeFlow