Reformat code.

This commit is contained in:
Cristiano Ferreira
2024-05-20 14:40:09 +01:00
parent e568aff4e4
commit 9654d9ff64

19
app.py
View File

@@ -346,7 +346,8 @@ def grade_writing_task_2():
},
{
"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 '
'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 '
@@ -363,6 +364,7 @@ def grade_writing_task_2():
except Exception as e:
return str(e)
def fix_writing_overall(overall: float, task_response: dict):
if overall > max(task_response.values()) or overall < min(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 overall
@app.route('/writing_task2_general', methods=['GET'])
@jwt_required()
def get_writing_task_2_general_question():
@@ -385,7 +388,8 @@ def get_writing_task_2_general_question():
},
{
"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 + '". '
'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.')
@@ -427,23 +431,26 @@ def grade_speaking_task_1():
messages = [
{
"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, '
'"task_response": {"Fluency and Coherence": 0.0, "Lexical Resource": 0.0, '
'"Grammatical Range and Accuracy": 0.0, "Pronunciation": 0.0}}')
},
{
"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 '
'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.'
'\n Question: "'+ question + '" \n Answer: "'+ answer + '"')
'\n Question: "' + question + '" \n Answer: "' + answer + '"')
}
]
token_count = count_total_tokens(messages)
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)
logging.info("POST - speaking_task_1 - " + str(request_id) + " - Answer graded: " + str(response))