using AIStudio.Chat; using AIStudio.Components; using Microsoft.AspNetCore.Components; namespace AIStudio.Assistants.ModelComparison; /// /// The card of one answer of the Model Comparison assistant, with its title above. /// /// /// The same markup for both answers of a run, so that nothing but the position tells them apart. The card fills the /// column of the grid it stands in; from the breakpoint md of MudBlazor on, both columns are in one row, so the cards /// are equally high however long the answers are. That is why the names of the models are not part of the card: how /// long a name is would make the cards differ, see ModelComparisonAnswerCaption. In a narrower window, the second card /// stands below the first one. The column itself belongs to the page, see ModelComparisonVoteColumns. /// public partial class ModelComparisonAnswerCard : MSGComponentBase { /// /// Gets or sets the title: "Answer A" or "Answer B" while the user votes, "First model" or "Second model" in the /// summary. /// [Parameter, EditorRequired] public string Title { get; set; } = string.Empty; /// /// Gets or sets the answer. /// [Parameter, EditorRequired] public ModelComparisonAnswer Answer { get; set; } = null!; /// /// Gets or sets when the run ended. Both answers of a run show this one time: a time of their own would tell the /// faster model from the slower one. /// [Parameter] public DateTimeOffset Time { get; set; } /// /// Gets or sets the classes of the card, see ModelComparisonOutcome.CardClassOf. /// [Parameter] public string CardClass { get; set; } = ModelComparisonOutcome.FILL_THE_COLUMN; /// /// The answer as the chat component wants it. Built once per answer, and not on every render: the chat component /// compares what it is given to decide whether anything has to be drawn again, and a new one would make it parse the /// whole Markdown again. /// private ContentText content = new(); /// /// The answer which content was built from. /// private ModelComparisonAnswer? shownAnswer; #region Overrides of ComponentBase protected override void OnParametersSet() { if (!ReferenceEquals(this.shownAnswer, this.Answer)) { this.shownAnswer = this.Answer; this.content = new ContentText { Text = this.Answer.Text }; } base.OnParametersSet(); } #endregion }