Fix reading exercise with more than 3 words.

This commit is contained in:
Cristiano Ferreira
2024-03-24 00:41:55 +00:00
parent 73532d5fed
commit 6aba83f3bb
2 changed files with 160 additions and 117 deletions

59
app.py
View File

@@ -231,7 +231,7 @@ def grade_writing_task_1():
token_count = count_tokens(message)["n_tokens"]
response = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, message, token_count,
["comment"],
GEN_QUESTION_TEMPERATURE)
GRADING_TEMPERATURE)
response['fixed_text'] = get_fixed_text(answer)
return response
else:
@@ -707,24 +707,7 @@ def get_reading_passage_1_question():
topic = request.args.get('topic', default=random.choice(topics))
req_exercises = request.args.getlist('exercises')
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
if (len(req_exercises) == 0):
req_exercises = random.sample(READING_EXERCISE_TYPES, 2)
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_1_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_1, topic)
app.logger.info("Generated passage: " + str(passage))
start_id = 1
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id, difficulty)
return {
"exercises": exercises,
"text": {
"content": passage["text"],
"title": passage["title"]
},
"difficulty": difficulty
}
return gen_reading_passage_1(topic, req_exercises, difficulty)
except Exception as e:
return str(e)
@@ -737,24 +720,7 @@ def get_reading_passage_2_question():
topic = request.args.get('topic', default=random.choice(topics))
req_exercises = request.args.getlist('exercises')
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
if (len(req_exercises) == 0):
req_exercises = random.sample(READING_EXERCISE_TYPES, 2)
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_2_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_2, topic)
app.logger.info("Generated passage: " + str(passage))
start_id = 14
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id, difficulty)
return {
"exercises": exercises,
"text": {
"content": passage["text"],
"title": passage["title"]
},
"difficulty": difficulty
}
return gen_reading_passage_2(topic, req_exercises, difficulty)
except Exception as e:
return str(e)
@@ -767,24 +733,7 @@ def get_reading_passage_3_question():
topic = request.args.get('topic', default=random.choice(topics))
req_exercises = request.args.getlist('exercises')
difficulty = request.args.get("difficulty", default=random.choice(difficulties))
if (len(req_exercises) == 0):
req_exercises = random.sample(READING_EXERCISE_TYPES, 2)
number_of_exercises_q = divide_number_into_parts(TOTAL_READING_PASSAGE_3_EXERCISES, len(req_exercises))
passage = generate_reading_passage(QuestionType.READING_PASSAGE_3, topic)
app.logger.info("Generated passage: " + str(passage))
start_id = 27
exercises = generate_reading_exercises(passage["text"], req_exercises, number_of_exercises_q, start_id, difficulty)
return {
"exercises": exercises,
"text": {
"content": passage["text"],
"title": passage["title"]
},
"difficulty": difficulty
}
return gen_reading_passage_3(topic, req_exercises, difficulty)
except Exception as e:
return str(e)