using AIStudio.Settings.DataModel; namespace AIStudio.Assistants.ModelComparison; /// /// Decides which preset the mode Answer Variance works in, since it always works in one. /// public static class ModelComparisonPresetChoice { /// /// Chooses the preset the mode Answer Variance opens with, and the one it continues with after a preset was deleted: the /// preselected preset of the options, or else the first one. /// /// /// An assistant session which the page restores brings back the preset of its own instead, because the form it /// restores belongs to that preset. /// /// The presets, in the order the list shows them. /// The options of the assistant. /// The ID of the preset, or null when there is none, and a new one is needed. public static Guid? Choose(IReadOnlyList presets, DataModelComparison options) { if (options.PreselectOptions && Guid.TryParse(options.PreselectedPresetId, out var preselectedId) && presets.Any(preset => preset.Id == preselectedId)) return preselectedId; return presets.Count > 0 ? presets[0].Id : null; } }