Add endpoint for custom level exams.
This commit is contained in:
@@ -1330,7 +1330,7 @@ def parse_conversation(conversation_data):
|
||||
return "\n".join(readable_text)
|
||||
|
||||
|
||||
def gen_multiple_choice_blank_space_utas(quantity: int, start_id: int, all_exams):
|
||||
def gen_multiple_choice_blank_space_utas(quantity: int, start_id: int, all_exams=None):
|
||||
gen_multiple_choice_for_text = "Generate " + str(
|
||||
quantity) + " multiple choice blank space questions of 4 options for an english level exam, some easy questions, some intermediate " \
|
||||
"questions and some advanced questions. Ensure that the questions cover a range of topics such as " \
|
||||
@@ -1362,11 +1362,12 @@ def gen_multiple_choice_blank_space_utas(quantity: int, start_id: int, all_exams
|
||||
if len(question["questions"]) != quantity:
|
||||
return gen_multiple_choice_level(quantity, start_id)
|
||||
else:
|
||||
seen_keys = set()
|
||||
for i in range(len(question["questions"])):
|
||||
question["questions"][i], seen_keys = replace_exercise_if_exists_utas(all_exams, question["questions"][i],
|
||||
question,
|
||||
seen_keys)
|
||||
if all_exams is not None:
|
||||
seen_keys = set()
|
||||
for i in range(len(question["questions"])):
|
||||
question["questions"][i], seen_keys = replace_exercise_if_exists_utas(all_exams, question["questions"][i],
|
||||
question,
|
||||
seen_keys)
|
||||
return fix_exercise_ids(question, start_id)
|
||||
|
||||
|
||||
@@ -1436,7 +1437,7 @@ def gen_multiple_choice_underlined_utas(quantity: int, start_id: int):
|
||||
if len(question["questions"]) != quantity:
|
||||
return gen_multiple_choice_level(quantity, start_id)
|
||||
else:
|
||||
return fix_exercise_ids(question, start_id)["questions"]
|
||||
return fix_exercise_ids(question, start_id)
|
||||
|
||||
|
||||
def gen_blank_space_text_utas(quantity: int, start_id: int, size: int, topic=random.choice(mti_topics)):
|
||||
@@ -1590,3 +1591,57 @@ def gen_text_multiple_choice_utas(text: str, start_id: int, mc_quantity: int):
|
||||
return gen_multiple_choice_level(mc_quantity, start_id)
|
||||
else:
|
||||
return fix_exercise_ids(question, start_id)["questions"]
|
||||
|
||||
|
||||
def generate_level_mc(start_id: int, quantity: int):
|
||||
json_format = {
|
||||
"questions": [
|
||||
{
|
||||
"id": "9",
|
||||
"options": [
|
||||
{
|
||||
"id": "A",
|
||||
"text": "a"
|
||||
},
|
||||
{
|
||||
"id": "B",
|
||||
"text": "b"
|
||||
},
|
||||
{
|
||||
"id": "C",
|
||||
"text": "c"
|
||||
},
|
||||
{
|
||||
"id": "D",
|
||||
"text": "d"
|
||||
}
|
||||
],
|
||||
"prompt": "prompt",
|
||||
"solution": "A",
|
||||
"variant": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": 'You are a helpful assistant designed to output JSON on this format: ' + str(json_format)
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": ('Generate ' + str(quantity) + ' multiple choice question of 4 options for an english level '
|
||||
'exam, it can be easy, intermediate or advanced.')
|
||||
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": 'Make sure every question only has 1 correct answer.'
|
||||
}
|
||||
]
|
||||
token_count = count_total_tokens(messages)
|
||||
|
||||
question = make_openai_call(GPT_4_O, messages, token_count, ["questions"],
|
||||
GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
return fix_exercise_ids(question, start_id)
|
||||
|
||||
Reference in New Issue
Block a user