diff --git a/helper/constants.py b/helper/constants.py index 40f0e50..bb86339 100644 --- a/helper/constants.py +++ b/helper/constants.py @@ -10,6 +10,7 @@ GEN_QUESTION_TEMPERATURE = 0.7 GPT_3_5_TURBO = "gpt-3.5-turbo" GPT_3_5_TURBO_16K = "gpt-3.5-turbo-16k" GPT_3_5_TURBO_INSTRUCT = "gpt-3.5-turbo-instruct" +GPT_4 = "gpt-4" GRADING_FIELDS = ['comment', 'overall', 'task_response'] GEN_FIELDS = ['topic'] diff --git a/helper/exercises.py b/helper/exercises.py index 2f03a02..ee18c60 100644 --- a/helper/exercises.py +++ b/helper/exercises.py @@ -675,7 +675,7 @@ def gen_multiple_choice_level(quantity: int, start_id=1): "questions and some advanced questions. Ensure that the questions cover a range of topics such as " \ "verb tense, subject-verb agreement, pronoun usage, sentence structure, and punctuation." token_count = count_tokens(gen_multiple_choice_for_text)["n_tokens"] - 300 - mc_questions = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_multiple_choice_for_text, token_count, + mc_questions = make_openai_instruct_call(GPT_4, gen_multiple_choice_for_text, token_count, None, GEN_QUESTION_TEMPERATURE) split_mc_questions = mc_questions.split('13') @@ -687,8 +687,8 @@ def gen_multiple_choice_level(quantity: int, start_id=1): '"prompt": "Which of the following is a conjunction?", ' '"solution": "A", "variant": "text"}]}. ' '\nThe questions: "' + split_mc_questions[0] + '"') - token_count = count_tokens(parse_mc_questions, model_name=GPT_3_5_TURBO_INSTRUCT)["n_tokens"] - question = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, parse_mc_questions, token_count, + token_count = count_tokens(parse_mc_questions, model_name=GPT_4)["n_tokens"] + question = make_openai_instruct_call(GPT_4, parse_mc_questions, token_count, ["questions"], GEN_QUESTION_TEMPERATURE) parse_mc_questions = ('Parse the questions into this json format: {"questions": [{"id": "9", "options": ' @@ -698,8 +698,8 @@ def gen_multiple_choice_level(quantity: int, start_id=1): '"prompt": "Which of the following is a conjunction?", ' '"solution": "A", "variant": "text"}]}. ' '\nThe questions: "' + '13' + split_mc_questions[1] + '"') - token_count = count_tokens(parse_mc_questions, model_name=GPT_3_5_TURBO_INSTRUCT)["n_tokens"] - question_2 = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, parse_mc_questions, token_count, + token_count = count_tokens(parse_mc_questions, model_name=GPT_4)["n_tokens"] + question_2 = make_openai_instruct_call(GPT_4, parse_mc_questions, token_count, ["questions"], GEN_QUESTION_TEMPERATURE) question["questions"].extend(question_2["questions"]) @@ -730,7 +730,7 @@ def generate_single_mc_level_question(): gen_multiple_choice_for_text = "Generate 1 multiple choice question of 4 options for an english level exam, it can " \ "be easy, intermediate or advanced." token_count = count_tokens(gen_multiple_choice_for_text)["n_tokens"] - 300 - mc_question = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, gen_multiple_choice_for_text, token_count, + mc_question = make_openai_instruct_call(GPT_4, gen_multiple_choice_for_text, token_count, None, GEN_QUESTION_TEMPERATURE) @@ -742,8 +742,8 @@ def generate_single_mc_level_question(): '"solution": "A", "variant": "text"}. ' '\nThe questions: "' + mc_question + '"') - token_count = count_tokens(parse_mc_question, model_name=GPT_3_5_TURBO_INSTRUCT)["n_tokens"] - question = make_openai_instruct_call(GPT_3_5_TURBO_INSTRUCT, parse_mc_question, token_count, + token_count = count_tokens(parse_mc_question, model_name=GPT_4)["n_tokens"] + question = make_openai_instruct_call(GPT_4, parse_mc_question, token_count, ["options"], GEN_QUESTION_TEMPERATURE) return question