using AIStudio.Provider; using Microsoft.AspNetCore.Components; namespace AIStudio.Components; public partial class ConfigurationMinConfidenceSelection : MSGComponentBase { /// /// The selected value. /// [Parameter] public Func SelectedValue { get; set; } = () => default!; /// /// An action that is called when the selection changes. /// [Parameter] public Action SelectionUpdate { get; set; } = _ => { }; /// /// Is the selection component disabled? /// [Parameter] public Func Disabled { get; set; } = () => false; /// /// Boolean value indicating whether the selection is restricted to a global minimum confidence level. /// [Parameter] public bool RestrictToGlobalMinimumConfidence { get; set; } private ConfidenceLevel FilteredSelectedValue() { if (this.SelectedValue() is ConfidenceLevel.NONE) return ConfidenceLevel.NONE; if(this.RestrictToGlobalMinimumConfidence && this.SettingsManager.ConfigurationData.LLMProviders.EnforceGlobalMinimumConfidence) { var minimumLevel = this.SettingsManager.ConfigurationData.LLMProviders.GlobalMinimumConfidence; if(this.SelectedValue() < minimumLevel) return minimumLevel; } return this.SelectedValue(); } }