11from typing import Any
22from lf_toolkit .evaluation import Result as LFResult , Params
33
4- from .schemas import FSA , FSAFrontend
4+ # note: this file is a temperary workaround, if the frontend -> backend communication succeed, fix this file
5+
6+ from .schemas import FSA #, FSAFrontend
57from .schemas .result import Result
68from .correction import analyze_fsa_correction
79
1315# feedback_items=[("error", f"{payload}")]
1416# )
1517
18+ def validate_fsa (value : str | dict ) -> FSA :
19+ if isinstance (value , str ):
20+ return FSA .model_validate_json (value )
21+ return FSA .model_validate (value )
22+
1623def evaluation_function (
1724 response : Any ,
1825 answer : Any ,
@@ -31,12 +38,16 @@ def evaluation_function(
3138 """
3239 try :
3340 # Parse FSAs from input
34- student_fsa_ = FSAFrontend .model_validate (response )
35- expected_fsa_ = FSAFrontend .model_validate (answer )
41+ # student_fsa_ = FSAFrontend.model_validate(response)
42+ # expected_fsa_ = FSAFrontend.model_validate(answer)
43+
44+ # student_fsa = student_fsa_.from_flattened()
45+ # expected_fsa = expected_fsa_.from_flattened()
46+
47+ # as a temporary workaround we assume the response and answer are all valid json strings
48+ student_fsa = validate_fsa (response )
49+ expected_fsa = validate_fsa (answer )
3650
37- # Convert from flattened format to FSA
38- student_fsa = FSAFrontend .from_flattened (student_fsa_ .model_dump ())
39- expected_fsa = FSAFrontend .from_flattened (expected_fsa_ .model_dump ())
4051
4152
4253 # Get require_minimal from params if present
0 commit comments