namespace AIStudio.Assistants.ModelComparison; /// /// How the summary of a batch shows what the user and the judge chose in a run. /// public static class ModelComparisonOutcome { /// /// Makes the card of an answer as high as its column, so that both cards of a run are equally high. /// public const string FILL_THE_COLUMN = "flex-grow-1"; /// /// Gets how a model did in the vote of the user, as a color: green when its answer was preferred, red when the /// other one was, orange when the user found them equally good. /// /// The model the user preferred in the run, or null without a vote. /// The model whose outcome this is. /// The color. public static Color ColorOf(ModelComparisonModelChoice? voteChoice, ModelComparisonModelChoice model) => voteChoice switch { null => Color.Default, ModelComparisonModelChoice.TIE => Color.Warning, { } chosen when chosen == model => Color.Success, _ => Color.Error, }; /// /// Gets the icon which goes with ColorOf. The color alone would not tell the outcomes apart for readers who are /// color blind, so every outcome has a shape of its own as well. /// /// The model the user preferred in the run, or null without a vote. /// The model whose outcome this is. /// The icon. public static string IconOf(ModelComparisonModelChoice? voteChoice, ModelComparisonModelChoice model) => voteChoice switch { null => AppIcons.VOTE_MISSING, ModelComparisonModelChoice.TIE => AppIcons.VOTE_TIE, { } chosen when chosen == model => AppIcons.VOTE_WON, _ => AppIcons.VOTE_LOST, }; /// /// Gets the classes of the card around an answer: it fills the height of its column, and with a vote of the user, /// it has a border in the color which goes with ColorOf. /// /// /// The classes are the ones of MudBlazor: a border two pixels wide, in the color of the outcome. They override the /// thin gray line of the card, which is why they are told to win. While the user votes, and for a run without a /// vote, the answers stand in the plain frame of the chat. /// /// The model the user preferred in the run, or null without a vote. /// The model whose answer the card shows. /// The classes. public static string CardClassOf(ModelComparisonModelChoice? voteChoice, ModelComparisonModelChoice model) { if (voteChoice is null) return FILL_THE_COLUMN; var color = ColorOf(voteChoice, model) switch { Color.Success => "mud-border-success", Color.Warning => "mud-border-warning", _ => "mud-border-error", }; return $"{FILL_THE_COLUMN} border-2 border-solid {color}"; } /// /// Gets whether the badge of the judge belongs on the answer of a model: either the judge preferred it, or the judge /// saw a tie, in which case both answers carry the badge. /// /// The model the judge preferred, or null without a usable verdict. /// The model whose answer this is. /// True when the answer carries the badge. public static bool JudgeFavors(ModelComparisonModelChoice? judgeChoice, ModelComparisonModelChoice model) => judgeChoice is ModelComparisonModelChoice.TIE || judgeChoice == model; }