savan360 commited on
Commit
d865a2c
·
verified ·
1 Parent(s): 19bcb2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,11 +1,11 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- def get_answer(question):
5
- # Reload the pipeline every time a query is made (fixes single-response issue)
6
- qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
7
 
8
- # Define a general knowledge context
 
9
  context = """
10
  Washington, D.C. is the capital of the United States of America.
11
  New Delhi is the capital of India.
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the QA model only once at the start
5
+ qa_pipeline = pipeline("question-answering", model="deepset/roberta-base-squad2")
 
6
 
7
+ def get_answer(question):
8
+ # Predefined factual context
9
  context = """
10
  Washington, D.C. is the capital of the United States of America.
11
  New Delhi is the capital of India.