using AIStudio.Components;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Assistants.ModelComparison;
///
/// The summary of a finished batch, with the names of the models: the votes of the user and the verdicts of the judge
/// in total, and every run on its own.
///
public partial class ModelComparisonBatchSummary : MSGComponentBase
{
///
/// Gets or sets the finished batch.
///
[Parameter, EditorRequired]
public ModelComparisonBatch Batch { get; set; } = null!;
///
/// Gets or sets whether a judge took part in the batch.
///
[Parameter]
public bool JudgeEnabled { get; set; }
///
/// Gets or sets what happens when the user wants to start over with the request.
///
[Parameter]
public EventCallback StartNewBatch { get; set; }
///
/// Gets or sets what happens when the user wants to see the results of all comparisons.
///
[Parameter]
public EventCallback OpenResults { get; set; }
///
/// The votes of the user in total, counted once per render.
///
private ModelComparisonTally voteTally = ModelComparisonTally.NONE;
///
/// The verdicts of the judge in total, or null without a judge.
///
private ModelComparisonTally? judgeTally;
#region Overrides of ComponentBase
protected override void OnParametersSet()
{
this.voteTally = this.Batch.TallyVotes();
this.judgeTally = this.JudgeEnabled ? this.Batch.TallyJudgeVerdicts() : null;
base.OnParametersSet();
}
#endregion
private string Heading => this.Batch.RunCount > 1
? string.Format(ModelComparisonFormat.Culture, T("All {0} runs are done."), this.Batch.RunCount)
: T("Done.");
}