Skip to content

Commit 04c087c

Browse files
mmabroukclaude
andcommitted
fix(api): use aggregate_score instead of score in json_multi_field_match
Fixes naming inconsistency between API service and SDK interface schema. The interface defines `aggregate_score` as the required output field, so the service must use the same name to pass schema validation. Also applies ruff auto-cleanup for unused imports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 0df3ddc commit 04c087c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

api/oss/src/services/evaluators_service.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ async def auto_exact_match(
253253
message=str(e),
254254
),
255255
)
256-
except Exception as e: # pylint: disable=broad-except
256+
except Exception: # pylint: disable=broad-except
257257
return Result(
258258
type="error",
259259
value=None,
@@ -487,8 +487,8 @@ async def json_multi_field_match(
487487
if match:
488488
matches += 1
489489

490-
# Overall score is average of field scores
491-
results["score"] = matches / len(fields) if fields else 0.0
490+
# Aggregate score is the percentage of matching fields
491+
results["aggregate_score"] = matches / len(fields) if fields else 0.0
492492

493493
return {"outputs": results}
494494

@@ -576,7 +576,7 @@ async def auto_custom_code_run(
576576
)
577577
)
578578
return Result(type="number", value=response["outputs"]["score"])
579-
except Exception as e: # pylint: disable=broad-except
579+
except Exception: # pylint: disable=broad-except
580580
return Result(
581581
type="error",
582582
value=None,
@@ -645,7 +645,7 @@ async def auto_ai_critique(
645645
)
646646
)
647647
return Result(type="number", value=response["outputs"]["score"])
648-
except Exception as e: # pylint: disable=broad-except
648+
except Exception: # pylint: disable=broad-except
649649
return Result(
650650
type="error",
651651
value=None,
@@ -656,9 +656,7 @@ async def auto_ai_critique(
656656
)
657657

658658

659-
import json
660-
import re
661-
from typing import Any, Dict, Iterable, Tuple, Optional
659+
from typing import Any, Dict, Iterable, Tuple
662660

663661
try:
664662
import jsonpath # ✅ use module API
@@ -1295,7 +1293,7 @@ async def auto_starts_with(
12951293
)
12961294
)
12971295
return Result(type="bool", value=response["outputs"]["success"])
1298-
except Exception as e: # pylint: disable=broad-except
1296+
except Exception: # pylint: disable=broad-except
12991297
return Result(
13001298
type="error",
13011299
value=None,
@@ -1337,7 +1335,7 @@ async def auto_ends_with(
13371335
)
13381336
result = Result(type="bool", value=response["outputs"]["success"])
13391337
return result
1340-
except Exception as e: # pylint: disable=broad-except
1338+
except Exception: # pylint: disable=broad-except
13411339
return Result(
13421340
type="error",
13431341
value=None,
@@ -1379,7 +1377,7 @@ async def auto_contains(
13791377
)
13801378
result = Result(type="bool", value=response["outputs"]["success"])
13811379
return result
1382-
except Exception as e: # pylint: disable=broad-except
1380+
except Exception: # pylint: disable=broad-except
13831381
return Result(
13841382
type="error",
13851383
value=None,
@@ -1421,7 +1419,7 @@ async def auto_contains_any(
14211419
)
14221420
result = Result(type="bool", value=response["outputs"]["success"])
14231421
return result
1424-
except Exception as e: # pylint: disable=broad-except
1422+
except Exception: # pylint: disable=broad-except
14251423
return Result(
14261424
type="error",
14271425
value=None,
@@ -1464,7 +1462,7 @@ async def auto_contains_all(
14641462
)
14651463
result = Result(type="bool", value=response["outputs"]["success"])
14661464
return result
1467-
except Exception as e: # pylint: disable=broad-except
1465+
except Exception: # pylint: disable=broad-except
14681466
return Result(
14691467
type="error",
14701468
value=None,
@@ -1512,7 +1510,7 @@ async def auto_contains_json(
15121510
input=EvaluatorInputInterface(**{"inputs": {"prediction": output}})
15131511
)
15141512
return Result(type="bool", value=response["outputs"]["success"])
1515-
except Exception as e: # pylint: disable=broad-except
1513+
except Exception: # pylint: disable=broad-except
15161514
return Result(
15171515
type="error",
15181516
value=None,
@@ -1530,7 +1528,7 @@ async def contains_json(input: EvaluatorInputInterface) -> EvaluatorOutputInterf
15301528
potential_json = str(input.inputs["prediction"])[start_index:end_index]
15311529
json.loads(potential_json)
15321530
contains_json = True
1533-
except (ValueError, json.JSONDecodeError) as e:
1531+
except (ValueError, json.JSONDecodeError):
15341532
contains_json = False
15351533

15361534
return {"outputs": {"success": contains_json}}
@@ -1992,7 +1990,7 @@ async def auto_levenshtein_distance(
19921990
message=str(e),
19931991
),
19941992
)
1995-
except Exception as e: # pylint: disable=broad-except
1993+
except Exception: # pylint: disable=broad-except
19961994
return Result(
19971995
type="error",
19981996
value=None,
@@ -2032,7 +2030,7 @@ async def auto_similarity_match(
20322030
message=str(e),
20332031
),
20342032
)
2035-
except Exception as e: # pylint: disable=broad-except
2033+
except Exception: # pylint: disable=broad-except
20362034
return Result(
20372035
type="error",
20382036
value=None,

0 commit comments

Comments
 (0)