mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-05 17:49:05 +00:00
Fixed handling of instance names while provider creation
This commit is contained in:
parent
38b74a0795
commit
2a152880f4
@ -88,9 +88,7 @@ public partial class Settings : ComponentBase
|
||||
if (dialogResult.Canceled)
|
||||
return;
|
||||
|
||||
var providerInstance = provider.UsedProvider.CreateProvider();
|
||||
providerInstance.InstanceName = provider.InstanceName;
|
||||
|
||||
var providerInstance = provider.UsedProvider.CreateProvider(provider.InstanceName);
|
||||
var deleteSecretResponse = await this.SettingsManager.DeleteAPIKey(this.JsRuntime, providerInstance);
|
||||
if(deleteSecretResponse.Success)
|
||||
{
|
||||
|
@ -33,10 +33,11 @@ public static class ExtensionsProvider
|
||||
/// Creates a new provider instance based on the provider value.
|
||||
/// </summary>
|
||||
/// <param name="provider">The provider value.</param>
|
||||
/// <param name="instanceName">The used instance name.</param>
|
||||
/// <returns>The provider instance.</returns>
|
||||
public static IProvider CreateProvider(this Providers provider) => provider switch
|
||||
public static IProvider CreateProvider(this Providers provider, string instanceName) => provider switch
|
||||
{
|
||||
Providers.OPEN_AI => new ProviderOpenAI(),
|
||||
Providers.OPEN_AI => new ProviderOpenAI { InstanceName = instanceName },
|
||||
|
||||
_ => new NoProvider(),
|
||||
};
|
||||
|
@ -72,12 +72,10 @@ public partial class ProviderDialog : ComponentBase
|
||||
if(this.IsEditing)
|
||||
{
|
||||
this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();
|
||||
var provider = this.DataProvider.CreateProvider();
|
||||
var provider = this.DataProvider.CreateProvider(this.DataInstanceName);
|
||||
if(provider is NoProvider)
|
||||
return;
|
||||
|
||||
provider.InstanceName = this.DataInstanceName;
|
||||
|
||||
// Load the API key:
|
||||
var requestedSecret = await this.SettingsManager.GetAPIKey(this.JsRuntime, provider);
|
||||
if(requestedSecret.Success)
|
||||
@ -124,8 +122,7 @@ public partial class ProviderDialog : ComponentBase
|
||||
};
|
||||
|
||||
// We need to instantiate the provider to store the API key:
|
||||
var provider = this.DataProvider.CreateProvider();
|
||||
provider.InstanceName = this.DataInstanceName;
|
||||
var provider = this.DataProvider.CreateProvider(this.DataInstanceName);
|
||||
|
||||
// Store the API key in the OS secure storage:
|
||||
var storeResponse = await this.SettingsManager.SetAPIKey(this.JsRuntime, provider, this.dataAPIKey);
|
||||
|
Loading…
Reference in New Issue
Block a user