Added a way for organizations to prohibit providers (#1105)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-22 18:57:12 +02:00
1 parent 052868b24e
commit 7ba5f01388
38 files changed
+1488 -629

No files matched your search

@@ -105,7 +105,7 @@ public partial class SettingsPanelApp : SettingsPanelBase
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(Tools.Components.APP_SETTINGS);
foreach (var provider in this.SettingsManager.GetAllTranscriptionProviders())
{
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
if (this.SettingsManager.IsProviderUsable(provider.UsedLLMProvider, minimumLevel))
yield return new(provider.Name, provider.Id);
}
}
@@ -39,9 +39,15 @@
</MudTd>
<MudTd>
<MudMarkdown Value="@context.GetConfidence(this.SettingsManager).Description" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE"/>
@if (this.SettingsManager.IsProviderProhibited(context))
{
<MudAlert Severity="Severity.Warning" Dense="@true" Class="mt-2">
@T("The use of this provider has been prohibited by your organization. Therefore, it is untrusted, and you cannot change its confidence level.")
</MudAlert>
}
</MudTd>
<MudTd Style="vertical-align: top;">
<MudMenu StartIcon="@Icons.Material.Filled.Security" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.GetCurrentConfidenceLevelName(context)" Variant="Variant.Filled" Style="@this.SetCurrentConfidenceLevelColorStyle(context)" Disabled="@this.IsCustomConfidenceSchemeLocked()">
<MudMenu StartIcon="@Icons.Material.Filled.Security" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" Label="@this.GetCurrentConfidenceLevelName(context)" Variant="Variant.Filled" Style="@this.SetCurrentConfidenceLevelColorStyle(context)" Disabled="@this.IsConfidenceLevelLocked(context)">
@foreach (var confidenceLevel in Enum.GetValues<ConfidenceLevel>().OrderBy(n => n))
{
if(confidenceLevel is ConfidenceLevel.NONE or ConfidenceLevel.UNKNOWN)
@@ -7,30 +7,51 @@ public partial class SettingsPanelConfidence : SettingsPanelBase
{
private string GetCurrentConfidenceLevelName(LLMProviders llmProvider)
{
if (this.SettingsManager.ConfigurationData.Confidence.CustomConfidenceScheme.TryGetValue(llmProvider, out var level))
if (this.TryGetShownConfidenceLevel(llmProvider, out var level))
return level.GetName();
return T("Not yet configured");
}
private string SetCurrentConfidenceLevelColorStyle(LLMProviders llmProvider)
{
if (this.SettingsManager.ConfigurationData.Confidence.CustomConfidenceScheme.TryGetValue(llmProvider, out var level))
if (this.TryGetShownConfidenceLevel(llmProvider, out var level))
return $"background-color: {level.GetColor(this.SettingsManager)};";
return $"background-color: {ConfidenceLevel.UNKNOWN.GetColor(this.SettingsManager)};";
}
/// <summary>
/// Determines the confidence level the table shows for a provider.
/// </summary>
/// <remarks>
/// A prohibited provider is untrusted, whatever level was chosen for it, see
/// SettingsManager.GetConfiguredConfidenceLevel. The chosen level stays stored, so the table
/// shows it again once the prohibition ends.
/// </remarks>
private bool TryGetShownConfidenceLevel(LLMProviders llmProvider, out ConfidenceLevel level)
{
if (this.SettingsManager.IsProviderProhibited(llmProvider))
{
level = ConfidenceLevel.UNTRUSTED;
return true;
}
return this.SettingsManager.ConfigurationData.Confidence.CustomConfidenceScheme.TryGetValue(llmProvider, out level);
}
private bool IsCustomConfidenceSchemeLocked()
{
return ManagedConfiguration.TryGet(x => x.Confidence, x => x.CustomConfidenceScheme, out var meta) && meta.IsLocked;
}
private bool IsConfidenceLevelLocked(LLMProviders llmProvider) => this.IsCustomConfidenceSchemeLocked() || this.SettingsManager.IsProviderProhibited(llmProvider);
private async Task ChangeCustomConfidenceLevel(LLMProviders llmProvider, ConfidenceLevel level)
{
if (this.IsCustomConfidenceSchemeLocked())
if (this.IsConfidenceLevelLocked(llmProvider))
return;
this.SettingsManager.ConfigurationData.Confidence.CustomConfidenceScheme[llmProvider] = level;
await this.SettingsManager.StoreSettings();
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
@@ -44,6 +44,12 @@
<MudTd>
<MudStack Row="true" Class="mb-2 mt-2" Spacing="1" Wrap="Wrap.Wrap">
@if (this.SettingsManager.IsProviderProhibited(context.UsedLLMProvider))
{
<MudTooltip Text="@T("The use of this embedding provider has been prohibited by your organization.")">
<MudIconButton Color="Color.Error" Icon="@Icons.Material.Filled.Block" Disabled="true"/>
</MudTooltip>
}
@if (context.IsTrustedForDataSourceSecurityChecks(this.SettingsManager))
{
<MudTooltip Text="@(context.IsSelfHosted ? T("This self-hosted embedding provider is trusted for data source security checks. Local data can be sent to it without security warnings.") : T("This embedding provider is trusted by your organization for data source security checks. Local data can be sent to it without security warnings."))">
@@ -62,7 +68,7 @@
<MudIconButton Color="Color.Info" Icon="@Icons.Material.Filled.Key" OnClick="@(() => this.EditEmbeddingProvider(context))"/>
</MudTooltip>
<MudTooltip Text="@T("Test")">
<MudIconButton Color="Color.Info" Icon="@Icons.Material.Filled.Api" OnClick="@(() => this.TestEmbeddingProvider(context))"/>
<MudIconButton Color="Color.Info" Icon="@Icons.Material.Filled.Api" OnClick="@(() => this.TestEmbeddingProvider(context))" Disabled="@this.SettingsManager.IsProviderProhibited(context.UsedLLMProvider)"/>
</MudTooltip>
}
else
@@ -78,7 +84,7 @@
<MudIconButton Color="Color.Error" Icon="@Icons.Material.Filled.Delete" OnClick="@(() => this.DeleteEmbeddingProvider(context))"/>
</MudTooltip>
<MudTooltip Text="@T("Test")">
<MudIconButton Color="Color.Info" Icon="@Icons.Material.Filled.Api" OnClick="@(() => this.TestEmbeddingProvider(context))"/>
<MudIconButton Color="Color.Info" Icon="@Icons.Material.Filled.Api" OnClick="@(() => this.TestEmbeddingProvider(context))" Disabled="@this.SettingsManager.IsProviderProhibited(context.UsedLLMProvider)"/>
</MudTooltip>
}
</MudStack>
@@ -36,6 +36,12 @@
<MudTd>@this.GetLLMProviderModelName(context)</MudTd>
<MudTd>
<MudStack Row="true" Class="mb-2 mt-2" Spacing="1" Wrap="Wrap.Wrap">
@if (this.SettingsManager.IsProviderProhibited(context.UsedLLMProvider))
{
<MudTooltip Text="@T("The use of this provider has been prohibited by your organization.")">
<MudIconButton Color="Color.Error" Icon="@Icons.Material.Filled.Block" Disabled="true"/>
</MudTooltip>
}
@if (context.IsTrustedForDataSourceSecurityChecks(this.SettingsManager))
{
<MudTooltip Text="@(context.IsSelfHosted ? T("This self-hosted provider is trusted for data source security checks.") : T("This provider is trusted by your organization for data source security checks."))">
@@ -41,6 +41,12 @@
<MudTd>
<MudStack Row="true" Class="mb-2 mt-2" Spacing="1" Wrap="Wrap.Wrap">
@if (this.SettingsManager.IsProviderProhibited(context.UsedLLMProvider))
{
<MudTooltip Text="@T("The use of this transcription provider has been prohibited by your organization.")">
<MudIconButton Color="Color.Error" Icon="@Icons.Material.Filled.Block" Disabled="true"/>
</MudTooltip>
}
@if (context.IsTrustedForDataSourceSecurityChecks(this.SettingsManager))
{
<MudTooltip Text="@(context.IsSelfHosted ? T("This self-hosted transcription provider is trusted for data source security checks.") : T("This transcription provider is trusted by your organization for data source security checks."))">