diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor index 71f0e618..a4ad15f7 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor @@ -45,12 +45,21 @@ } - @if (context.IsEnterpriseConfiguration) + @if (context.IsEnterpriseConfiguration && !context.AllowUserProvidedAPIKey) { } + else if (context.IsEnterpriseConfiguration && context.AllowUserProvidedAPIKey) + { + + + + + + + } else { diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs index f7b88c14..dd74f949 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelEmbeddings.razor.cs @@ -73,6 +73,9 @@ public partial class SettingsPanelEmbeddings : SettingsPanelProviderBase private async Task EditEmbeddingProvider(EmbeddingProvider embeddingProvider) { + if (embeddingProvider.IsEnterpriseConfiguration && !embeddingProvider.AllowUserProvidedAPIKey) + return; + var dialogParameters = new DialogParameters { { x => x.DataNum, embeddingProvider.Num }, @@ -84,6 +87,7 @@ public partial class SettingsPanelEmbeddings : SettingsPanelProviderBase { x => x.IsSelfHosted, embeddingProvider.IsSelfHosted }, { x => x.IsEditing, true }, { x => x.DataHost, embeddingProvider.Host }, + { x => x.IsEnterpriseConfiguration, embeddingProvider.IsEnterpriseConfiguration }, }; var dialogReference = await this.DialogService.ShowAsync(T("Edit Embedding Provider"), dialogParameters, DialogOptions.FULLSCREEN); @@ -91,6 +95,16 @@ public partial class SettingsPanelEmbeddings : SettingsPanelProviderBase if (dialogResult is null || dialogResult.Canceled) return; + if (embeddingProvider.IsEnterpriseConfiguration) + { + // Only the API key changed, and the dialog already stored it directly. The provider + // object itself is managed by the configuration plugin and must not be overwritten + // with the dialog's copy -- doing so would let the locked-but-technically-editable + // fields drift from what the organization configured. + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + return; + } + var editedEmbeddingProvider = (EmbeddingProvider)dialogResult.Data!; // Set the provider number if it's not set. This is important for providers diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor index 93d22ba1..40ec1a82 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor @@ -41,12 +41,18 @@ } - @if (context.IsEnterpriseConfiguration) + @if (context.IsEnterpriseConfiguration && !context.AllowUserProvidedAPIKey) { } + else if (context.IsEnterpriseConfiguration && context.AllowUserProvidedAPIKey) + { + + + + } else { diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor.cs b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor.cs index 25e3120b..4d8daa15 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor.cs +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelTranscription.razor.cs @@ -72,6 +72,9 @@ public partial class SettingsPanelTranscription : SettingsPanelProviderBase private async Task EditTranscriptionProvider(TranscriptionProvider transcriptionProvider) { + if (transcriptionProvider.IsEnterpriseConfiguration && !transcriptionProvider.AllowUserProvidedAPIKey) + return; + var dialogParameters = new DialogParameters { { x => x.DataNum, transcriptionProvider.Num }, @@ -83,13 +86,24 @@ public partial class SettingsPanelTranscription : SettingsPanelProviderBase { x => x.IsSelfHosted, transcriptionProvider.IsSelfHosted }, { x => x.IsEditing, true }, { x => x.DataHost, transcriptionProvider.Host }, + { x => x.IsEnterpriseConfiguration, transcriptionProvider.IsEnterpriseConfiguration }, }; - + var dialogReference = await this.DialogService.ShowAsync(T("Edit Transcription Provider"), dialogParameters, DialogOptions.FULLSCREEN); var dialogResult = await dialogReference.Result; if (dialogResult is null || dialogResult.Canceled) return; - + + if (transcriptionProvider.IsEnterpriseConfiguration) + { + // Only the API key changed, and the dialog already stored it directly. The provider + // object itself is managed by the configuration plugin and must not be overwritten + // with the dialog's copy -- doing so would let the locked-but-technically-editable + // fields drift from what the organization configured. + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); + return; + } + var editedTranscriptionProvider = (TranscriptionProvider)dialogResult.Data!; // Set the provider number if it's not set. This is important for providers