Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -344,42 +344,47 @@ with gr.Blocks(title="Quiz Maker", theme=gr.themes.Default(primary_hue="green",
|
|
| 344 |
formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False,
|
| 345 |
)
|
| 346 |
output_json = json.loads(f"{response}")
|
| 347 |
-
|
| 348 |
-
except Exception as e:
|
| 349 |
-
count+=1
|
| 350 |
-
print(f"Exception occurred: {e}")
|
| 351 |
-
print("Trying again...please wait")
|
| 352 |
-
continue
|
| 353 |
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
print('Question radio list ' , question_radio_list)
|
| 385 |
|
|
|
|
| 344 |
formatted_prompt, **generate_kwargs, stream=False, details=False, return_full_text=False,
|
| 345 |
)
|
| 346 |
output_json = json.loads(f"{response}")
|
| 347 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
|
| 349 |
+
print(response)
|
| 350 |
+
print('output json', output_json)
|
| 351 |
+
|
| 352 |
+
global quiz_data
|
| 353 |
+
|
| 354 |
+
quiz_data = output_json
|
| 355 |
+
|
| 356 |
+
question_radio_list = []
|
| 357 |
+
|
| 358 |
+
for question_num in range(1, 11):
|
| 359 |
+
question_key = f"Q{question_num}"
|
| 360 |
+
answer_key = f"A{question_num}"
|
| 361 |
+
|
| 362 |
+
question = quiz_data.get(question_key)
|
| 363 |
+
answer = quiz_data.get(quiz_data.get(answer_key))
|
| 364 |
+
|
| 365 |
+
if not question or not answer:
|
| 366 |
+
continue
|
| 367 |
+
|
| 368 |
+
choice_keys = [f"{question_key}:C{i}" for i in range(1, 5)]
|
| 369 |
+
choice_list = []
|
| 370 |
+
for choice_key in choice_keys:
|
| 371 |
+
choice = quiz_data.get(choice_key, "Choice not found")
|
| 372 |
+
choice_list.append(f"{choice}")
|
| 373 |
+
|
| 374 |
+
radio = gr.Radio(choices=choice_list, label=question,
|
| 375 |
+
visible=True, interactive=True)
|
| 376 |
+
|
| 377 |
+
question_radio_list.append(radio)
|
| 378 |
+
if len(question_radio_list)==10:
|
| 379 |
+
break
|
| 380 |
+
else:
|
| 381 |
+
print('10 questions not generated . So trying again!')
|
| 382 |
+
continue
|
| 383 |
+
except Exception as e:
|
| 384 |
+
count+=1
|
| 385 |
+
print(f"Exception occurred: {e}")
|
| 386 |
+
print("Trying again...please wait")
|
| 387 |
+
continue
|
| 388 |
|
| 389 |
print('Question radio list ' , question_radio_list)
|
| 390 |
|