Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
pipe = pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad")
|
|
|
5 |
# Define the function to answer questions
|
6 |
def get_answer(text):
|
7 |
-
result =
|
8 |
-
"question": text,
|
9 |
-
"context": knowledge_base_text
|
10 |
-
})
|
11 |
return result["answer"]
|
12 |
|
13 |
# Define the Gradio interface
|
@@ -41,9 +40,6 @@ knowledge_base_text = """
|
|
41 |
- for SAP , wifi , network related issue , you should contact Md. Monirul Islam & his contact number 01730372426
|
42 |
"""
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
iface = gr.Interface(
|
48 |
fn=chatbot_interface,
|
49 |
inputs="text",
|
@@ -51,9 +47,7 @@ iface = gr.Interface(
|
|
51 |
css="footer{display:none !important}",
|
52 |
title="British American Tobacco Bangladesh",
|
53 |
description="- powered by IDT",
|
54 |
-
theme='
|
55 |
-
|
56 |
)
|
57 |
|
58 |
-
|
59 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Use a pipeline as a high-level helper
|
5 |
pipe = pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad")
|
6 |
+
|
7 |
# Define the function to answer questions
|
8 |
def get_answer(text):
|
9 |
+
result = pipe(question=text, context=knowledge_base_text)
|
|
|
|
|
|
|
10 |
return result["answer"]
|
11 |
|
12 |
# Define the Gradio interface
|
|
|
40 |
- for SAP , wifi , network related issue , you should contact Md. Monirul Islam & his contact number 01730372426
|
41 |
"""
|
42 |
|
|
|
|
|
|
|
43 |
iface = gr.Interface(
|
44 |
fn=chatbot_interface,
|
45 |
inputs="text",
|
|
|
47 |
css="footer{display:none !important}",
|
48 |
title="British American Tobacco Bangladesh",
|
49 |
description="- powered by IDT",
|
50 |
+
theme='compact'
|
|
|
51 |
)
|
52 |
|
|
|
53 |
iface.launch()
|