Add speaking task 3 grading endpoint.

This commit is contained in:
Cristiano Ferreira
2023-09-16 11:44:08 +01:00
parent f77fafa864
commit 8d9cd2949c
3 changed files with 96 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
from enum import Enum
from typing import List
class QuestionType(Enum):
LISTENING_SECTION_1 = "Listening Section 1"
@@ -109,23 +111,14 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
},
{
"role": "user",
"content": "Please provide your assessment using the following JSON format: {'comment': 'Comment about "
"answer quality', 'overall': 7.0, 'task_response': {'Fluency and Coherence': 8.0, 'Lexical "
"Resource': 6.5, 'Grammatical Range and Accuracy': 7.5, 'Pronunciation': 6.0}}"
"content": "Please provide your assessment using the following JSON format: {'comment': 'Comment about answer "
"quality will go here', 'overall': 7.0, 'task_response': {'Fluency and "
"Coherence': 8.0, 'Lexical Resource': 6.5, 'Grammatical Range and Accuracy': 7.5, 'Pronunciation': 6.0}}"
},
{
"role": "user",
"content": "Example output: {'comment': 'The candidate has provided a clear response to the question and "
"has given examples of how they spend their weekends. However, there are some issues with grammar "
"and pronunciation that affect the overall score. In terms of fluency and coherence, the candidate "
"speaks clearly and smoothly with only minor hesitations. They have also provided a well-organized "
"response that is easy to follow. Regarding lexical resource, the candidate has used a range of "
"vocabulary related to weekend activities but there are some errors in word choice that affect "
"the meaning of their sentences. In terms of grammatical range and accuracy, the candidate has "
"used a mix of simple and complex sentence structures but there are some errors in subject-verb "
"agreement and preposition use. Finally, regarding pronunciation, the candidate's speech is "
"generally clear but there are some issues with stress and intonation that make it difficult "
"to understand at times.', 'overall': 6.5, 'task_response': {'Fluency and Coherence': 7.0, "
"content": "Example output: {'comment': 'Comment about answer quality will go here', 'overall': 6.5, "
"'task_response': {'Fluency and Coherence': 7.0, "
"'Lexical Resource': 6.5, 'Grammatical Range and Accuracy': 7.0, 'Pronunciation': 6.0}}"
},
{
@@ -192,6 +185,54 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
raise Exception("Question type not implemented: " + question_type.value)
def get_speaking_grading_messages(answers: List):
messages = [
{
"role": "user",
"content": "You are an IELTS examiner."
},
{
"role": "user",
"content": "The exercise you need to grade is a Speaking Task, and it is has the following questions and answers:"
}
]
for item in answers:
question = item["question"]
answer = item["answer_text"]
messages.append({
"role": "user",
"content": f"Question: {question}; Answer: {answer}"
})
messages.extend([
{
"role": "user",
"content": f"Assess this answer according to the IELTS grading system."
},
{
"role": "user",
"content": "Please provide your assessment using the following JSON format: {'comment': 'Comment about answer "
"quality will go here', 'overall': 7.0, 'task_response': {'Fluency and "
"Coherence': 8.0, 'Lexical Resource': 6.5, 'Grammatical Range and Accuracy': 7.5, 'Pronunciation': 6.0}}"
},
{
"role": "user",
"content": "Example output: {'comment': 'Comment about answer quality will go here', 'overall': 6.5, "
"'task_response': {'Fluency and Coherence': 7.0, "
"'Lexical Resource': 6.5, 'Grammatical Range and Accuracy': 7.0, 'Pronunciation': 6.0}}"
},
{
"role": "user",
"content": "Please assign a grade of 0 if the answer provided does not address the question."
},
{
"role": "user",
"content": "Remember to consider Fluency and Coherence, Lexical Resource, Grammatical Range and Accuracy, "
"and Pronunciation when grading the response."
}
])
return messages
def get_question_gen_messages(question_type: QuestionType):
if QuestionType.LISTENING_SECTION_1 == question_type:
return [