namespace AIStudio.Assistants.ModelComparison; public static class ModelComparisonPresentationOrderExtensions { /// Which model is shown in column A. extension(ModelComparisonPresentationOrder order) { /// /// Gets the answer which is shown in column A. /// /// The answers of both models. /// The answer for column A. public ModelComparisonAnswer InColumnA(ModelComparisonRunResult run) => order switch { ModelComparisonPresentationOrder.FIRST_MODEL_FIRST => run.First, ModelComparisonPresentationOrder.SECOND_MODEL_FIRST => run.Second, _ => throw new ArgumentOutOfRangeException(nameof(order), order, $"The presentation order '{order}' is not known."), }; /// /// Gets the answer which is shown in column B. /// /// The answers of both models. /// The answer for column B. public ModelComparisonAnswer InColumnB(ModelComparisonRunResult run) => order switch { ModelComparisonPresentationOrder.FIRST_MODEL_FIRST => run.Second, ModelComparisonPresentationOrder.SECOND_MODEL_FIRST => run.First, _ => throw new ArgumentOutOfRangeException(nameof(order), order, $"The presentation order '{order}' is not known."), }; /// /// Turns a column-based choice back into the model it means. The reverse of InColumnA and InColumnB: /// those turn a known model into its column, this turns a known column back into its model. /// /// The column-based choice, from the user's own vote or from a judge verdict. public ModelComparisonModelChoice ToModelChoice(ModelComparisonVote vote) => vote switch { ModelComparisonVote.TIE => ModelComparisonModelChoice.TIE, ModelComparisonVote.COLUMN_A => order is ModelComparisonPresentationOrder.FIRST_MODEL_FIRST ? ModelComparisonModelChoice.FIRST : ModelComparisonModelChoice.SECOND, ModelComparisonVote.COLUMN_B => order is ModelComparisonPresentationOrder.FIRST_MODEL_FIRST ? ModelComparisonModelChoice.SECOND : ModelComparisonModelChoice.FIRST, _ => throw new ArgumentOutOfRangeException(nameof(vote), vote, $"The vote '{vote}' is not known."), }; } }