File size: 1,835 Bytes
a6577d8 afd2151 a6577d8 9f539b8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
from transformers import pipeline
import gradio as gr
def isEnglish(s):
try:
s.encode(encoding='utf-8').decode('ascii')
except UnicodeDecodeError:
return False
else:
return True
pipe = pipeline("text2text-generation", model="Varshitha/flan-t5-large-finetune-medicine-v5")
examples = [
["what is fever?"],
["what medicen to give child if got fever?"],
['Where is the protein Pannexin1 located?'],
]
title = "Qarisoft Medical Bot"
txt_box = gr.Textbox()
def ff_(message, history):
if not isEnglish(message):
return "Only support English right now"
return pipe(message)[0]['generated_text']
gr.ChatInterface(ff_,
title=title,
description=title,
examples=examples,
submit_btn="Ask- أرسل",
undo_btn="تراجع",
retry_btn="اعادة",
clear_btn="حذف",
theme="soft",
css="""
a.built-with {
opacity: 0 !important;
visibility: hidden !important;
}
.message{
width: fit-content !important;
}
.user.svelte-1henpdt.latest {
width: fit-content;
margin-left: auto;
}
header,
header.from-gray-50-to-white,
header.from-gray-50-to-white.relative.border-b.border-gray-100.bg-gradient-to-t.via-white.pt-0\.5.dark\:via-gray-950 {
display: none !important;
}
""",
).launch(show_api=False,show_tips=False)
|