Add difficulty settings for generation
This commit is contained in:
@@ -106,6 +106,8 @@ FEMALE_VOICES = [item for item in ALL_VOICES if item.get('Gender') == 'Female']
|
||||
MALE_NEURAL_VOICES = [item for item in ALL_NEURAL_VOICES if item.get('Gender') == 'Male']
|
||||
FEMALE_NEURAL_VOICES = [item for item in ALL_NEURAL_VOICES if item.get('Gender') == 'Female']
|
||||
|
||||
difficulties = ["easy", "medium", "hard"]
|
||||
|
||||
topics = [
|
||||
"Art and Creativity",
|
||||
"History of Ancient Civilizations",
|
||||
|
||||
@@ -292,25 +292,25 @@ def generate_listening_4_monologue(topic: str):
|
||||
return response
|
||||
|
||||
|
||||
def generate_reading_exercises(passage: str, req_exercises: list, number_of_exercises_q, start_id):
|
||||
def generate_reading_exercises(passage: str, req_exercises: list, number_of_exercises_q, start_id, difficulty):
|
||||
exercises = []
|
||||
for req_exercise in req_exercises:
|
||||
number_of_exercises = number_of_exercises_q.get()
|
||||
|
||||
if req_exercise == "multipleChoice":
|
||||
question = gen_multiple_choice_exercise(passage, number_of_exercises, start_id)
|
||||
question = gen_multiple_choice_exercise(passage, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added multiple choice: " + str(question))
|
||||
elif req_exercise == "fillBlanks":
|
||||
question = gen_summary_fill_blanks_exercise(passage, number_of_exercises, start_id)
|
||||
question = gen_summary_fill_blanks_exercise(passage, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added fill blanks: " + str(question))
|
||||
elif req_exercise == "trueFalse":
|
||||
question = gen_true_false_not_given_exercise(passage, number_of_exercises, start_id)
|
||||
question = gen_true_false_not_given_exercise(passage, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added trueFalse: " + str(question))
|
||||
elif req_exercise == "writeBlanks":
|
||||
question = gen_write_blanks_exercise(passage, number_of_exercises, start_id)
|
||||
question = gen_write_blanks_exercise(passage, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks: " + str(question))
|
||||
|
||||
@@ -319,28 +319,28 @@ def generate_reading_exercises(passage: str, req_exercises: list, number_of_exer
|
||||
return exercises
|
||||
|
||||
|
||||
def generate_listening_conversation_exercises(conversation: str, req_exercises: list, number_of_exercises_q, start_id):
|
||||
def generate_listening_conversation_exercises(conversation: str, req_exercises: list, number_of_exercises_q, start_id, difficulty):
|
||||
exercises = []
|
||||
for req_exercise in req_exercises:
|
||||
number_of_exercises = number_of_exercises_q.get()
|
||||
|
||||
if req_exercise == "multipleChoice":
|
||||
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id)
|
||||
question = gen_multiple_choice_exercise_listening_conversation(conversation, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added multiple choice: " + str(question))
|
||||
elif req_exercise == "writeBlanksQuestions":
|
||||
question = gen_write_blanks_questions_exercise_listening_conversation(conversation, number_of_exercises,
|
||||
start_id)
|
||||
start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks questions: " + str(question))
|
||||
elif req_exercise == "writeBlanksFill":
|
||||
question = gen_write_blanks_notes_exercise_listening_conversation(conversation, number_of_exercises,
|
||||
start_id)
|
||||
start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks notes: " + str(question))
|
||||
elif req_exercise == "writeBlanksForm":
|
||||
question = gen_write_blanks_form_exercise_listening_conversation(conversation, number_of_exercises,
|
||||
start_id)
|
||||
start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks form: " + str(question))
|
||||
|
||||
@@ -349,25 +349,25 @@ def generate_listening_conversation_exercises(conversation: str, req_exercises:
|
||||
return exercises
|
||||
|
||||
|
||||
def generate_listening_monologue_exercises(monologue: str, req_exercises: list, number_of_exercises_q, start_id):
|
||||
def generate_listening_monologue_exercises(monologue: str, req_exercises: list, number_of_exercises_q, start_id, difficulty):
|
||||
exercises = []
|
||||
for req_exercise in req_exercises:
|
||||
number_of_exercises = number_of_exercises_q.get()
|
||||
|
||||
if req_exercise == "multipleChoice":
|
||||
question = gen_multiple_choice_exercise_listening_monologue(monologue, number_of_exercises, start_id)
|
||||
question = gen_multiple_choice_exercise_listening_monologue(monologue, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added multiple choice: " + str(question))
|
||||
elif req_exercise == "writeBlanksQuestions":
|
||||
question = gen_write_blanks_questions_exercise_listening_monologue(monologue, number_of_exercises, start_id)
|
||||
question = gen_write_blanks_questions_exercise_listening_monologue(monologue, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks questions: " + str(question))
|
||||
elif req_exercise == "writeBlanksFill":
|
||||
question = gen_write_blanks_notes_exercise_listening_monologue(monologue, number_of_exercises, start_id)
|
||||
question = gen_write_blanks_notes_exercise_listening_monologue(monologue, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks notes: " + str(question))
|
||||
elif req_exercise == "writeBlanksForm":
|
||||
question = gen_write_blanks_form_exercise_listening_monologue(monologue, number_of_exercises, start_id)
|
||||
question = gen_write_blanks_form_exercise_listening_monologue(monologue, number_of_exercises, start_id, difficulty)
|
||||
exercises.append(question)
|
||||
print("Added write blanks form: " + str(question))
|
||||
|
||||
@@ -376,8 +376,8 @@ def generate_listening_monologue_exercises(monologue: str, req_exercises: list,
|
||||
return exercises
|
||||
|
||||
|
||||
def gen_multiple_choice_exercise(text: str, quantity: int, start_id):
|
||||
gen_multiple_choice_for_text = "Generate " + str(quantity) + " multiple choice questions for this text: " \
|
||||
def gen_multiple_choice_exercise(text: str, quantity: int, start_id, difficulty):
|
||||
gen_multiple_choice_for_text = "Generate " + str(quantity) + " " + difficulty + " difficulty multiple choice questions for this text: " \
|
||||
"'" + text + "'\n" \
|
||||
"Use this format: \"questions\": [{\"id\": \"9\", \"options\": [{\"id\": \"A\", \"text\": " \
|
||||
"\"Economic benefits\"}, {\"id\": \"B\", \"text\": \"Government regulations\"}, {\"id\": \"C\", \"text\": " \
|
||||
@@ -405,7 +405,7 @@ def gen_multiple_choice_exercise(text: str, quantity: int, start_id):
|
||||
}
|
||||
|
||||
|
||||
def gen_summary_fill_blanks_exercise(text: str, quantity: int, start_id):
|
||||
def gen_summary_fill_blanks_exercise(text: str, quantity: int, start_id, difficulty):
|
||||
gen_summary_for_text = "Summarize this text: " + text
|
||||
token_count = count_tokens(gen_summary_for_text)["n_tokens"]
|
||||
text_summary = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_summary_for_text, token_count,
|
||||
@@ -413,7 +413,7 @@ def gen_summary_fill_blanks_exercise(text: str, quantity: int, start_id):
|
||||
GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
gen_words_to_replace = "Select " + str(
|
||||
quantity) + " words, it must be words and not expressions, from the summary and respond in this " \
|
||||
quantity) + " " + difficulty + " difficulty words, it must be words and not expressions, from the summary and respond in this " \
|
||||
"JSON format: { \"words\": [\"word_1\", \"word_2\"] }. The summary is: " + text_summary
|
||||
token_count = count_tokens(gen_words_to_replace)["n_tokens"]
|
||||
words_to_replace = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_words_to_replace, token_count,
|
||||
@@ -437,9 +437,9 @@ def gen_summary_fill_blanks_exercise(text: str, quantity: int, start_id):
|
||||
}
|
||||
|
||||
|
||||
def gen_true_false_not_given_exercise(text: str, quantity: int, start_id):
|
||||
def gen_true_false_not_given_exercise(text: str, quantity: int, start_id, difficulty):
|
||||
gen_true_false_not_given = "Generate " + str(
|
||||
quantity) + " statements in JSON format (True, False, or Not Given) " \
|
||||
quantity) + " " + difficulty + " difficulty statements in JSON format (True, False, or Not Given) " \
|
||||
"based on the provided text. Ensure that your statements " \
|
||||
"accurately represent information or inferences from the " \
|
||||
"text, and provide a variety of responses, including, at least one of each True, " \
|
||||
@@ -466,8 +466,8 @@ def gen_true_false_not_given_exercise(text: str, quantity: int, start_id):
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_exercise(text: str, quantity: int, start_id):
|
||||
gen_short_answer_questions = "Generate " + str(quantity) + " short answer questions, and the possible answers " \
|
||||
def gen_write_blanks_exercise(text: str, quantity: int, start_id, difficulty):
|
||||
gen_short_answer_questions = "Generate " + str(quantity) + " " + difficulty + " difficulty short answer questions, and the possible answers " \
|
||||
"(max 3 words per answer), about this text: '" + text + "'. " \
|
||||
"Provide your answer in this JSON format: {\"questions\": [{\"question\": question, " \
|
||||
"\"possible_answers\": [\"answer_1\", \"answer_2\"]}]}"
|
||||
@@ -487,9 +487,9 @@ def gen_write_blanks_exercise(text: str, quantity: int, start_id):
|
||||
}
|
||||
|
||||
|
||||
def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id):
|
||||
def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty):
|
||||
gen_multiple_choice_for_text = "Generate " + str(
|
||||
quantity) + " multiple choice questions of 4 options for this conversation: " \
|
||||
quantity) + " " + difficulty + " difficulty multiple choice questions of 4 options of for this conversation: " \
|
||||
"'" + text + "'"
|
||||
token_count = count_tokens(gen_multiple_choice_for_text)["n_tokens"]
|
||||
mc_questions = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_multiple_choice_for_text, token_count,
|
||||
@@ -512,8 +512,8 @@ def gen_multiple_choice_exercise_listening_conversation(text: str, quantity: int
|
||||
}
|
||||
|
||||
|
||||
def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id):
|
||||
gen_multiple_choice_for_text = "Generate " + str(quantity) + " multiple choice questions for this monologue: " \
|
||||
def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty):
|
||||
gen_multiple_choice_for_text = "Generate " + str(quantity) + " " + difficulty + " difficulty multiple choice questions for this monologue: " \
|
||||
"'" + text + "'"
|
||||
token_count = count_tokens(gen_multiple_choice_for_text)["n_tokens"]
|
||||
mc_questions = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_multiple_choice_for_text, token_count,
|
||||
@@ -536,8 +536,8 @@ def gen_multiple_choice_exercise_listening_monologue(text: str, quantity: int, s
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_questions_exercise_listening_conversation(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_questions = "Generate " + str(quantity) + " short answer questions, and the possible answers " \
|
||||
def gen_write_blanks_questions_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_questions = "Generate " + str(quantity) + " " + difficulty + " difficulty short answer questions, and the possible answers " \
|
||||
"(max 3 words per answer), about a monologue and" \
|
||||
"respond in this JSON format: {\"questions\": [{\"question\": question, " \
|
||||
"\"possible_answers\": [\"answer_1\", \"answer_2\"]}]}." \
|
||||
@@ -558,8 +558,8 @@ def gen_write_blanks_questions_exercise_listening_conversation(text: str, quanti
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_questions_exercise_listening_monologue(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_questions = "Generate " + str(quantity) + " short answer questions, and the possible answers " \
|
||||
def gen_write_blanks_questions_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_questions = "Generate " + str(quantity) + " " + difficulty + " difficulty short answer questions, and the possible answers " \
|
||||
"(max 3 words per answer), about a monologue and" \
|
||||
"respond in this JSON format: {\"questions\": [{\"question\": question, " \
|
||||
"\"possible_answers\": [\"answer_1\", \"answer_2\"]}]}." \
|
||||
@@ -580,8 +580,8 @@ def gen_write_blanks_questions_exercise_listening_monologue(text: str, quantity:
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_notes_exercise_listening_conversation(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_notes = "Generate " + str(quantity) + " notes taken from the conversation and and respond in this " \
|
||||
def gen_write_blanks_notes_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_notes = "Generate " + str(quantity) + " " + difficulty + " difficulty notes taken from the conversation and and respond in this " \
|
||||
"JSON format: { \"notes\": [\"note_1\", \"note_2\"] }. The monologue is this: '" + text + "'"
|
||||
|
||||
token_count = count_tokens(gen_write_blanks_notes)["n_tokens"]
|
||||
@@ -605,8 +605,8 @@ def gen_write_blanks_notes_exercise_listening_conversation(text: str, quantity:
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_notes_exercise_listening_monologue(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_notes = "Generate " + str(quantity) + " notes taken from the monologue and and respond in this " \
|
||||
def gen_write_blanks_notes_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_notes = "Generate " + str(quantity) + " " + difficulty + " difficulty notes taken from the monologue and respond in this " \
|
||||
"JSON format: { \"notes\": [\"note_1\", \"note_2\"] }. The monologue is this: '" + text + "'"
|
||||
|
||||
token_count = count_tokens(gen_write_blanks_notes)["n_tokens"]
|
||||
@@ -630,8 +630,8 @@ def gen_write_blanks_notes_exercise_listening_monologue(text: str, quantity: int
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_form_exercise_listening_conversation(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_form = "Generate a form with " + str(quantity) + " key-value pairs about the conversation. " \
|
||||
def gen_write_blanks_form_exercise_listening_conversation(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_form = "Generate a form with " + str(quantity) + " " + difficulty + " difficulty key-value pairs about the conversation. " \
|
||||
"The conversation is this: '" + text + "'"
|
||||
token_count = count_tokens(gen_write_blanks_form)["n_tokens"]
|
||||
form = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_write_blanks_form, token_count,
|
||||
@@ -653,8 +653,8 @@ def gen_write_blanks_form_exercise_listening_conversation(text: str, quantity: i
|
||||
}
|
||||
|
||||
|
||||
def gen_write_blanks_form_exercise_listening_monologue(text: str, quantity: int, start_id):
|
||||
gen_write_blanks_form = "Generate a form with " + str(quantity) + " key-value pairs about the monologue. " \
|
||||
def gen_write_blanks_form_exercise_listening_monologue(text: str, quantity: int, start_id, difficulty):
|
||||
gen_write_blanks_form = "Generate a form with " + str(quantity) + " " + difficulty + " difficulty key-value pairs about the monologue. " \
|
||||
"The monologue is this: '" + text + "'"
|
||||
token_count = count_tokens(gen_write_blanks_form)["n_tokens"]
|
||||
form = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_write_blanks_form, token_count,
|
||||
|
||||
Reference in New Issue
Block a user