Skip to content

Commit 8e154eb

Browse files
author
Dylan Huang
committed
Add 'passed' field to EvalMetadata and update evaluation logic to determine if the evaluation passed based on the threshold of success.
1 parent 9be63e2 commit 8e154eb

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

eval_protocol/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class EvalMetadata(BaseModel):
212212
num_runs: int = Field(..., description="Number of times the evaluation was repeated")
213213
aggregation_method: str = Field(..., description="Method used to aggregate scores across runs")
214214
threshold_of_success: Optional[float] = Field(None, description="Threshold score for test success")
215+
passed: Optional[bool] = Field(None, description="Whether the evaluation passed based on the threshold")
215216

216217

217218
class EvaluationRow(BaseModel):

eval_protocol/pytest/evaluation_test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ def wrapper_body(**kwargs):
275275
)
276276
all_results.extend(results)
277277

278+
scores = [r.evaluation_result.score for r in all_results if r.evaluation_result]
279+
agg_score = aggregate(scores, aggregation_method)
280+
281+
# Determine if the evaluation passed based on threshold
282+
passed = None
283+
if threshold_of_success is not None:
284+
passed = agg_score >= threshold_of_success
285+
278286
# Create eval metadata with test function info and current commit hash
279287
eval_metadata = EvalMetadata(
280288
name=test_func.__name__,
@@ -284,16 +292,16 @@ def wrapper_body(**kwargs):
284292
num_runs=num_runs,
285293
aggregation_method=aggregation_method,
286294
threshold_of_success=threshold_of_success,
295+
passed=passed,
287296
)
288297

289298
# Add metadata to all results before logging
290299
for r in all_results:
291300
r.eval_metadata = eval_metadata
292301
default_logger.log(r)
293302

294-
scores = [r.evaluation_result.score for r in all_results if r.evaluation_result]
295-
agg_score = aggregate(scores, aggregation_method)
296-
if threshold_of_success is not None:
303+
# Check threshold after logging
304+
if threshold_of_success is not None and not passed:
297305
assert (
298306
agg_score >= threshold_of_success
299307
), f"Aggregated score {agg_score:.3f} below threshold {threshold_of_success}"

vite-app/src/types/eval-protocol.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export const EvalMetadataSchema = z.object({
8181
status: z.enum(['running', 'finished', 'error']).default('running').describe('Status of the evaluation'),
8282
num_runs: z.number().int().describe('Number of times the evaluation was repeated'),
8383
aggregation_method: z.string().describe('Method used to aggregate scores across runs'),
84-
threshold_of_success: z.number().optional().describe('Threshold score for test success')
84+
threshold_of_success: z.number().optional().describe('Threshold score for test success'),
85+
passed: z.boolean().optional().describe('Whether the evaluation passed based on the threshold')
8586
});
8687

8788
export const EvaluationRowSchema = z.object({

0 commit comments

Comments
 (0)