Spaces:
Runtime error
Runtime error
Commit
·
7fcb63d
1
Parent(s):
a5290d5
Update demo.py
Browse files
demo.py
CHANGED
@@ -33,13 +33,13 @@ def get_level_mapping(level):
|
|
33 |
if level is None:
|
34 |
raise gr.Error("Please select a level.")
|
35 |
|
36 |
-
return
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
"
|
41 |
-
|
42 |
-
|
43 |
|
44 |
def generate_fill_gaps(original_text, level, number_of_words, number_of_gaps, number_of_distractors, temperature, language):
|
45 |
"""
|
@@ -85,6 +85,8 @@ def generate_fill_gaps(original_text, level, number_of_words, number_of_gaps, nu
|
|
85 |
"language": language
|
86 |
}
|
87 |
|
|
|
|
|
88 |
output = ""
|
89 |
try:
|
90 |
response = requests.post(
|
@@ -141,10 +143,12 @@ def generate_open_question(original_text, level, temperature, language, question
|
|
141 |
"level": get_level_mapping(level),
|
142 |
"temperature": int(temperature) * 0.2,
|
143 |
"language": language,
|
144 |
-
"
|
145 |
-
"
|
146 |
}
|
147 |
|
|
|
|
|
148 |
output = ""
|
149 |
try:
|
150 |
response = requests.post(
|
@@ -206,7 +210,7 @@ def generate_multiplechoice(original_text, level, number_of_easy_distractors, nu
|
|
206 |
"text": original_text,
|
207 |
"type": bool(exercise_type),
|
208 |
"level": get_level_mapping(level),
|
209 |
-
"
|
210 |
"n_o_ca": int(correct_answers),
|
211 |
"n_o_d": int(number_of_distractors),
|
212 |
"nedd": int(number_of_easy_distractors),
|
@@ -365,7 +369,7 @@ def build_multiplechoice_interface():
|
|
365 |
language = gr.Dropdown(languages, label="Language", value="English")
|
366 |
with gr.Row():
|
367 |
exercise_type = gr.Radio(["Theoretical", "Practical"], label="Exercise type", value="Theoretical", type="index")
|
368 |
-
question_category = gr.Dropdown(categories, label="Question Category", value="Factual Knowledge"
|
369 |
with gr.Row():
|
370 |
correct_answers = gr.Number(value=1, minimum=1, maximum=3, step=1, label="Number of correct answers")
|
371 |
easy_distractors = gr.Number(value=1, minimum=0, maximum=8, step=1, label="Number of easy distractors")
|
@@ -380,12 +384,12 @@ def build_multiplechoice_interface():
|
|
380 |
def update_exercise_type(exercise_type, question_category, number_of_correct_answers):
|
381 |
if exercise_type == 0:
|
382 |
return (
|
383 |
-
gr.Dropdown(categories, label="Question Category", value="Analysys And Evaluation"
|
384 |
gr.Number(value=number_of_correct_answers, minimum=1, maximum=3, step=1, label="Number of correct answers")
|
385 |
)
|
386 |
elif exercise_type == 1:
|
387 |
return (
|
388 |
-
gr.Dropdown(["Analysys And Evaluation"], label="Question Category", value="Analysys And Evaluation"
|
389 |
gr.Number(value=1, minimum=1, maximum=1, step=1, label="Number of correct answers")
|
390 |
)
|
391 |
|
@@ -423,7 +427,7 @@ def build_open_question_interface():
|
|
423 |
language = gr.Dropdown(languages, label="Language", value="English")
|
424 |
with gr.Row():
|
425 |
question_type = gr.Dropdown(["Open", "ShortAnswer", "TrueFalse"], label="Question Type", value="Open", type="index")
|
426 |
-
question_category = gr.Dropdown(categories, label="Question Category", value="Factual Knowledge"
|
427 |
temperature = gr.Checkbox(value=False, label="Increase creativity (decreases preciseness)", visible=False)
|
428 |
with gr.Row():
|
429 |
output = gr.TextArea(placeholder="Generated text", label="Output")
|
|
|
33 |
if level is None:
|
34 |
raise gr.Error("Please select a level.")
|
35 |
|
36 |
+
return levels.index(level)
|
37 |
+
|
38 |
+
def get_category_mapping(category):
|
39 |
+
if category is None:
|
40 |
+
raise gr.Error("Please select a level.")
|
41 |
+
|
42 |
+
return categories.index(category)
|
43 |
|
44 |
def generate_fill_gaps(original_text, level, number_of_words, number_of_gaps, number_of_distractors, temperature, language):
|
45 |
"""
|
|
|
85 |
"language": language
|
86 |
}
|
87 |
|
88 |
+
print(input_json)
|
89 |
+
|
90 |
output = ""
|
91 |
try:
|
92 |
response = requests.post(
|
|
|
143 |
"level": get_level_mapping(level),
|
144 |
"temperature": int(temperature) * 0.2,
|
145 |
"language": language,
|
146 |
+
"type": question_type,
|
147 |
+
"category": get_category_mapping(question_category),
|
148 |
}
|
149 |
|
150 |
+
print(input_json)
|
151 |
+
|
152 |
output = ""
|
153 |
try:
|
154 |
response = requests.post(
|
|
|
210 |
"text": original_text,
|
211 |
"type": bool(exercise_type),
|
212 |
"level": get_level_mapping(level),
|
213 |
+
"category": get_category_mapping(question_category),
|
214 |
"n_o_ca": int(correct_answers),
|
215 |
"n_o_d": int(number_of_distractors),
|
216 |
"nedd": int(number_of_easy_distractors),
|
|
|
369 |
language = gr.Dropdown(languages, label="Language", value="English")
|
370 |
with gr.Row():
|
371 |
exercise_type = gr.Radio(["Theoretical", "Practical"], label="Exercise type", value="Theoretical", type="index")
|
372 |
+
question_category = gr.Dropdown(categories, label="Question Category", value="Factual Knowledge")
|
373 |
with gr.Row():
|
374 |
correct_answers = gr.Number(value=1, minimum=1, maximum=3, step=1, label="Number of correct answers")
|
375 |
easy_distractors = gr.Number(value=1, minimum=0, maximum=8, step=1, label="Number of easy distractors")
|
|
|
384 |
def update_exercise_type(exercise_type, question_category, number_of_correct_answers):
|
385 |
if exercise_type == 0:
|
386 |
return (
|
387 |
+
gr.Dropdown(categories, label="Question Category", value="Analysys And Evaluation"),
|
388 |
gr.Number(value=number_of_correct_answers, minimum=1, maximum=3, step=1, label="Number of correct answers")
|
389 |
)
|
390 |
elif exercise_type == 1:
|
391 |
return (
|
392 |
+
gr.Dropdown(["Analysys And Evaluation"], label="Question Category", value="Analysys And Evaluation"),
|
393 |
gr.Number(value=1, minimum=1, maximum=1, step=1, label="Number of correct answers")
|
394 |
)
|
395 |
|
|
|
427 |
language = gr.Dropdown(languages, label="Language", value="English")
|
428 |
with gr.Row():
|
429 |
question_type = gr.Dropdown(["Open", "ShortAnswer", "TrueFalse"], label="Question Type", value="Open", type="index")
|
430 |
+
question_category = gr.Dropdown(categories, label="Question Category", value="Factual Knowledge")
|
431 |
temperature = gr.Checkbox(value=False, label="Increase creativity (decreases preciseness)", visible=False)
|
432 |
with gr.Row():
|
433 |
output = gr.TextArea(placeholder="Generated text", label="Output")
|