| | | 1 | | namespace EHonda.KicktippAi.Core; |
| | | 2 | | |
| | | 3 | | public sealed record PredictionModelConfig |
| | | 4 | | { |
| | 1 | 5 | | private static readonly HashSet<string> AllowedReasoningEfforts = new(StringComparer.Ordinal) |
| | 1 | 6 | | { |
| | 1 | 7 | | "none", |
| | 1 | 8 | | "minimal", |
| | 1 | 9 | | "low", |
| | 1 | 10 | | "medium", |
| | 1 | 11 | | "high", |
| | 1 | 12 | | "xhigh" |
| | 1 | 13 | | }; |
| | | 14 | | |
| | 1 | 15 | | private PredictionModelConfig(string model, string? reasoningEffort) |
| | | 16 | | { |
| | 1 | 17 | | Model = model; |
| | 1 | 18 | | ReasoningEffort = reasoningEffort; |
| | 1 | 19 | | } |
| | | 20 | | |
| | | 21 | | public string Model { get; } |
| | | 22 | | |
| | | 23 | | public string? ReasoningEffort { get; } |
| | | 24 | | |
| | 1 | 25 | | public string IdentityKey => ReasoningEffort is null |
| | 1 | 26 | | ? Model |
| | 1 | 27 | | : $"{Model}:reasoning-effort:{ReasoningEffort}"; |
| | | 28 | | |
| | 1 | 29 | | public string DisplayName => ReasoningEffort is null |
| | 1 | 30 | | ? Model |
| | 1 | 31 | | : $"{Model} ({ReasoningEffort})"; |
| | | 32 | | |
| | 1 | 33 | | public bool AllowsLegacyModelOnlyLookup => ReasoningEffort is null; |
| | | 34 | | |
| | | 35 | | public static PredictionModelConfig Create(string model, string? reasoningEffort = null) |
| | | 36 | | { |
| | 1 | 37 | | ArgumentException.ThrowIfNullOrWhiteSpace(model); |
| | | 38 | | |
| | 1 | 39 | | return new PredictionModelConfig( |
| | 1 | 40 | | model.Trim(), |
| | 1 | 41 | | NormalizeReasoningEffort(reasoningEffort)); |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | public static string? NormalizeReasoningEffort(string? reasoningEffort) |
| | | 45 | | { |
| | 1 | 46 | | if (string.IsNullOrWhiteSpace(reasoningEffort)) |
| | | 47 | | { |
| | 1 | 48 | | return null; |
| | | 49 | | } |
| | | 50 | | |
| | 1 | 51 | | var normalized = reasoningEffort.Trim().ToLowerInvariant(); |
| | 1 | 52 | | if (!AllowedReasoningEfforts.Contains(normalized)) |
| | | 53 | | { |
| | 0 | 54 | | throw new ArgumentException( |
| | 0 | 55 | | "--reasoning-effort must be one of: none, minimal, low, medium, high, xhigh", |
| | 0 | 56 | | nameof(reasoningEffort)); |
| | | 57 | | } |
| | | 58 | | |
| | 1 | 59 | | return normalized; |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | public static bool IsValidReasoningEffort(string? reasoningEffort) |
| | | 63 | | { |
| | 1 | 64 | | if (string.IsNullOrWhiteSpace(reasoningEffort)) |
| | | 65 | | { |
| | 1 | 66 | | return true; |
| | | 67 | | } |
| | | 68 | | |
| | 1 | 69 | | return AllowedReasoningEfforts.Contains(reasoningEffort.Trim().ToLowerInvariant()); |
| | | 70 | | } |
| | | 71 | | } |