qarisoft commited on
Commit
a6577d8
1 Parent(s): 9dd8021

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -43
app.py CHANGED
@@ -1,44 +1,53 @@
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="""
36
- footer.svelte-1ax1toq {
37
- display: none !important;
38
- }
39
- """,
40
- ).launch()
41
-
42
-
43
-
 
 
 
 
 
 
 
 
 
44
 
 
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="""
36
+ a.built-with {
37
+ opacity: 0 !important;
38
+ visibility: hidden !important;
39
+ }
40
+ .message{
41
+ width: fit-content !important;
42
+ }
43
+
44
+ .user.svelte-1henpdt.latest {
45
+ width: fit-content;
46
+ margin-left: auto;
47
+ }
48
+ """,
49
+ ).launch(show_api=False,show_tips=False)
50
+
51
+
52
+
53