Small bugfix to not call OpenAI twice and File Reformat
This commit is contained in:
@@ -349,30 +349,30 @@ def get_question_gen_messages(question_type: QuestionType):
|
||||
def get_question_tips(question: str, answer: str, correct_answer: str, context: str = None):
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"role": "user",
|
||||
"content": "You are a IELTS exam program that analyzes incorrect answers to questions and gives tips to "
|
||||
"help students understand why it was a wrong answer and explains how their thought process "
|
||||
"should have been. The tip should refer to the context and question.",
|
||||
"help students understand why it was a wrong answer and gives helpful insight for the future. "
|
||||
"The tip should refer to the context and question.",
|
||||
}
|
||||
]
|
||||
|
||||
if not (context is None or context == ""):
|
||||
messages.append({
|
||||
"role": "system",
|
||||
"role": "user",
|
||||
"content": f"This is the context for the question: {context}",
|
||||
})
|
||||
|
||||
messages.extend([
|
||||
{
|
||||
"role": "system",
|
||||
"role": "user",
|
||||
"content": f"This is the question: {question}",
|
||||
},
|
||||
{
|
||||
"role": "system",
|
||||
"role": "user",
|
||||
"content": f"This is the answer: {answer}",
|
||||
},
|
||||
{
|
||||
"role": "system",
|
||||
"role": "user",
|
||||
"content": f"This is the correct answer: {correct_answer}",
|
||||
}
|
||||
])
|
||||
|
||||
@@ -53,7 +53,12 @@ def make_openai_call(model, messages, token_count, fields_to_check, temperature)
|
||||
frequency_penalty=float(FREQUENCY_PENALTY),
|
||||
messages=messages
|
||||
)
|
||||
|
||||
if fields_to_check is None:
|
||||
return result["choices"][0]["message"]["content"]
|
||||
|
||||
processed_response = process_response(result["choices"][0]["message"]["content"], fields_to_check[0])
|
||||
|
||||
if check_fields(processed_response, fields_to_check) is False and try_count < TRY_LIMIT:
|
||||
try_count = try_count + 1
|
||||
return make_openai_call(model, messages, token_count, fields_to_check, temperature)
|
||||
|
||||
Reference in New Issue
Block a user