| 
									
										
										
										
											2024-09-14 17:20:33 +00:00
										 |  |  | using AIStudio.Provider; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using Microsoft.AspNetCore.Components; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace AIStudio.Components; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-27 07:06:05 +00:00
										 |  |  | public partial class ConfigurationMinConfidenceSelection : MSGComponentBase | 
					
						
							| 
									
										
										
										
											2024-09-14 17:20:33 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// The selected value. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     [Parameter] | 
					
						
							|  |  |  |     public Func<ConfidenceLevel> SelectedValue { get; set; } = () => default!; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// An action that is called when the selection changes. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     [Parameter] | 
					
						
							|  |  |  |     public Action<ConfidenceLevel> SelectionUpdate { get; set; } = _ => { }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// <summary> | 
					
						
							|  |  |  |     /// Boolean value indicating whether the selection is restricted to a global minimum confidence level. | 
					
						
							|  |  |  |     /// </summary> | 
					
						
							|  |  |  |     [Parameter] | 
					
						
							|  |  |  |     public bool RestrictToGlobalMinimumConfidence { get; set; } | 
					
						
							| 
									
										
										
										
											2025-08-09 17:29:43 +00:00
										 |  |  |      | 
					
						
							|  |  |  |     [Parameter] | 
					
						
							|  |  |  |     public Func<bool> Disabled { get; set; } = () => false; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     [Parameter] | 
					
						
							|  |  |  |     public Func<bool> IsLocked { get; set; } = () => false; | 
					
						
							| 
									
										
										
										
											2024-09-14 17:20:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     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(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |