dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.63k stars 408 forks source link

Allowing multiple Azure OpenAI clients #5332

Closed adanbrownpaca closed 1 week ago

adanbrownpaca commented 3 weeks ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe the problem.

Because certain models are only available in certain regions in Azure, I have a need to have multiple Azure AI clients on my project. Dall-e models are only available in EAST US, while GTP40 in EASTUS2, etc. At the moment, only one client with one connection string can be created for dependency injection.

Describe the solution you'd like

Basically similar solution to registering HttpClients on the project. You define your class with the right client. Any other solution is fine by me.

Additional context

No response

davidfowl commented 3 weeks ago

You can call AddKeyedAzureOpenAIClient and pass a name, then used KeyedServices to resolve the client

adanbrownpaca commented 3 weeks ago

Thanks David. Will give it a shot! If this is a solution, we can close this issue.