(t *testing.T)
| 119 | } |
| 120 | |
| 121 | func TestSaveRunSessionsJSON(t *testing.T) { |
| 122 | t.Parallel() |
| 123 | |
| 124 | outputDir := t.TempDir() |
| 125 | |
| 126 | // Create sessions with different content |
| 127 | sess1 := session.New( |
| 128 | session.WithTitle("eval-json-1"), |
| 129 | session.WithUserMessage("What is the capital of France?"), |
| 130 | ) |
| 131 | sess1.InputTokens = 100 |
| 132 | sess1.OutputTokens = 50 |
| 133 | sess1.Cost = 0.01 |
| 134 | sess1.Evals = &session.EvalCriteria{ |
| 135 | Relevance: []string{"mentions Paris", "mentions France"}, |
| 136 | } |
| 137 | |
| 138 | sess2 := session.New( |
| 139 | session.WithTitle("eval-json-2"), |
| 140 | session.WithUserMessage("What is 2+2?"), |
| 141 | ) |
| 142 | sess2.InputTokens = 80 |
| 143 | sess2.OutputTokens = 30 |
| 144 | sess2.Cost = 0.005 |
| 145 | sess2.Evals = &session.EvalCriteria{ |
| 146 | Relevance: []string{"gives the correct answer", "explains the math"}, |
| 147 | } |
| 148 | |
| 149 | // Create an eval run with sessions and eval criteria |
| 150 | run := &EvalRun{ |
| 151 | Name: "test-json-001", |
| 152 | Timestamp: time.Now(), |
| 153 | Duration: 42 * time.Second, |
| 154 | Config: Config{ |
| 155 | AgentFilename: "./test-agent.yaml", |
| 156 | JudgeModel: "anthropic/claude-opus-4-5", |
| 157 | Concurrency: 4, |
| 158 | EvalsDir: "./evals", |
| 159 | }, |
| 160 | Summary: Summary{ |
| 161 | TotalEvals: 3, |
| 162 | FailedEvals: 1, |
| 163 | TotalCost: 0.015, |
| 164 | }, |
| 165 | Results: []Result{ |
| 166 | { |
| 167 | Title: "eval-json-1", |
| 168 | Question: "What is the capital of France?", |
| 169 | Response: "Paris is the capital of France.", |
| 170 | Cost: 0.01, |
| 171 | OutputTokens: 50, |
| 172 | RelevancePassed: 2, |
| 173 | RelevanceExpected: 2, |
| 174 | RelevanceResults: []RelevanceResult{ |
| 175 | {Criterion: "mentions Paris", Passed: true, Reason: "response includes Paris"}, |
| 176 | {Criterion: "mentions France", Passed: true, Reason: "response includes France"}, |
| 177 | }, |
| 178 | Session: sess1, |
nothing calls this directly
no test coverage detected