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=""" footer.svelte-1ax1toq { display: none !important; } """, ).launch()