Skip to content

Commit d63248f

Browse files
authored
Merge pull request #41 from lambda-feedback/payload
feat: try config
2 parents 0151bfc + e85abe7 commit d63248f

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

evaluation_function/evaluation.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .schemas import FSA, FSAFrontend
44
from .schemas.result import Result
55
from .correction import analyze_fsa_correction
6+
import json
67

78
def validate_fsa(value: str | dict) -> FSA:
89
"""Parse a FSA from JSON string or dict."""
@@ -27,34 +28,34 @@ def evaluation_function(
2728
LFResult with is_correct and feedback_items
2829
"""
2930
try:
30-
# TEMPORARY WORKAROUND: Extract from params if not passed directly
31-
if params is None:
32-
params = {}
33-
34-
if isinstance(params, dict):
35-
raw_response = response or params.get("response") or {}
36-
raw_answer = answer or params.get("answer") or {}
37-
extra_params = params.get("params") or {}
38-
else:
39-
# If params is not a dict, fallback to empty dict
40-
raw_response = response
41-
raw_answer = answer
42-
extra_params = {}
43-
44-
if not raw_response or not raw_answer:
31+
if not response or not answer:
4532
raise ValueError(
4633
f"Missing FSA data: response or answer is None\n"
47-
f"raw_response: {raw_response}\nraw_answer: {raw_answer}"
34+
f"response: {response}\nanswer: {answer}"
4835
)
36+
# Extract and remove config from answer
37+
raw_config = "{}"
38+
if isinstance(answer, dict):
39+
raw_config = answer.pop("config", "{}")
40+
41+
config = json.loads(raw_config)
4942

5043
# Parse FSAs
51-
student_fsa = validate_fsa(raw_response)
52-
expected_fsa = validate_fsa(raw_answer)
44+
student_fsa = validate_fsa(response)
45+
expected_fsa = validate_fsa(answer)
5346

54-
require_minimal = extra_params.get("require_minimal", False) if isinstance(extra_params, dict) else False
47+
require_minimal = params.get("require_minimal", False) if isinstance(params, dict) else False
5548

5649
# Run correction pipeline
5750
result: Result = analyze_fsa_correction(student_fsa, expected_fsa, require_minimal)
51+
return LFResult(
52+
is_correct=False,
53+
feedback_items=[(
54+
"error",
55+
f"Invalid FSA format: {str(e)}\n\n"
56+
f"response: {response}\nanswer: {answer}\nparams: {params}\n\nconfig:{config}"
57+
)]
58+
)
5859

5960
# Return LFResult
6061
return LFResult(

0 commit comments

Comments
 (0)