9
app.py
9
app.py
@@ -53,7 +53,7 @@ def get_listening_section_1_question():
|
||||
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
|
||||
|
||||
if (len(req_exercises) == 0):
|
||||
req_exercises = random.sample(LISTENING_EXERCISE_TYPES, 1)
|
||||
req_exercises = random.sample(LISTENING_1_EXERCISE_TYPES, 1)
|
||||
|
||||
number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_1_EXERCISES, len(req_exercises))
|
||||
|
||||
@@ -62,7 +62,8 @@ def get_listening_section_1_question():
|
||||
app.logger.info("Generated conversation: " + str(processed_conversation))
|
||||
|
||||
start_id = 1
|
||||
exercises = generate_listening_conversation_exercises(parse_conversation(processed_conversation), req_exercises,
|
||||
exercises = generate_listening_conversation_exercises(parse_conversation(processed_conversation),
|
||||
req_exercises,
|
||||
number_of_exercises_q,
|
||||
start_id, difficulty)
|
||||
return {
|
||||
@@ -85,7 +86,7 @@ def get_listening_section_2_question():
|
||||
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
|
||||
|
||||
if (len(req_exercises) == 0):
|
||||
req_exercises = random.sample(LISTENING_EXERCISE_TYPES, 2)
|
||||
req_exercises = random.sample(LISTENING_2_EXERCISE_TYPES, 2)
|
||||
|
||||
number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_2_EXERCISES, len(req_exercises))
|
||||
|
||||
@@ -115,7 +116,7 @@ def get_listening_section_3_question():
|
||||
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
|
||||
|
||||
if (len(req_exercises) == 0):
|
||||
req_exercises = random.sample(LISTENING_EXERCISE_TYPES, 1)
|
||||
req_exercises = random.sample(LISTENING_3_EXERCISE_TYPES, 1)
|
||||
|
||||
number_of_exercises_q = divide_number_into_parts(TOTAL_LISTENING_SECTION_3_EXERCISES, len(req_exercises))
|
||||
|
||||
|
||||
@@ -19,6 +19,11 @@ GEN_TEXT_FIELDS = ['title']
|
||||
LISTENING_GEN_FIELDS = ['transcript', 'exercise']
|
||||
READING_EXERCISE_TYPES = ['fillBlanks', 'writeBlanks', 'trueFalse', 'paragraphMatch']
|
||||
LISTENING_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksForm']
|
||||
LISTENING_1_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksFill',
|
||||
'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm', 'writeBlanksForm']
|
||||
LISTENING_2_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions']
|
||||
LISTENING_3_EXERCISE_TYPES = ['multipleChoice3Options', 'writeBlanksQuestions']
|
||||
LISTENING_4_EXERCISE_TYPES = ['multipleChoice', 'writeBlanksQuestions', 'writeBlanksFill', 'writeBlanksForm']
|
||||
|
||||
TOTAL_READING_PASSAGE_1_EXERCISES = 13
|
||||
TOTAL_READING_PASSAGE_2_EXERCISES = 13
|
||||
|
||||
@@ -283,6 +283,16 @@ def generate_listening_1_conversation(topic: str):
|
||||
'Make sure that the generated conversation does not contain forbidden subjects in '
|
||||
'muslim countries.')
|
||||
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": 'Try to have misleading discourse (refer multiple dates, multiple colors and etc).'
|
||||
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": 'Try to have spelling of names (cities, people, etc)'
|
||||
|
||||
}
|
||||
]
|
||||
token_count = count_total_tokens(messages)
|
||||
@@ -400,7 +410,7 @@ def generate_listening_4_monologue(topic: str):
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
'Generate a comprehensive monologue on the academic subject '
|
||||
'Generate a comprehensive and complex monologue on the academic subject '
|
||||
'of: "' + topic + '". Make sure that the generated monologue does not contain forbidden subjects in '
|
||||
'muslim countries.')
|
||||
|
||||
@@ -467,7 +477,12 @@ def generate_listening_conversation_exercises(conversation: str, req_exercises:
|
||||
|
||||
if req_exercise == "multipleChoice":
|
||||
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id,
|
||||
difficulty)
|
||||
difficulty, 4)
|
||||
exercises.append(question)
|
||||
print("Added multiple choice: " + str(question))
|
||||
elif req_exercise == "multipleChoice3Options":
|
||||
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id,
|
||||
difficulty, 3)
|
||||
exercises.append(question)
|
||||
print("Added multiple choice: " + str(question))
|
||||
elif req_exercise == "writeBlanksQuestions":
|
||||
@@ -723,7 +738,7 @@ def assign_letters_to_paragraphs(paragraphs):
|
||||
return result
|
||||
|
||||
|
||||
def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty):
|
||||
def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty, n_options=4):
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
@@ -737,7 +752,7 @@ def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
'Generate ' + str(quantity) + ' ' + difficulty + ' difficulty multiple choice questions of 4 options '
|
||||
'Generate ' + str(quantity) + ' ' + difficulty + ' difficulty multiple choice questions of ' + str(n_options) + ' options '
|
||||
'of for this conversation:\n"' + text + '"')
|
||||
|
||||
}
|
||||
@@ -753,7 +768,7 @@ def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int
|
||||
}
|
||||
|
||||
|
||||
def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty):
|
||||
def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty, n_options=4):
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
@@ -768,7 +783,7 @@ def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, s
|
||||
"role": "user",
|
||||
"content": (
|
||||
'Generate ' + str(
|
||||
quantity) + ' ' + difficulty + ' difficulty multiple choice questions of 4 options '
|
||||
quantity) + ' ' + difficulty + ' difficulty multiple choice questions of ' + str(n_options) + ' options '
|
||||
'of for this monologue:\n"' + text + '"')
|
||||
|
||||
}
|
||||
@@ -951,13 +966,19 @@ def gen_write_blanks_form_exercise_listening_conversation(text: str, quantity: i
|
||||
"role": "system",
|
||||
"content": (
|
||||
'You are a helpful assistant designed to output JSON on this format: '
|
||||
'{"form": ["key: value", "key2: value"]}')
|
||||
'{"form": ["key": "value", "key2": "value"]}')
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
'Generate a form with ' + str(
|
||||
quantity) + ' ' + difficulty + ' difficulty key-value pairs about this conversation:\n"' + text + '"')
|
||||
quantity) + ' entries with information about this conversation:\n"' + text + '"')
|
||||
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": 'It must be a form and not questions. '
|
||||
'Example: {"form": ["Color of car": "blue", "Brand of car": "toyota"]}'
|
||||
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user