diff --git a/app.py b/app.py index f78cccb..5ec587a 100644 --- a/app.py +++ b/app.py @@ -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) diff --git a/helper/constants.py b/helper/constants.py index dfef39d..7557ee9 100644 --- a/helper/constants.py +++ b/helper/constants.py @@ -108,6 +108,59 @@ FEMALE_NEURAL_VOICES = [item for item in ALL_NEURAL_VOICES if item.get('Gender') difficulties = ["easy", "medium", "hard"] +mti_topics = [ + "Education", + "Technology", + "Environment", + "Health and Fitness", + "Globalization", + "Engineering", + "Work and Careers", + "Travel and Tourism", + "Culture and Traditions", + "Social Issues", + "Arts and Entertainment", + "Climate Change", + "Social Media", + "Sustainable Development", + "Health Care", + "Immigration", + "Artificial Intelligence", + "Consumerism", + "Online Shopping", + "Energy", + "Oil and Gas", + "Poverty and Inequality", + "Cultural Diversity", + "Democracy and Governance", + "Mental Health", + "Ethics and Morality", + "Population Growth", + "Science and Innovation", + "Poverty Alleviation", + "Cybersecurity and Privacy", + "Human Rights", + "Social Justice", + "Food and Agriculture", + "Cyberbullying and Online Safety", + "Linguistic Diversity", + "Urbanization", + "Artificial Intelligence in Education", + "Youth Empowerment", + "Disaster Management", + "Mental Health Stigma", + "Internet Censorship", + "Sustainable Fashion", + "Indigenous Rights", + "Water Scarcity", + "Social Entrepreneurship", + "Privacy in the Digital Age", + "Sustainable Transportation", + "Gender Equality", + "Automation and Job Displacement", + "Digital Divide", + "Education Inequality" +] topics = [ "Art and Creativity", "History of Ancient Civilizations", @@ -615,5 +668,3 @@ academic_subjects = [ "Ecology", "International Business" ] - -