mirror of
				https://github.com/MindWorkAI/AI-Studio.git
				synced 2025-11-04 05:40:21 +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)
 | 
					        if (dialogResult.Canceled)
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        var providerInstance = provider.UsedProvider.CreateProvider();
 | 
					        var providerInstance = provider.UsedProvider.CreateProvider(provider.InstanceName);
 | 
				
			||||||
        providerInstance.InstanceName = provider.InstanceName;
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        var deleteSecretResponse = await this.SettingsManager.DeleteAPIKey(this.JsRuntime, providerInstance);
 | 
					        var deleteSecretResponse = await this.SettingsManager.DeleteAPIKey(this.JsRuntime, providerInstance);
 | 
				
			||||||
        if(deleteSecretResponse.Success)
 | 
					        if(deleteSecretResponse.Success)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
				
			|||||||
@ -33,10 +33,11 @@ public static class ExtensionsProvider
 | 
				
			|||||||
    /// Creates a new provider instance based on the provider value.
 | 
					    /// Creates a new provider instance based on the provider value.
 | 
				
			||||||
    /// </summary>
 | 
					    /// </summary>
 | 
				
			||||||
    /// <param name="provider">The provider value.</param>
 | 
					    /// <param name="provider">The provider value.</param>
 | 
				
			||||||
 | 
					    /// <param name="instanceName">The used instance name.</param>
 | 
				
			||||||
    /// <returns>The provider instance.</returns>
 | 
					    /// <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(),
 | 
					        _ => new NoProvider(),
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
				
			|||||||
@ -72,12 +72,10 @@ public partial class ProviderDialog : ComponentBase
 | 
				
			|||||||
        if(this.IsEditing)
 | 
					        if(this.IsEditing)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();
 | 
					            this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();
 | 
				
			||||||
            var provider = this.DataProvider.CreateProvider();
 | 
					            var provider = this.DataProvider.CreateProvider(this.DataInstanceName);
 | 
				
			||||||
            if(provider is NoProvider)
 | 
					            if(provider is NoProvider)
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            provider.InstanceName = this.DataInstanceName;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            // Load the API key:
 | 
					            // Load the API key:
 | 
				
			||||||
            var requestedSecret = await this.SettingsManager.GetAPIKey(this.JsRuntime, provider);
 | 
					            var requestedSecret = await this.SettingsManager.GetAPIKey(this.JsRuntime, provider);
 | 
				
			||||||
            if(requestedSecret.Success)
 | 
					            if(requestedSecret.Success)
 | 
				
			||||||
@ -124,8 +122,7 @@ public partial class ProviderDialog : ComponentBase
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // We need to instantiate the provider to store the API key:
 | 
					        // We need to instantiate the provider to store the API key:
 | 
				
			||||||
        var provider = this.DataProvider.CreateProvider();
 | 
					        var provider = this.DataProvider.CreateProvider(this.DataInstanceName);
 | 
				
			||||||
        provider.InstanceName = this.DataInstanceName;
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        // Store the API key in the OS secure storage:
 | 
					        // Store the API key in the OS secure storage:
 | 
				
			||||||
        var storeResponse = await this.SettingsManager.SetAPIKey(this.JsRuntime, provider, this.dataAPIKey);
 | 
					        var storeResponse = await this.SettingsManager.SetAPIKey(this.JsRuntime, provider, this.dataAPIKey);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user