Working with Multiple Instances abnormal #287
Replies: 5 comments 3 replies
-
Could you please share the above part of the code? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks, I'll have a look at this, most probably today evening. |
Beta Was this translation helpful? Give feedback.
-
On the other hand,Is there an error in the Configuration Settings in your example: |
Beta Was this translation helpful? Give feedback.
-
I just test this It worked without any issues. Sorry, but I can't tell what is wrong with your code. It may be a typo issue or environment. (I made slight typo update on wiki page but nothing is major) using LaserCatEyes.HttpClientListener;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using OpenAI.Managers;
using OpenAI;
using OpenAI.Extensions;
using Microsoft.Extensions.Configuration;
var host = new HostBuilder()
.ConfigureAppConfiguration(configurationBuilder =>
{
configurationBuilder.AddUserSecrets<Program>();
})
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
services.AddOpenAIService<MyOpenAIService>(MyOpenAIService.SettingKey);
services.AddOpenAIService<MyAzureOpenAIService>(MyAzureOpenAIService.SettingKey);
services.AddLaserCatEyesHttpClientListener();
})
.Build();
host.Run();
public class MyOpenAIService : OpenAIService
{
public const string SettingKey = "MyOpenAIService";
[ActivatorUtilitiesConstructor]
public MyOpenAIService(HttpClient httpClient, IOptionsSnapshot<OpenAiOptions> settings) : base(settings.Get(SettingKey), httpClient) { }
public MyOpenAIService(OpenAiOptions settings, HttpClient? httpClient = null) : base(settings, httpClient) { }
}
public class MyAzureOpenAIService : OpenAIService
{
public const string SettingKey = "MyAzureOpenAIService";
[ActivatorUtilitiesConstructor]
public MyAzureOpenAIService(HttpClient httpClient, IOptionsSnapshot<OpenAiOptions> settings) : base(settings.Get(SettingKey), httpClient) { }
public MyAzureOpenAIService(OpenAiOptions settings, HttpClient? httpClient = null) : base(settings, httpClient) { }
} User Secret: {
"OpenAIServiceOptions": {
"MyOpenAIService": {
"ApiKey": "sk-J**Q",
"Organization": "org-**I"
},
"MyAzureOpenAIService": {
"ApiKey": "**",
"DeploymentId": "**",
"ResourceName": "**",
"ProviderType": "Azure"
}
},
"LaserCatEyesOptions": {
"Appkey": "d**7"
}
} |
Beta Was this translation helpful? Give feedback.
-
I updated to version 7.0.0 and used Working with Multiple Instances,Following exactly your example,The following exception occurred:
Beta Was this translation helpful? Give feedback.
All reactions