Add topic choice for writing and speaking

This commit is contained in:
Cristiano Ferreira
2024-02-12 18:54:58 +00:00
parent f3f9415665
commit a200b29dba
2 changed files with 70 additions and 8 deletions

23
app.py
View File

@@ -251,9 +251,11 @@ def grade_writing_task_1():
@jwt_required()
def get_writing_task_1_general_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
topic = request.args.get("topic", default=random.choice(mti_topics))
try:
gen_wt1_question = "Craft a prompt for an IELTS Writing Task 1 General Training exercise that instructs the " \
"student to compose a letter. The prompt should present a specific scenario or situation, " \
"based on the topic of '" + topic + "', "\
"requiring the student to provide information, advice, or instructions within the letter. " \
"Make sure that the generated prompt is of " + difficulty + " difficulty and does not contain forbidden subjects in muslim countries."
token_count = count_tokens(gen_wt1_question)["n_tokens"]
@@ -261,7 +263,8 @@ def get_writing_task_1_general_question():
GEN_QUESTION_TEMPERATURE)
return {
"question": response.strip(),
"difficulty": difficulty
"difficulty": difficulty,
"topic": topic
}
except Exception as e:
return str(e)
@@ -309,9 +312,10 @@ def grade_writing_task_2():
@jwt_required()
def get_writing_task_2_general_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
topic = request.args.get("topic", default=random.choice(mti_topics))
try:
gen_wt2_question = "Craft a comprehensive question of " + difficulty + " difficulty for IELTS Writing Task 2 General Training that directs the candidate " \
"to delve into an in-depth analysis of contrasting perspectives on a specific topic. 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."
@@ -320,7 +324,8 @@ def get_writing_task_2_general_question():
GEN_QUESTION_TEMPERATURE)
return {
"question": response.strip(),
"difficulty": difficulty
"difficulty": difficulty,
"topic": topic
}
except Exception as e:
return str(e)
@@ -403,9 +408,10 @@ def grade_speaking_task_1():
@jwt_required()
def get_speaking_task_1_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
topic = request.args.get("topic", default=random.choice(mti_topics))
try:
gen_sp1_question = "Craft a thought-provoking question of " + difficulty + " difficulty for IELTS Speaking Part 1 that encourages candidates to delve deeply " \
"into personal experiences, preferences, or insights on diverse topics. Instruct the candidate to offer " \
"into personal experiences, preferences, or insights on the topic of '" + topic + "'. Instruct the candidate to offer " \
"not only detailed descriptions but also provide nuanced explanations, examples, or anecdotes to enrich " \
"their response. Make sure that the generated question does not contain forbidden subjects in muslim countries." \
"Provide your response in this json format: {'topic': 'topic','question': 'question'}"
@@ -414,6 +420,7 @@ def get_speaking_task_1_question():
GEN_QUESTION_TEMPERATURE)
response["type"] = 1
response["difficulty"] = difficulty
response["topic"] = topic
return response
except Exception as e:
return str(e)
@@ -476,9 +483,10 @@ def grade_speaking_task_2():
@jwt_required()
def get_speaking_task_2_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
topic = request.args.get("topic", default=random.choice(mti_topics))
try:
gen_sp2_question = "Create a question of " + difficulty + " difficulty for IELTS Speaking Part 2 that encourages candidates to narrate a personal experience " \
"or story related to a randomly selected topic. Include 3 prompts that guide the candidate to describe " \
"or story related to the topic of '" + topic + "'. Include 3 prompts that guide the candidate to describe " \
"specific aspects of the experience, such as details about the situation, their actions, and the " \
"reasons it left a lasting impression. Make sure that the generated question does not contain forbidden subjects in muslim countries." \
"Provide your response in this json format: {'topic': 'topic','question': 'question', " \
@@ -488,6 +496,7 @@ def get_speaking_task_2_question():
GEN_QUESTION_TEMPERATURE)
response["type"] = 2
response["difficulty"] = difficulty
response["topic"] = topic
return response
except Exception as e:
return str(e)
@@ -497,9 +506,10 @@ def get_speaking_task_2_question():
@jwt_required()
def get_speaking_task_3_question():
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
topic = request.args.get("topic", default=random.choice(mti_topics))
try:
gen_sp3_question = "Formulate a set of 3 questions of " + difficulty + " difficulty for IELTS Speaking Part 3 that encourage candidates to engage in a " \
"meaningful discussion on a particular topic. Provide inquiries, ensuring " \
"meaningful discussion on the topic of '" + topic + "'. Provide inquiries, ensuring " \
"they explore various aspects, perspectives, and implications related to the topic. " \
"Make sure that the generated question does not contain forbidden subjects in muslim countries." \
"Provide your response in this json format: {'topic': 'topic','questions': ['question', " \
@@ -512,6 +522,7 @@ def get_speaking_task_3_question():
question in response["questions"]]
response["type"] = 3
response["difficulty"] = difficulty
response["topic"] = topic
return response
except Exception as e:
return str(e)