GuysTrans commited on
Commit
2a33b22
1 Parent(s): 2df7dbb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -10,6 +10,8 @@ import subprocess
10
 
11
  tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
12
 
 
 
13
  model = AutoModelForSeq2SeqLM.from_pretrained(
14
  "GuysTrans/bart-base-finetuned-xsum", revision="worked")
15
 
@@ -37,7 +39,7 @@ word_remove_sentence = [
37
  ]
38
 
39
 
40
- def generate_summary(question, model):
41
  inputs = tokenizer(
42
  question,
43
  padding="max_length",
@@ -64,11 +66,13 @@ PAGE_ACCESS_TOKEN = os.environ['PAGE_ACCESS_TOKEN']
64
  def get_bot_response(message):
65
  lang = detect(message)
66
  model_use = model
 
67
  template = "Welcome to MedForRum chatbot service. %s. Thanks for asking on MedForum."
68
  if lang == "vi":
69
  model_use = vn_model
 
70
  template = "Chào mừng bạn đến với dịch vụ MedForRum chatbot. %s. Cảm ơn bạn đã sử dụng MedForum."
71
- return template % post_process(generate_summary(message, model_use)[1][0])
72
 
73
 
74
  def verify_webhook(req):
 
10
 
11
  tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
12
 
13
+ vn_tokenizer = AutoTokenizer.from_pretrained("GuysTrans/bart-base-vn-ehealth-vn-tokenizer")
14
+
15
  model = AutoModelForSeq2SeqLM.from_pretrained(
16
  "GuysTrans/bart-base-finetuned-xsum", revision="worked")
17
 
 
39
  ]
40
 
41
 
42
+ def generate_summary(question, model, tokenizer):
43
  inputs = tokenizer(
44
  question,
45
  padding="max_length",
 
66
  def get_bot_response(message):
67
  lang = detect(message)
68
  model_use = model
69
+ tokenizer_use = tokenizer
70
  template = "Welcome to MedForRum chatbot service. %s. Thanks for asking on MedForum."
71
  if lang == "vi":
72
  model_use = vn_model
73
+ tokenizer_use = vn_tokenizer
74
  template = "Chào mừng bạn đến với dịch vụ MedForRum chatbot. %s. Cảm ơn bạn đã sử dụng MedForum."
75
+ return template % post_process(generate_summary(message, model_use, tokenizer_use)[1][0])
76
 
77
 
78
  def verify_webhook(req):