| | | 1 | | using System.ComponentModel; |
| | | 2 | | using EHonda.KicktippAi.Core; |
| | | 3 | | using Spectre.Console; |
| | | 4 | | using Spectre.Console.Cli; |
| | | 5 | | |
| | | 6 | | namespace Orchestrator.Commands.Observability.ExportExperimentItem; |
| | | 7 | | |
| | | 8 | | public sealed class ExportExperimentItemSettings : CommandSettings |
| | | 9 | | { |
| | | 10 | | [CommandArgument(0, "<MODEL>")] |
| | | 11 | | [Description("The model used for the stored prediction that anchors prompt reconstruction")] |
| | 1 | 12 | | public string Model { get; set; } = string.Empty; |
| | | 13 | | |
| | | 14 | | [CommandOption("--community-context")] |
| | | 15 | | [Description("Community context used for the stored prediction")] |
| | 1 | 16 | | public string CommunityContext { get; set; } = string.Empty; |
| | | 17 | | |
| | | 18 | | [CommandOption("--home")] |
| | | 19 | | [Description("Home team name")] |
| | 1 | 20 | | public string HomeTeam { get; set; } = string.Empty; |
| | | 21 | | |
| | | 22 | | [CommandOption("--away")] |
| | | 23 | | [Description("Away team name")] |
| | 1 | 24 | | public string AwayTeam { get; set; } = string.Empty; |
| | | 25 | | |
| | | 26 | | [CommandOption("--matchday")] |
| | | 27 | | [Description("Matchday number for the selected match")] |
| | | 28 | | public int? Matchday { get; set; } |
| | | 29 | | |
| | | 30 | | [CommandOption("--with-justification")] |
| | | 31 | | [Description("Reconstruct the justification prompt variant")] |
| | | 32 | | [DefaultValue(false)] |
| | | 33 | | public bool WithJustification { get; set; } |
| | | 34 | | |
| | | 35 | | [CommandOption("--reasoning-effort")] |
| | | 36 | | [Description("Optional OpenAI reasoning effort used for the stored prediction (none, minimal, low, medium, high, xhi |
| | | 37 | | public string? ReasoningEffort { get; set; } |
| | | 38 | | |
| | | 39 | | [CommandOption("--evaluation-time")] |
| | | 40 | | [Description("Optional explicit evaluation time in NodaTime invariant ZonedDateTime 'G' format, for example '2026-03 |
| | | 41 | | public string? EvaluationTime { get; set; } |
| | | 42 | | |
| | | 43 | | [CommandOption("--evaluation-policy-kind")] |
| | | 44 | | [Description("Optional evaluation policy kind. Currently only 'relative' is supported.")] |
| | | 45 | | public string? EvaluationPolicyKind { get; set; } |
| | | 46 | | |
| | | 47 | | [CommandOption("--evaluation-policy-offset")] |
| | | 48 | | [Description("Optional NodaTime Duration offset for the evaluation policy, for example '-12:00:00'.")] |
| | | 49 | | public string? EvaluationPolicyOffset { get; set; } |
| | | 50 | | |
| | | 51 | | [CommandOption("--output")] |
| | | 52 | | [Description("Path to the JSON file to write. Defaults to artifacts/langfuse-experiments/items/<match>.json")] |
| | | 53 | | public string? OutputPath { get; set; } |
| | | 54 | | |
| | | 55 | | public override ValidationResult Validate() |
| | | 56 | | { |
| | 1 | 57 | | if (string.IsNullOrWhiteSpace(Model)) |
| | | 58 | | { |
| | 0 | 59 | | return ValidationResult.Error("Model is required"); |
| | | 60 | | } |
| | | 61 | | |
| | 1 | 62 | | if (string.IsNullOrWhiteSpace(CommunityContext)) |
| | | 63 | | { |
| | 0 | 64 | | return ValidationResult.Error("--community-context is required"); |
| | | 65 | | } |
| | | 66 | | |
| | 1 | 67 | | if (string.IsNullOrWhiteSpace(HomeTeam)) |
| | | 68 | | { |
| | 0 | 69 | | return ValidationResult.Error("--home must be provided"); |
| | | 70 | | } |
| | | 71 | | |
| | 1 | 72 | | if (string.IsNullOrWhiteSpace(AwayTeam)) |
| | | 73 | | { |
| | 0 | 74 | | return ValidationResult.Error("--away must be provided"); |
| | | 75 | | } |
| | | 76 | | |
| | 1 | 77 | | if (!Matchday.HasValue) |
| | | 78 | | { |
| | 0 | 79 | | return ValidationResult.Error("--matchday must be provided"); |
| | | 80 | | } |
| | | 81 | | |
| | 1 | 82 | | if (!string.IsNullOrWhiteSpace(EvaluationTime)) |
| | | 83 | | { |
| | | 84 | | try |
| | | 85 | | { |
| | 0 | 86 | | _ = Commands.Observability.EvaluationTimeParser.Parse(EvaluationTime); |
| | 0 | 87 | | } |
| | | 88 | | catch (ArgumentException ex) |
| | | 89 | | { |
| | 0 | 90 | | return ValidationResult.Error(ex.Message); |
| | | 91 | | } |
| | | 92 | | } |
| | | 93 | | |
| | 1 | 94 | | if (!PredictionModelConfig.IsValidReasoningEffort(ReasoningEffort)) |
| | | 95 | | { |
| | 0 | 96 | | return ValidationResult.Error("--reasoning-effort must be one of: none, minimal, low, medium, high, xhigh"); |
| | | 97 | | } |
| | | 98 | | |
| | 1 | 99 | | var hasEvaluationPolicyKind = !string.IsNullOrWhiteSpace(EvaluationPolicyKind); |
| | 1 | 100 | | var hasEvaluationPolicyOffset = !string.IsNullOrWhiteSpace(EvaluationPolicyOffset); |
| | | 101 | | |
| | 1 | 102 | | if (hasEvaluationPolicyKind != hasEvaluationPolicyOffset) |
| | | 103 | | { |
| | 0 | 104 | | return ValidationResult.Error("--evaluation-policy-kind and --evaluation-policy-offset must be provided toge |
| | | 105 | | } |
| | | 106 | | |
| | 1 | 107 | | if (!string.IsNullOrWhiteSpace(EvaluationTime) && hasEvaluationPolicyKind) |
| | | 108 | | { |
| | 0 | 109 | | return ValidationResult.Error("--evaluation-time cannot be combined with --evaluation-policy-kind/--evaluati |
| | | 110 | | } |
| | | 111 | | |
| | 1 | 112 | | if (hasEvaluationPolicyKind) |
| | | 113 | | { |
| | | 114 | | try |
| | | 115 | | { |
| | 0 | 116 | | _ = Commands.Observability.EvaluationTimestampPolicyParser.Parse(EvaluationPolicyKind, EvaluationPolicyO |
| | 0 | 117 | | } |
| | | 118 | | catch (ArgumentException ex) |
| | | 119 | | { |
| | 0 | 120 | | return ValidationResult.Error(ex.Message); |
| | | 121 | | } |
| | | 122 | | } |
| | | 123 | | |
| | 1 | 124 | | return ValidationResult.Success(); |
| | 0 | 125 | | } |
| | | 126 | | } |