Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -323,6 +323,11 @@ class VectorData():
|
|
| 323 |
self.ingested_files.clear()
|
| 324 |
self.retriever, self.vectorstore = utils.delete_all_doc(self.vectorstore)
|
| 325 |
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
|
| 327 |
data_obj = VectorData()
|
| 328 |
|
|
@@ -389,15 +394,27 @@ with gr.Blocks() as rag_interface:
|
|
| 389 |
|
| 390 |
# Right Column: Question Answering
|
| 391 |
with gr.Column():
|
| 392 |
-
gr.Markdown("### Ask a Question")
|
| 393 |
|
| 394 |
# Question input
|
| 395 |
-
question_input = gr.Textbox(label="Enter your question")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
|
| 397 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
ask_button = gr.Button("Get Answer")
|
| 399 |
answer_output = gr.Textbox(label="Answer", interactive=False)
|
| 400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
ask_button.click(fn=answer_question, inputs=question_input, outputs=answer_output)
|
| 402 |
|
| 403 |
|
|
|
|
| 323 |
self.ingested_files.clear()
|
| 324 |
self.retriever, self.vectorstore = utils.delete_all_doc(self.vectorstore)
|
| 325 |
return []
|
| 326 |
+
|
| 327 |
+
def get_example_questions(self):
|
| 328 |
+
return [
|
| 329 |
+
"ਕਵੀ ਕੌਣ ਹੈ?"
|
| 330 |
+
]
|
| 331 |
|
| 332 |
data_obj = VectorData()
|
| 333 |
|
|
|
|
| 394 |
|
| 395 |
# Right Column: Question Answering
|
| 396 |
with gr.Column():
|
| 397 |
+
# gr.Markdown("### Ask a Question")
|
| 398 |
|
| 399 |
# Question input
|
| 400 |
+
# question_input = gr.Textbox(label="Enter your question")
|
| 401 |
+
|
| 402 |
+
# # Get answer button and answer output
|
| 403 |
+
# ask_button = gr.Button("Get Answer")
|
| 404 |
+
# answer_output = gr.Textbox(label="Answer", interactive=False)
|
| 405 |
|
| 406 |
+
# ask_button.click(fn=answer_question, inputs=question_input, outputs=answer_output)
|
| 407 |
+
|
| 408 |
+
gr.Markdown("### Ask a Question")
|
| 409 |
+
example_questions = gr.Radio(choices=data_obj.get_example_questions(), label="Example Questions")
|
| 410 |
+
question_input = gr.Textbox(label="Enter your question")
|
| 411 |
ask_button = gr.Button("Get Answer")
|
| 412 |
answer_output = gr.Textbox(label="Answer", interactive=False)
|
| 413 |
|
| 414 |
+
def set_example_question(example):
|
| 415 |
+
return gr.update(value=example)
|
| 416 |
+
|
| 417 |
+
example_questions.change(fn=set_example_question, inputs=example_questions, outputs=question_input)
|
| 418 |
ask_button.click(fn=answer_question, inputs=question_input, outputs=answer_output)
|
| 419 |
|
| 420 |
|