Spaces:
Running
Running
Upload 2 files
Browse files- app.py +31 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
def medical_chatbot(question):
|
5 |
+
model_name = "AventIQ-AI/t5-medical-chatbot"
|
6 |
+
generator = pipeline("text2text-generation", model=model_name)
|
7 |
+
|
8 |
+
instruction = "As a medical expert, provide a detailed and accurate diagnosis based on the patient's symptoms."
|
9 |
+
input_text = f"{instruction} {question}"
|
10 |
+
|
11 |
+
response = generator(input_text, max_length=256)[0]['generated_text']
|
12 |
+
|
13 |
+
return response
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=medical_chatbot,
|
17 |
+
inputs=gr.Textbox(label="🩺 Ask a Medical Question", placeholder="Describe your symptoms or ask a medical query...", lines=3),
|
18 |
+
outputs=gr.Textbox(label="💡 Expert Diagnosis", interactive=True),
|
19 |
+
title="🔬 AI-Powered Medical Chatbot",
|
20 |
+
description="🤖 Enter a medical question, and the chatbot will generate a detailed response based on expert knowledge.",
|
21 |
+
theme="compact",
|
22 |
+
allow_flagging="never",
|
23 |
+
examples=[
|
24 |
+
["I have a fever and sore throat. What could it be?"],
|
25 |
+
["What are the symptoms of diabetes?"],
|
26 |
+
["How can I manage high blood pressure naturally?"]
|
27 |
+
],
|
28 |
+
)
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
3 |
+
gradio
|
4 |
+
sentencepiece
|