Skip to content

Commit cbb5bc9

Browse files
Merge pull request #1 from lambda-feedback/tr-Alpha-418
Changed interaction logic for custom feedback and cases
2 parents 51716a0 + e5d386b commit cbb5bc9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

handler.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ def handle_eval_command(event):
7171
}
7272
}
7373

74-
# Result already contains feedback generated inside the custom function
75-
if "feedback" in result:
76-
return {"command": "eval", "result": result}
77-
7874
# If a list of "cases" wasn't provided, we don't have any other way to get feedback
7975
cases = params.get("cases", [])
8076
if len(cases) == 0:
@@ -106,6 +102,7 @@ def feedback_from_cases(response, params, cases):
106102
# A list of "cases" was provided, try matching to each of them
107103
matches = []
108104
warnings = []
105+
eval_function_feedback = []
109106
for i, case in enumerate(cases):
110107
# Validate the case block has an answer and feedback
111108
if 'answer' not in case:
@@ -150,13 +147,19 @@ def feedback_from_cases(response, params, cases):
150147
# This case matches the response, add it's index to the list of matches
151148
if res.get('is_correct') == True:
152149
matches += [i]
150+
eval_function_feedback += [res.get("feedback","")]
153151

154152
if len(matches) == 0:
155153
return None, warnings
156154

157155
# Select the matched case
158156
matched_case = cases[matches[0]]
159157
matched_case['id'] = matches[0]
158+
if not matched_case["params"].get("override_eval_feedback",False):
159+
separator = "\n" if len(eval_function_feedback[0]) > 0 else ""
160+
matched_case["feedback"] = matched_case.get("feedback","")\
161+
+separator\
162+
+eval_function_feedback[0]
160163

161164
if len(matches) == 1:
162165
# warnings += [{"case": matches[0]}]

0 commit comments

Comments
 (0)