Add Speaking parts.

This commit is contained in:
Cristiano Ferreira
2023-06-29 22:44:03 +01:00
parent 0b661fe108
commit 0a53f2c1b8
3 changed files with 132 additions and 15 deletions

View File

@@ -4,7 +4,8 @@ from enum import Enum
class QuestionType(Enum):
WRITING_TASK_1 = "Writing Task 1"
WRITING_TASK_2 = "Writing Task 2"
SPEAKING = "Speaking Task"
SPEAKING_1 = "Speaking Task Part 1"
SPEAKING_2 = "Speaking Task Part 2"
def get_grading_messages(question_type: QuestionType, question: str, answer: str, context: str = None):
@@ -92,7 +93,7 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
"content": f"Evaluate this answer according to ielts grading system: {answer}",
},
]
elif QuestionType.SPEAKING == question_type:
elif QuestionType.SPEAKING_1 == question_type:
return [
{
"role": "user",
@@ -100,7 +101,44 @@ def get_grading_messages(question_type: QuestionType, question: str, answer: str
},
{
"role": "user",
"content": f"The question you have to grade is of type Speaking and is the following: {question}",
"content": f"The question you have to grade is of type Speaking Task Part 1 and is the following: {question}",
},
{
"role": "user",
"content": "It is mandatory for you to provide your response with the overall grade and breakdown grades, "
"with just 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}}",
},
{
"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, 'Lexical Resource': 6.5, 'Grammatical Range and Accuracy': 7.0,"
" 'Pronunciation': 6.0}}",
},
{
"role": "user",
"content": f"Evaluate this answer according to ielts grading system: {answer}",
},
]
elif QuestionType.SPEAKING_2 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS examiner.",
},
{
"role": "user",
"content": f"The question you have to grade is of type Speaking Task Part 2 and is the following: {question}",
},
{
"role": "user",
@@ -161,7 +199,7 @@ def get_question_gen_messages(question_type: QuestionType):
"content": "Generate a question for IELTS exam Writing Task 2.",
},
]
elif QuestionType.SPEAKING == question_type:
elif QuestionType.SPEAKING_1 == question_type:
return [
{
"role": "user",
@@ -169,7 +207,7 @@ def get_question_gen_messages(question_type: QuestionType):
},
{
"role": "user",
"content": "The question you have to generate is of type Speaking Task.",
"content": "The question you have to generate is of type Speaking Task Part 1.",
},
{
"role": "user",
@@ -178,9 +216,36 @@ def get_question_gen_messages(question_type: QuestionType):
},
{
"role": "user",
"content": "Example output: { 'question': 'Describe someone you know who does something well. You should say "
"who this person is, how do you know this person, what they do well and explain why you think this "
"person is so good at doing this.'}",
"content": "Example output: { 'question': 'Lets talk about your home town or village. "
"What kind of place is it? Whats the most interesting part of your town/village? "
"What kind of jobs do the people in your town/village do? "
"Would you say its a good place to live? (Why?)'}",
},
{
"role": "user",
"content": "Generate a question for IELTS exam Speaking Task.",
},
]
elif QuestionType.SPEAKING_2 == question_type:
return [
{
"role": "user",
"content": "You are a IELTS program that generates questions for the exams.",
},
{
"role": "user",
"content": "The question you have to generate is of type Speaking Task Part 2.",
},
{
"role": "user",
"content": "It is mandatory for you to provide your response with the question "
"just with the following json format: {'question': 'question'}",
},
{
"role": "user",
"content": "Example output: { 'question': 'Describe something you own which is very important to you. "
"You should say: where you got it from how long you have had it what you use it for and "
"explain why it is important to you.'}",
},
{
"role": "user",