ambrosfitz commited on
Commit
b5ae83c
·
verified ·
1 Parent(s): 71a2b31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from question_generator import generate_microbiology_question
3
  import logging
 
4
 
5
  # Set up logging
6
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
@@ -22,8 +23,9 @@ def generate_question():
22
  "" # Clear any previous error messages
23
  )
24
  except Exception as e:
25
- logging.error(f"Error generating question: {e}", exc_info=True)
26
- return ("Error generating question. Please try again.", "", "", "", "", "", str(e))
 
27
 
28
  def check_answer(choice):
29
  if current_question is None:
@@ -57,7 +59,7 @@ with gr.Blocks() as demo:
57
  result = gr.Textbox(label="Result", lines=10)
58
 
59
  with gr.Row():
60
- error_message = gr.Textbox(label="Error", lines=2)
61
 
62
  generate_btn.click(
63
  generate_question,
 
1
  import gradio as gr
2
  from question_generator import generate_microbiology_question
3
  import logging
4
+ import traceback
5
 
6
  # Set up logging
7
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
23
  "" # Clear any previous error messages
24
  )
25
  except Exception as e:
26
+ error_message = f"Error generating question: {str(e)}\n\n{traceback.format_exc()}"
27
+ logging.error(error_message)
28
+ return ("Error generating question. Please try again.", "", "", "", "", "", error_message)
29
 
30
  def check_answer(choice):
31
  if current_question is None:
 
59
  result = gr.Textbox(label="Result", lines=10)
60
 
61
  with gr.Row():
62
+ error_message = gr.Textbox(label="Error", lines=5)
63
 
64
  generate_btn.click(
65
  generate_question,