Spaces:
Sleeping
Sleeping
FIXED-TERM Nguyen Trung Tam (MS/EMC25-XC)
commited on
Commit
•
91aa056
1
Parent(s):
a4cc6d9
Add vn lang
Browse files- app.py +9 -1
- requirements.txt +1 -0
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import re
|
5 |
from transformers import AutoModelForSeq2SeqLM
|
6 |
from transformers import AutoTokenizer
|
|
|
7 |
import subprocess
|
8 |
|
9 |
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
|
@@ -11,6 +12,9 @@ tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
|
|
11 |
model = AutoModelForSeq2SeqLM.from_pretrained(
|
12 |
"GuysTrans/bart-base-finetuned-xsum")
|
13 |
|
|
|
|
|
|
|
14 |
map_words = {
|
15 |
"Hello and Welcome to 'Ask A Doctor' service": "",
|
16 |
"Hello,": "",
|
@@ -53,7 +57,11 @@ PAGE_ACCESS_TOKEN = os.environ['PAGE_ACCESS_TOKEN']
|
|
53 |
|
54 |
|
55 |
def get_bot_response(message):
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
|
58 |
|
59 |
def verify_webhook(req):
|
|
|
4 |
import re
|
5 |
from transformers import AutoModelForSeq2SeqLM
|
6 |
from transformers import AutoTokenizer
|
7 |
+
from langdetect import detect
|
8 |
import subprocess
|
9 |
|
10 |
tokenizer = AutoTokenizer.from_pretrained("facebook/bart-base")
|
|
|
12 |
model = AutoModelForSeq2SeqLM.from_pretrained(
|
13 |
"GuysTrans/bart-base-finetuned-xsum")
|
14 |
|
15 |
+
vn_model = AutoModelForSeq2SeqLM.from_pretrained(
|
16 |
+
"GuysTrans/bart-base-vn-ehealth")
|
17 |
+
|
18 |
map_words = {
|
19 |
"Hello and Welcome to 'Ask A Doctor' service": "",
|
20 |
"Hello,": "",
|
|
|
57 |
|
58 |
|
59 |
def get_bot_response(message):
|
60 |
+
lang = detect(message)
|
61 |
+
model_use = model
|
62 |
+
if lang == "vn":
|
63 |
+
model_use = vn_model
|
64 |
+
return post_process(generate_summary(message, model_use)[1][0])
|
65 |
|
66 |
|
67 |
def verify_webhook(req):
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers
|
2 |
flask
|
3 |
torch
|
|
|
|
1 |
transformers
|
2 |
flask
|
3 |
torch
|
4 |
+
langdetect
|