🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(evals): normalize Python score aliases in plain dictionaries (#15514)
Tobias Wochinger57c7c349cc77
diff --git a/scripts/code-eval-runners/python/code_based_eval_handler.py b/scripts/code-eval-runners/python/code_based_eval_handler.pyindex d4b4b3f551..bd19481da5 100644--- a/scripts/code-eval-runners/python/code_based_eval_handler.py+++ b/scripts/code-eval-runners/python/code_based_eval_handler.py@@ -139,6 +139,21 @@ def normalize_result(result):"Evaluator must return an object shaped like { scores: [...] }",)+ for score in normalized["scores"]:+ if not isinstance(score, dict):+ continue++ # Plain dictionaries bypass the Score dataclass field translation.+ # Retry known Python aliases at the score boundary without rewriting+ # arbitrary user metadata. Explicit wire-format keys take precedence.+ for alias, key in _DATACLASS_FIELD_NAME_OVERRIDES.items():+ if alias not in score:+ continue++ alias_value = score.pop(alias)+ if alias_value is not None and key not in score:+ score[key] = alias_value+return normalizeddiff --git a/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts b/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.tsindex fc9f6f31d0..3a9679c581 100644--- a/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts+++ b/worker/src/features/evaluation/codeBased/awsLambdaCodeEvalDispatcher.integration.test.ts@@ -51,7 +51,13 @@ const expectedScores = [dataType: "TEXT",metadata: { source: "runner-fixture" },},- { name: "rating", value: "good", dataType: "CATEGORICAL" },+ {+ name: "rating",+ value: "good",+ dataType: "CATEGORICAL",+ configId: "rating-config",+ },+ { name: "untyped", value: "fallback" },] as const;const sources: Record<CodeEvalRuntimeLanguage, string> = {@@ -75,7 +81,8 @@ function evaluate(ctx: {{ name: "output-contains-input-str", value: contains ? "True" : "False", dataType: "BOOLEAN" },{ name: ctx.observation.metadata.topic, value: ctx.experiment?.itemMetadata.item ?? 0, dataType: "NUMERIC" },{ name: "expected-output", value: ctx.experiment?.itemExpectedOutput ?? "", dataType: "TEXT", metadata: { source: "runner-fixture" } },- { name: "rating", value: "good", dataType: "CATEGORICAL" },+ { name: "rating", value: "good", dataType: "CATEGORICAL", configId: "rating-config" },+ { name: "untyped", value: "fallback" },],};}@@ -90,7 +97,8 @@ def evaluate(ctx):{"name": "output-contains-input-str", "value": "true" if contains else "false", "dataType": "BOOLEAN"},{"name": ctx.observation.metadata["topic"], "value": ctx.experiment.item_metadata["item"], "dataType": "NUMERIC"},Score(name="expected-output", value=ctx.experiment.item_expected_output, data_type="TEXT", metadata={"source": "runner-fixture"}),- {"name": "rating", "value": "good", "dataType": "CATEGORICAL"},+ {"name": "rating", "value": "good", "data_type": "CATEGORICAL", "config_id": "rating-config"},+ {"name": "untyped", "value": "fallback", "data_type": None, "config_id": None},],}`,