Compare commits
6 Commits
bug/create
...
feature/le
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a931c5ec2e | ||
|
|
a2cfa335d7 | ||
|
|
0427d6e1b4 | ||
|
|
31c6ed570a | ||
|
|
3a27c42a69 | ||
|
|
b2b4dfb74e |
12
.env
12
.env
@@ -1,12 +0,0 @@
|
||||
OPENAI_API_KEY=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
|
||||
JWT_SECRET_KEY=6e9c124ba92e8814719dcb0f21200c8aa4d0f119a994ac5e06eb90a366c83ab2
|
||||
JWT_TEST_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0In0.Emrs2D3BmMP4b3zMjw0fJTPeyMwWEBDbxx2vvaWguO0
|
||||
GOOGLE_APPLICATION_CREDENTIALS=firebase-configs/storied-phalanx-349916.json
|
||||
HEY_GEN_TOKEN=MjY4MDE0MjdjZmNhNDFmYTlhZGRkNmI3MGFlMzYwZDItMTY5NTExNzY3MA==
|
||||
GPT_ZERO_API_KEY=0195b9bb24c5439899f71230809c74af
|
||||
|
||||
FIREBASE_SCRYPT_B64_SIGNER_KEY="vbO3Xii2lajSeSkCstq3s/dCwpXP7J2YN9rP/KRreU2vGOT1fg+wzSuy1kIhBECqJHG82tmwAilSxLFFtNKVMA=="
|
||||
FIREBASE_SCRYPT_B64_SALT_SEPARATOR="Bw=="
|
||||
FIREBASE_SCRYPT_ROUNDS=8
|
||||
FIREBASE_SCRYPT_MEM_COST=14
|
||||
FIREBASE_PROJECT_ID=storied-phalanx-349916
|
||||
@@ -6,8 +6,6 @@ FROM python:3.11-slim
|
||||
# Allow statements and log messages to immediately appear in the logs
|
||||
ENV PYTHONUNBUFFERED True
|
||||
|
||||
ENV GOOGLE_APPLICATION_CREDENTIALS=/app/firebase-configs/storied-phalanx-349916.json
|
||||
|
||||
# Copy local code to the container image.
|
||||
ENV APP_HOME /app
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
9
app.py
9
app.py
@@ -1317,6 +1317,7 @@ class CustomLevelExerciseTypes(Enum):
|
||||
MULTIPLE_CHOICE_4 = "multiple_choice_4"
|
||||
MULTIPLE_CHOICE_BLANK_SPACE = "multiple_choice_blank_space"
|
||||
MULTIPLE_CHOICE_UNDERLINED = "multiple_choice_underlined"
|
||||
FILL_BLANKS_MC = "fill_blanks_mc"
|
||||
BLANK_SPACE_TEXT = "blank_space_text"
|
||||
READING_PASSAGE_UTAS = "reading_passage_utas"
|
||||
WRITING_LETTER = "writing_letter"
|
||||
@@ -1414,6 +1415,14 @@ def get_custom_level():
|
||||
exercise_id = exercise_id + qty
|
||||
exercise_qty = exercise_qty - qty
|
||||
|
||||
elif exercise_type == CustomLevelExerciseTypes.FILL_BLANKS_MC.value:
|
||||
response["exercises"]["exercise_" + str(i)] = gen_fill_blanks_mc_utas(
|
||||
exercise_qty, exercise_id, exercise_text_size
|
||||
)
|
||||
response["exercises"]["exercise_" + str(i)]["type"] = "fillBlanks"
|
||||
response["exercises"]["exercise_" + str(i)]["variant"] = "mc"
|
||||
exercise_id = exercise_id + exercise_qty
|
||||
|
||||
elif exercise_type == CustomLevelExerciseTypes.BLANK_SPACE_TEXT.value:
|
||||
response["exercises"]["exercise_" + str(i)] = gen_blank_space_text_utas(exercise_qty, exercise_id,
|
||||
exercise_text_size)
|
||||
|
||||
@@ -1563,6 +1563,66 @@ def gen_multiple_choice_underlined_utas(quantity: int, start_id: int, all_exams=
|
||||
return response
|
||||
|
||||
|
||||
def gen_fill_blanks_mc_utas(quantity: int, start_id: int, size: int, topic=random.choice(mti_topics)):
|
||||
json_format = {
|
||||
"question": {
|
||||
"solutions": [
|
||||
{
|
||||
"id": "<question id>",
|
||||
"solution": "<the option that holds the solution>"
|
||||
}
|
||||
],
|
||||
"words": [
|
||||
{
|
||||
"id": "<question id>",
|
||||
"options": {
|
||||
"A": "<a option>",
|
||||
"B": "<b option>",
|
||||
"C": "<c option>",
|
||||
"D": "<d option>"
|
||||
}
|
||||
}
|
||||
],
|
||||
"text": "text"
|
||||
}
|
||||
}
|
||||
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": 'You are a helpful assistant designed to output JSON on this format: ' + str(json_format)
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
f'Generate a text of at least {size} words about the topic {topic}. Make sure the text is structured '
|
||||
'in paragraphs formatted with newlines (\\n\\n) to delimit them.'
|
||||
)
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": (
|
||||
f'From the generated text choose {quantity} words (cannot be sequential words) to replace '
|
||||
'once with {{id}} where id starts on ' + str(start_id) + ' and is incremented for each word. '
|
||||
'For each word choose 4 options, 1 correct and the other ones false. Make sure that only 1 is the '
|
||||
'correct one amongst the 4 options and put the solution on the solutions array. '
|
||||
'The ids must be ordered throughout the text and the words must be replaced only once. Put the '
|
||||
'removed words and respective ids on the words array of the json in the correct order. You can\'t '
|
||||
'reference multiple times the same id across the text, if for example one of the chosen words is '
|
||||
'"word1" then word1 must be placed in the text with an id once, if word1 is referenced other '
|
||||
'times in the text then replace with the actual text of word.'
|
||||
)
|
||||
}
|
||||
]
|
||||
|
||||
token_count = count_total_tokens(messages)
|
||||
question = make_openai_call(GPT_4_O, messages, token_count,
|
||||
["question"],
|
||||
GEN_QUESTION_TEMPERATURE)
|
||||
|
||||
return question["question"]
|
||||
|
||||
|
||||
def gen_blank_space_text_utas(quantity: int, start_id: int, size: int, topic=random.choice(mti_topics)):
|
||||
json_format = {
|
||||
"question": {
|
||||
|
||||
Reference in New Issue
Block a user