AI-Studio/app/MindWork AI Studio/Components/ConfidenceInfo.razor.cs

53 lines
1.4 KiB
C#
Raw Normal View History

2024-09-11 21:08:02 +00:00
using AIStudio.Provider;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
2025-04-27 07:06:05 +00:00
public partial class ConfidenceInfo : MSGComponentBase
2024-09-11 21:08:02 +00:00
{
[Parameter]
public PopoverTriggerMode Mode { get; set; } = PopoverTriggerMode.BUTTON;
2024-09-11 21:08:02 +00:00
[Parameter]
public LLMProviders LLMProvider { get; set; }
2024-09-11 21:08:02 +00:00
private Confidence currentConfidence;
private bool showConfidence;
public ConfidenceInfo()
{
this.currentConfidence = LLMProviders.NONE.GetConfidence(this.SettingsManager);
2024-09-11 21:08:02 +00:00
}
#region Overrides of ComponentBase
protected override async Task OnParametersSetAsync()
{
this.currentConfidence = this.LLMProvider.GetConfidence(this.SettingsManager);
2024-09-11 21:08:02 +00:00
await base.OnParametersSetAsync();
}
#endregion
private void ToggleConfidence()
{
this.showConfidence = !this.showConfidence;
}
private void HideConfidence()
{
this.showConfidence = false;
}
private IEnumerable<(string Index, string Source)> GetConfidenceSources()
{
var index = 0;
foreach (var source in this.currentConfidence.Sources)
yield return ($"Source {++index}", source);
}
private string GetCurrentConfidenceColor() => $"color: {this.currentConfidence.Level.GetColor(this.SettingsManager)};";
2025-03-12 18:12:56 +00:00
private string GetPopoverStyle() => $"border-color: {this.currentConfidence.Level.GetColor(this.SettingsManager)};";
2024-09-11 21:08:02 +00:00
}