rameshmoorthy commited on
Commit
e6a997e
1 Parent(s): 4825c3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -35
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
- break
348
- except Exception as e:
349
- count+=1
350
- print(f"Exception occurred: {e}")
351
- print("Trying again...please wait")
352
- continue
353
 
354
- print(response)
355
- print('output json', output_json)
356
-
357
- global quiz_data
358
-
359
- quiz_data = output_json
360
-
361
- question_radio_list = []
362
-
363
- for question_num in range(1, 11):
364
- question_key = f"Q{question_num}"
365
- answer_key = f"A{question_num}"
366
-
367
- question = quiz_data.get(question_key)
368
- answer = quiz_data.get(quiz_data.get(answer_key))
369
-
370
- if not question or not answer:
371
- continue
372
-
373
- choice_keys = [f"{question_key}:C{i}" for i in range(1, 5)]
374
- choice_list = []
375
- for choice_key in choice_keys:
376
- choice = quiz_data.get(choice_key, "Choice not found")
377
- choice_list.append(f"{choice}")
378
-
379
- radio = gr.Radio(choices=choice_list, label=question,
380
- visible=True, interactive=True)
381
-
382
- question_radio_list.append(radio)
 
 
 
 
 
 
 
 
 
 
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