using AIStudio.Components;
using Microsoft.AspNetCore.Components;
namespace AIStudio.Assistants.ModelComparison;
///
/// What the judge of a comparison series said about a decided task, or why it said nothing.
///
///
/// Shown only after the decision of the user, so that the judge cannot anchor it. The judge names the chats as the
/// user saw them, "Chat 1" and "Chat 2", never a model.
///
public partial class ModelComparisonSeriesVerdict : MSGComponentBase
{
///
/// Gets or sets the decided task.
///
[Parameter, EditorRequired]
public ModelComparisonSeriesTask SeriesTask { get; set; } = null!;
///
/// Gets or sets the number of the task in its series, from 1.
///
[Parameter, EditorRequired]
public int TaskNumber { get; set; }
///
/// Gets or sets whether the judge reads the chats of the task right now.
///
[Parameter]
public bool IsJudging { get; set; }
///
/// Gets or sets what happens when the user asks the judge again, e.g., after a judge without a usable verdict.
///
[Parameter]
public EventCallback AskJudge { get; set; }
///
/// Names the chat the judge preferred, and says whether that matches the decision of the user.
///
private string VerdictText
{
get
{
var vote = this.SeriesTask.Vote;
if (this.SeriesTask.JudgeChoice is not { } judgeChoice)
return string.Empty;
if (judgeChoice is ModelComparisonModelChoice.TIE)
return vote is ModelComparisonModelChoice.TIE
? TA("The judge found both chats equally helpful, as you did.")
: TA("The judge found both chats equally helpful, while you preferred one of them.");
var chatNumber = this.SeriesTask.ChatNumberOf(judgeChoice);
var text = vote switch
{
ModelComparisonModelChoice.TIE => TA("The judge preferred chat {0}, while you found both chats equally helpful."),
{ } chosen when chosen == judgeChoice => TA("The judge preferred chat {0}, as you did."),
_ => TA("The judge preferred chat {0}, while you preferred the other one."),
};
return string.Format(ModelComparisonFormat.Culture, text, chatNumber);
}
}
}