SarowarSaurav commited on
Commit
b69fcd1
·
verified ·
1 Parent(s): d940b60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -10
app.py CHANGED
@@ -20,24 +20,19 @@ def select_backend():
20
  def release_backend(index):
21
  backend_locks[index].release()
22
 
 
 
 
23
  # Define the function to answer questions
24
  def get_answer(text):
25
- backend_index = select_backend()
26
- if backend_index is not None:
27
- try:
28
- result = backend_servers[backend_index](question=text, context=knowledge_base_text)
29
- return result["answer"]
30
- finally:
31
- release_backend(backend_index)
32
- else:
33
- return "All pipelines are busy. Please try again later."
34
 
35
  # Define the Gradio interface
36
  def chatbot_interface(text):
37
  answer = get_answer(text)
38
  return answer
39
 
40
-
41
  knowledge_base_text = """
42
  - British American Tobacco Bangladesh (BATB) is a leading multinational corporation operating in Bangladesh, listed on both the Dhaka Stock Exchange and Chittagong Stock Exchange.
43
  - Established in 1910, BATB has over a century of business history in Bangladesh.
 
20
  def release_backend(index):
21
  backend_locks[index].release()
22
 
23
+ # Define the function to answer questions
24
+ pipe = pipeline("question-answering", model="google-bert/bert-large-uncased-whole-word-masking-finetuned-squad")
25
+
26
  # Define the function to answer questions
27
  def get_answer(text):
28
+ result = pipe(question=text, context=knowledge_base_text)
29
+ return result["answer"]
 
 
 
 
 
 
 
30
 
31
  # Define the Gradio interface
32
  def chatbot_interface(text):
33
  answer = get_answer(text)
34
  return answer
35
 
 
36
  knowledge_base_text = """
37
  - British American Tobacco Bangladesh (BATB) is a leading multinational corporation operating in Bangladesh, listed on both the Dhaka Stock Exchange and Chittagong Stock Exchange.
38
  - Established in 1910, BATB has over a century of business history in Bangladesh.