File size: 1,219 Bytes
6f99e29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from transformers import pipeline

def medical_chatbot(question):
    model_name = "AventIQ-AI/t5-medical-chatbot"
    generator = pipeline("text2text-generation", model=model_name)
    
    instruction = "As a medical expert, provide a detailed and accurate diagnosis based on the patient's symptoms."
    input_text = f"{instruction} {question}"
    
    response = generator(input_text, max_length=256)[0]['generated_text']
    
    return response

iface = gr.Interface(
    fn=medical_chatbot,
    inputs=gr.Textbox(label="🩺 Ask a Medical Question", placeholder="Describe your symptoms or ask a medical query...", lines=3),
    outputs=gr.Textbox(label="💡 Expert Diagnosis", interactive=True),
    title="🔬 AI-Powered Medical Chatbot",
    description="🤖 Enter a medical question, and the chatbot will generate a detailed response based on expert knowledge.",
    theme="compact",
    allow_flagging="never",
    examples=[
        ["I have a fever and sore throat. What could it be?"],
        ["What are the symptoms of diabetes?"],
        ["How can I manage high blood pressure naturally?"]
    ],
)

if __name__ == "__main__":
    iface.launch()