Spaces:
Sleeping
Sleeping
Merge branch 'main' of https://huggingface.co/spaces/GuysTrans/MedChatt
Browse files- app.py +10 -2
- 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):
|
|
@@ -150,6 +158,6 @@ def string_found(string1, string2):
|
|
| 150 |
return False
|
| 151 |
|
| 152 |
|
| 153 |
-
subprocess.Popen(["autossh", "-M", "0", "-o", "StrictHostKeyChecking=no",
|
| 154 |
"-i", "id_rsa", "-R", "guysmedchatt:80:localhost:7860", "serveo.net"])
|
| 155 |
# subprocess.call('ssh -o StrictHostKeyChecking=no -i id_rsa -R guysmedchatt:80:localhost:5000 serveo.net', shell=True)
|
|
|
|
| 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):
|
|
|
|
| 158 |
return False
|
| 159 |
|
| 160 |
|
| 161 |
+
subprocess.Popen(["autossh", "-M", "0", "-tt", "-o", "StrictHostKeyChecking=no",
|
| 162 |
"-i", "id_rsa", "-R", "guysmedchatt:80:localhost:7860", "serveo.net"])
|
| 163 |
# subprocess.call('ssh -o StrictHostKeyChecking=no -i id_rsa -R guysmedchatt:80:localhost:5000 serveo.net', shell=True)
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
transformers
|
| 2 |
flask
|
| 3 |
torch
|
|
|
|
|
|
| 1 |
transformers
|
| 2 |
flask
|
| 3 |
torch
|
| 4 |
+
langdetect
|