Allow settings explicit minimum confidence level

This commit is contained in:
Thorsten Sommer 2026-01-29 07:55:02 +01:00
parent 3aae3a98fa
commit 7db68ea6d5
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -20,6 +20,9 @@ public partial class ProviderSelection : MSGComponentBase
[Parameter] [Parameter]
public Func<AIStudio.Settings.Provider, string?> ValidateProvider { get; set; } = _ => null; public Func<AIStudio.Settings.Provider, string?> ValidateProvider { get; set; } = _ => null;
[Parameter]
public ConfidenceLevel ExplicitMinimumConfidence { get; set; } = ConfidenceLevel.UNKNOWN;
[Inject] [Inject]
private ILogger<ProviderSelection> Logger { get; init; } = null!; private ILogger<ProviderSelection> Logger { get; init; } = null!;
@ -44,7 +47,15 @@ public partial class ProviderSelection : MSGComponentBase
yield break; yield break;
case { } component: case { } component:
// Get the minimum confidence level for this component, and/or the global minimum if enforced:
var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(component); var minimumLevel = this.SettingsManager.GetMinimumConfidenceLevel(component);
// Override with the explicit minimum level if set and higher:
if (this.ExplicitMinimumConfidence is not ConfidenceLevel.UNKNOWN && this.ExplicitMinimumConfidence > minimumLevel)
minimumLevel = this.ExplicitMinimumConfidence;
// Filter providers based on the minimum confidence level:
foreach (var provider in this.SettingsManager.ConfigurationData.Providers) foreach (var provider in this.SettingsManager.ConfigurationData.Providers)
if (provider.UsedLLMProvider != LLMProviders.NONE) if (provider.UsedLLMProvider != LLMProviders.NONE)
if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel) if (provider.UsedLLMProvider.GetConfidence(this.SettingsManager).Level >= minimumLevel)
@ -52,4 +63,4 @@ public partial class ProviderSelection : MSGComponentBase
break; break;
} }
} }
} }