[QUERY] What is the configuration structure for configuring the `OpenAIClient`?
See original GitHub issueLibrary name and version
Azure.AI.OpenAI 1.0.0-beta.5
Query/Question
I’m currently configuring the OpenAIClient by registering it into DI like this:
builder.Services.AddAzureClients(clientBuilder =>
{
clientBuilder.AddOpenAIClient(
new Uri(builder.Configuration["Azure:OpenAI:Endpoint"]),
new AzureKeyCredential(builder.Configuration["Azure:OpenAI:ApiKey"])
);
});
I know there’s also an overload to pass in configuration like this:
builder.Services.AddAzureClients(clientBuilder =>
{
clientBuilder.AddOpenAIClient(builder.Configuration.GetSection("Azure:OpenAI"));
});
But I don’t know how to configure the Endpoint
and ApiKey
with this overload.
So what should my configuration structure look like to configure it like the first sample?
Ideally, this would work with .NET’s autoreloading configuration, so I can swap API keys without having to restart my application.
Environment
No response
Issue Analytics
- State:
- Created 5 months ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Get started generating text using Azure OpenAI Service
You can experiment with the configuration settings such as temperature and pre-response text to improve the performance of your task.
Read more >Get started using GPT-35-Turbo and GPT-4 with Azure ...
Walkthrough on how to get started with GPT-35-Turbo and GPT-4 on Azure OpenAI Service.
Read more >Building an Azure OpenAI-Powered PDF Question- ...
Configure OpenAI API client. OpenAIClient client = new(new Uri(endpoint), new AzureKeyCredential(key));. Step 3: Load the PDF File and ...
Read more >How to use the Azure OpenAI Embedding model to find ...
This article explains how to use OpenAI's text-embedding-ada-002 model for text embedding to find the most relevant documents at a lower ...
Read more >Beginner's Guide to OpenAI's GPT-3.5-Turbo Model
From GPT-3 to GPT-3.5-Turbo: Understanding the Latest Upgrades in OpenAI's Language Model API.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After looking a bit at this @Swimburger - there are some folks speculating that if you were to configure a section like this:
And then get the section by its name:
Notice that the property names match the parameter names of the corresponding parameterized call, I wonder if that’s how it maps?
Also, see here, as a somewhat related sample: https://learn.microsoft.com/dotnet/azure/sdk/dependency-injection#configure-a-new-retry-policy
Doesnt seem like that overload works unless you have already registered the OpenAIClient with your DI container