Reformat code.
This commit is contained in:
15
app.py
15
app.py
@@ -346,7 +346,8 @@ def grade_writing_task_2():
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": ('Evaluate the given Writing Task 2 response based on the IELTS grading system, ensuring a '
|
"content": (
|
||||||
|
'Evaluate the given Writing Task 2 response based on the IELTS grading system, ensuring a '
|
||||||
'strict assessment that penalizes errors. Deduct points for deviations from the task, and '
|
'strict assessment that penalizes errors. Deduct points for deviations from the task, and '
|
||||||
'assign a score of 0 if the response fails to address the question. Additionally, provide an '
|
'assign a score of 0 if the response fails to address the question. Additionally, provide an '
|
||||||
'exemplary answer with a minimum of 250 words, along with a detailed commentary highlighting '
|
'exemplary answer with a minimum of 250 words, along with a detailed commentary highlighting '
|
||||||
@@ -363,6 +364,7 @@ def grade_writing_task_2():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
|
|
||||||
|
|
||||||
def fix_writing_overall(overall: float, task_response: dict):
|
def fix_writing_overall(overall: float, task_response: dict):
|
||||||
if overall > max(task_response.values()) or overall < min(task_response.values()):
|
if overall > max(task_response.values()) or overall < min(task_response.values()):
|
||||||
total_sum = sum(task_response.values())
|
total_sum = sum(task_response.values())
|
||||||
@@ -371,6 +373,7 @@ def fix_writing_overall(overall: float, task_response: dict):
|
|||||||
return rounded_average
|
return rounded_average
|
||||||
return overall
|
return overall
|
||||||
|
|
||||||
|
|
||||||
@app.route('/writing_task2_general', methods=['GET'])
|
@app.route('/writing_task2_general', methods=['GET'])
|
||||||
@jwt_required()
|
@jwt_required()
|
||||||
def get_writing_task_2_general_question():
|
def get_writing_task_2_general_question():
|
||||||
@@ -385,7 +388,8 @@ def get_writing_task_2_general_question():
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": ('Craft a comprehensive question of ' + difficulty + 'difficulty like the ones for IELTS Writing Task 2 General Training that directs the candidate '
|
"content": (
|
||||||
|
'Craft a comprehensive question of ' + difficulty + 'difficulty like the ones for IELTS Writing Task 2 General Training that directs the candidate '
|
||||||
'to delve into an in-depth analysis of contrasting perspectives on the topic of "' + topic + '". '
|
'to delve into an in-depth analysis of contrasting perspectives on the topic of "' + topic + '". '
|
||||||
'The candidate should be asked to discuss the strengths and weaknesses of both viewpoints, provide evidence or '
|
'The candidate should be asked to discuss the strengths and weaknesses of both viewpoints, provide evidence or '
|
||||||
'examples, and present a well-rounded argument before concluding with their personal opinion on the subject.')
|
'examples, and present a well-rounded argument before concluding with their personal opinion on the subject.')
|
||||||
@@ -427,14 +431,16 @@ def grade_speaking_task_1():
|
|||||||
messages = [
|
messages = [
|
||||||
{
|
{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": ('You are a helpful assistant designed to output JSON on this format: '
|
"content": (
|
||||||
|
'You are a helpful assistant designed to output JSON on this format: '
|
||||||
'{"comment": "comment about answer quality", "overall": 0.0, '
|
'{"comment": "comment about answer quality", "overall": 0.0, '
|
||||||
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
|
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
|
||||||
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
|
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"role": "user",
|
"role": "user",
|
||||||
"content": ('Evaluate the given Speaking Part 1 response based on the IELTS grading system, ensuring a '
|
"content": (
|
||||||
|
'Evaluate the given Speaking Part 1 response based on the IELTS grading system, ensuring a '
|
||||||
'strict assessment that penalizes errors. Deduct points for deviations from the task, and '
|
'strict assessment that penalizes errors. Deduct points for deviations from the task, and '
|
||||||
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
'assign a score of 0 if the response fails to address the question. Additionally, provide '
|
||||||
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
'detailed commentary highlighting both strengths and weaknesses in the response.'
|
||||||
@@ -442,6 +448,7 @@ def grade_speaking_task_1():
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
token_count = count_total_tokens(messages)
|
token_count = count_total_tokens(messages)
|
||||||
|
|
||||||
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Requesting grading of the answer.")
|
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Requesting grading of the answer.")
|
||||||
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, ["comment"],
|
response = make_openai_call(GPT_3_5_TURBO, messages, token_count, ["comment"],
|
||||||
GRADING_TEMPERATURE)
|
GRADING_TEMPERATURE)
|
||||||
|
|||||||
Reference in New Issue
Block a user