|
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) |
|
|
|
|
|
|
|
|