Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Jul 11, 2025

Internally we have helpers that convert from M.E.AI chat messages to the various OpenAI object models. To ease interop when a developer gets M.E.AI messages from another library and then wants to submit them on their own to OpenAI, this just exposes those helpers publicly.

Microsoft Reviewers: Open in CodeFlow

Internally we have helpers that convert from M.E.AI chat messages to the various OpenAI object models. To ease interop when a developer gets M.E.AI messages from another library and then wants to submit them on their own to OpenAI, this just exposes those helpers publicly.
@stephentoub stephentoub requested a review from a team as a code owner July 11, 2025 20:43
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Jul 11, 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 internal helper methods to convert M.E.AI chat messages into OpenAI SDK types by making them accessible via public extensions and updating existing client implementations.

  • Add public extensions AsOpenAIChatMessages and AsOpenAIResponseItems
  • Change ToOpenAIChatMessages and ToOpenAIResponseItems from private to internal and adjust their signatures
  • Update OpenAIChatClient and OpenAIResponseChatClient to use default JSON options and call the new internal methods
  • Add comprehensive tests for the new extensions; remove a duplicate test file

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs New tests covering AsOpenAIChatMessages and AsOpenAIResponseItems
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIAIFunctionConversionTests.cs Removed redundant conversion tests
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponseChatClient.cs Made ToOpenAIResponseItems internal; added pragma for SA1202
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIClientExtensions.cs Added AsOpenAIChatMessages & AsOpenAIResponseItems extensions
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs Updated ToOpenAIChatMessages signature and removed JSON options parameter
Comments suppressed due to low confidence (1)

src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponseChatClient.cs:20

  • [nitpick] Disabling SA1202 suppresses warnings about element ordering; consider reordering members to follow access-order conventions instead of disabling the rule.
#pragma warning disable SA1202 // Elements should be ordered by access

@stephentoub stephentoub enabled auto-merge (squash) July 11, 2025 21:15
@stephentoub stephentoub merged commit 194d9db into dotnet:main Jul 11, 2025
7 checks passed
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Jul 14, 2025
Internally we have helpers that convert from M.E.AI chat messages to the various OpenAI object models. To ease interop when a developer gets M.E.AI messages from another library and then wants to submit them on their own to OpenAI, this just exposes those helpers publicly.
jeffhandley pushed a commit that referenced this pull request Jul 15, 2025
Internally we have helpers that convert from M.E.AI chat messages to the various OpenAI object models. To ease interop when a developer gets M.E.AI messages from another library and then wants to submit them on their own to OpenAI, this just exposes those helpers publicly.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 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