Skip to content
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

Remove non-AsXx surface area from M.E.AI.OpenAI/AzureAIInference #6138

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Mar 17, 2025

We expect the AsChatClient/AsEmbeddingGenerator extension methods from M.E.AI.OpenAI and M.E.AI.AzureAIInference to move into the OpenAI / Azure.AI.Inference libraries, respectively. To prepare for that, and the temporary M.E.AI.OpenAI/AzureAIInference libs then being deprecated, this PR removes the other surface area from these assemblies. For anything folks found useful, we should find another way to ship it, likely just as sample source somewhere.

Closes #6094
Closes #5965
Closes #5964

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner March 17, 2025 18:09
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Mar 17, 2025
@stephentoub stephentoub enabled auto-merge (squash) March 17, 2025 21:23
@SteveSandersonMS
Copy link
Member

This is certainly all good stuff in general.

Within the GetService implementations, should we also remove the clauses that return this if serviceType.IsInstanceOfType(this)? I'm not sure what use case those clauses would serve now you can't just reference the type directly and can only get it in obscure ways (e.g., by being the second-to-last middleware and passing innerClient.GetType().

We expect the AsChatClient/AsEmbeddingGenerator extension methods from M.E.AI.OpenAI and M.E.AI.AzureAIInference to move into the OpenAI / Azure.AI.Inference libraries, respectively. To prepare for that, and the temporary M.E.AI.OpenAI/AzureAIInference libs then being deprecated, this PR removes the other surface area from these assemblies. For anything folks found useful, we should find another way to ship it, likely just as sample source somewhere.
Only meaningful code changes are deleting the extension methods on OpenAIClient (keeping the ones on ChatClient / EmbeddingClient), and renaming the AsChatClient / AsEmbeddingGenerator extension methods to be AsIChatClient / AsIEmbeddingGenerator. Otherwise, "ChatClient" is confusing with the OpenAI type of the same name.
@stephentoub stephentoub requested review from a team as code owners March 26, 2025 18:24
@stephentoub
Copy link
Member Author

This should be ready to go.

One important note:
I've made two additional changes:

  • Removed the AsChatClient/AsEmbeddingGenerator extensions for the OpenAIClient type, leaving just the ones for OpenAI.Chat.ChatClient and OpenAI.Embeddings.EmbeddingClient. Given what we've seen with OpenAI's move to push folks away from ChatClient and towards ResponseClient, it seems unwise for us to have AsChatClient on OpenAIClient that's bound to the chat completion implementation.
  • Renamed AsChatClient to AsIChatClient and AsEmbeddingGenerator to AsIEmbeddingGenerator. This is to avoid confusion with naming, e.g. having an OpenAI ChatClient have an AsChatClient extension method on it.

cc: @jeffhandley, @SteveSandersonMS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ai Microsoft.Extensions.AI libraries
Projects
None yet
4 participants