Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load
|
5 |
qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot')
|
6 |
|
7 |
-
# Define
|
8 |
-
def
|
9 |
-
result = qa_pipeline(question
|
10 |
return result['answer']
|
11 |
|
12 |
-
# Create a
|
13 |
-
|
14 |
-
fn=
|
15 |
inputs=[
|
16 |
-
gr.
|
17 |
-
gr.
|
18 |
],
|
19 |
-
outputs="
|
20 |
-
|
21 |
-
description="Ask questions and get answers based on the provided context."
|
22 |
-
)
|
23 |
-
|
24 |
-
# Launch the interface
|
25 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load your QA model
|
5 |
qa_pipeline = pipeline('question-answering', model='MaawaKhalid/Extractive-QA-Bot')
|
6 |
|
7 |
+
# Define a function to handle the QA
|
8 |
+
def qa_function(context, question):
|
9 |
+
result = qa_pipeline({'context': context, 'question': question})
|
10 |
return result['answer']
|
11 |
|
12 |
+
# Create a Gradio interface
|
13 |
+
gr.Interface(
|
14 |
+
fn=qa_function,
|
15 |
inputs=[
|
16 |
+
gr.components.Textbox(label="Context", placeholder="Enter some text to ask questions from"),
|
17 |
+
gr.components.Textbox(label="Question", placeholder="Enter your question")
|
18 |
],
|
19 |
+
outputs=gr.components.Textbox(label="Answer")
|
20 |
+
).launch()
|
|
|
|
|
|
|
|
|
|