Fix grading parse.
This commit is contained in:
2
app.py
2
app.py
@@ -29,7 +29,7 @@ GRADING_TEMPERATURE = 0.1
|
||||
GEN_QUESTION_TEMPERATURE = 0.9
|
||||
GPT_3_5_TURBO = "gpt-3.5-turbo"
|
||||
GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k"
|
||||
GRADING_FIELDS = ['overall', 'comment', 'task_response']
|
||||
GRADING_FIELDS = ['comment', 'overall', 'task_response']
|
||||
GEN_FIELDS = ['question']
|
||||
LISTENING_GEN_FIELDS = ['transcript', 'exercise']
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ def process_response(input_string, quotation_check_field):
|
||||
index = input_string.index('{')
|
||||
# Extract everything after the first '{' (inclusive)
|
||||
result = input_string[index:]
|
||||
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result):
|
||||
if re.search(r"'" + quotation_check_field + "':\s*'(.*?)'", result, re.DOTALL | re.MULTILINE):
|
||||
parsed_string = result.replace("\"", "\\\"")
|
||||
pattern = r"(?<!\w)'|'(?!\w)"
|
||||
parsed_string = re.sub(pattern, '"', parsed_string)
|
||||
@@ -35,8 +35,8 @@ def process_response(input_string, quotation_check_field):
|
||||
else:
|
||||
json_obj = json.loads(result)
|
||||
return json_obj
|
||||
except json.JSONDecodeError:
|
||||
print("Invalid JSON string!")
|
||||
except Exception as e:
|
||||
print(f"Invalid JSON string! Exception: {e}")
|
||||
else:
|
||||
return input_string
|
||||
|
||||
|
||||
1227
testing.py
1227
testing.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user