NCTCMumbai commited on
Commit
9dfc987
β€’
1 Parent(s): 1fad4eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -205,6 +205,14 @@ def generate_quiz(question_difficulty, topic):
205
  return ['Please enter a valid topic.'] + [gr.Radio(visible=False) for _ in range(10)]
206
 
207
  top_k_rank = 10
 
 
 
 
 
 
 
 
208
  RAG_db_ = RAG_db.value
209
  documents_full = RAG_db_.search(topic, k=top_k_rank)
210
 
@@ -378,9 +386,16 @@ with gr.Blocks(title="Quiz Maker", theme=gr.themes.Default(primary_hue="green",
378
  """)
379
 
380
  with gr.Column(scale=2):
381
- load_btn = gr.Button("Click to Load!πŸš€")
382
- load_text = gr.Textbox()
383
- load_btn.click(fn=load_model, outputs=load_text)
 
 
 
 
 
 
 
384
 
385
  topic = gr.Textbox(label="Enter the Topic for Quiz", placeholder="Write any topic/details from Customs Manual")
386
 
 
205
  return ['Please enter a valid topic.'] + [gr.Radio(visible=False) for _ in range(10)]
206
 
207
  top_k_rank = 10
208
+ # Load the model and database within the generate_quiz function
209
+ try:
210
+ RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")
211
+ RAG_db_ = RAG.from_index('.ragatouille/colbert/indexes/cbseclass10index')
212
+ gr.Warning('Model loaded!')
213
+ except Exception as e:
214
+ return [f"Error loading model: {e}"] + [gr.Radio(visible=False) for _ in range(10)]
215
+
216
  RAG_db_ = RAG_db.value
217
  documents_full = RAG_db_.search(topic, k=top_k_rank)
218
 
 
386
  """)
387
 
388
  with gr.Column(scale=2):
389
+ gr.HTML("""
390
+ <center>
391
+
392
+ <h2>Ready!</h2>
393
+
394
+ </center>
395
+ """)
396
+ # load_btn = gr.Button("Click to Load!πŸš€")
397
+ # load_text = gr.Textbox()
398
+ # load_btn.click(fn=load_model, outputs=load_text)
399
 
400
  topic = gr.Textbox(label="Enter the Topic for Quiz", placeholder="Write any topic/details from Customs Manual")
401