salah
Browse files- app.py +40 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
def isEnglish(s):
|
4 |
+
try:
|
5 |
+
s.encode(encoding='utf-8').decode('ascii')
|
6 |
+
except UnicodeDecodeError:
|
7 |
+
return False
|
8 |
+
else:
|
9 |
+
return True
|
10 |
+
|
11 |
+
|
12 |
+
pipe = pipeline("text2text-generation", model="Varshitha/flan-t5-large-finetune-medicine-v5")
|
13 |
+
examples = [
|
14 |
+
["what is fever?"],
|
15 |
+
["what medicen to give child if got fever?"],
|
16 |
+
['Where is the protein Pannexin1 located?'],
|
17 |
+
]
|
18 |
+
|
19 |
+
title = "Qarisoft Medical Bot"
|
20 |
+
txt_box = gr.Textbox()
|
21 |
+
def ff_(message, history):
|
22 |
+
if not isEnglish(message):
|
23 |
+
return "Only support English right now"
|
24 |
+
return pipe(message)[0]['generated_text']
|
25 |
+
|
26 |
+
gr.ChatInterface(ff_,
|
27 |
+
title=title,
|
28 |
+
description=title,
|
29 |
+
examples=examples,
|
30 |
+
submit_btn="Ask- أرسل",
|
31 |
+
undo_btn="تراجع",
|
32 |
+
retry_btn="اعادة",
|
33 |
+
clear_btn="حذف",
|
34 |
+
theme="soft",
|
35 |
+
css="main.css"
|
36 |
+
).launch()
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|