Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,12 +9,12 @@ sample_questions = [
|
|
9 |
"What are the first-line medications for treating hypertension?",
|
10 |
]
|
11 |
|
12 |
-
def qa_bot(user_question, history):
|
13 |
history = history or []
|
14 |
if not user_question.strip():
|
15 |
return history, history
|
16 |
history.append({"role": "user", "content": user_question})
|
17 |
-
result = rag_chain.forward(user_question)
|
18 |
answer = result.final_answer
|
19 |
history.append({"role": "assistant", "content": answer})
|
20 |
return history, history
|
@@ -107,6 +107,24 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
|
107 |
btn = gr.Button(q, elem_id=f"suggestion-{i}", elem_classes=["suggestion-btn"])
|
108 |
suggestion_buttons.append(btn)
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
with gr.Row():
|
111 |
user_input = gr.Textbox(placeholder="Type a medical question...", show_label=False, lines=1, scale=8, elem_id="user-input")
|
112 |
submit_btn = gr.Button(value="➤", scale=1, elem_id="submit-btn")
|
@@ -114,8 +132,8 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
|
114 |
def suggestion_click(q, history):
|
115 |
return qa_bot(q, history)
|
116 |
|
117 |
-
submit_btn.click(qa_bot, inputs=[user_input, state], outputs=[chatbot, state])
|
118 |
-
user_input.submit(qa_bot, inputs=[user_input, state], outputs=[chatbot, state])
|
119 |
for btn, q in zip(suggestion_buttons, sample_questions):
|
120 |
btn.click(suggestion_click, inputs=[gr.State(q), state], outputs=[chatbot, state])
|
121 |
|
|
|
9 |
"What are the first-line medications for treating hypertension?",
|
10 |
]
|
11 |
|
12 |
+
def qa_bot(user_question, history, year, specialty):
|
13 |
history = history or []
|
14 |
if not user_question.strip():
|
15 |
return history, history
|
16 |
history.append({"role": "user", "content": user_question})
|
17 |
+
result = rag_chain.forward(user_question, year, specialty)
|
18 |
answer = result.final_answer
|
19 |
history.append({"role": "assistant", "content": answer})
|
20 |
return history, history
|
|
|
107 |
btn = gr.Button(q, elem_id=f"suggestion-{i}", elem_classes=["suggestion-btn"])
|
108 |
suggestion_buttons.append(btn)
|
109 |
|
110 |
+
with gr.Row():
|
111 |
+
specialty_options = [
|
112 |
+
"Rheumatology", "Psychiatry", "Pulmonology & Respiratory Medicine", "Nephrology", "Public Health & Epidemiology",
|
113 |
+
"Medical Research & Methodology", "Pharmacy & Pharmacology", "Hematology", "Oncology", "Medical Ethics & Law",
|
114 |
+
"Medical Technology & Informatics", "Infectious Disease", "Basic Medical Sciences", "Allergology", "Geriatrics",
|
115 |
+
"Cardiology", "Gastroenterology & Hepatology", "General Surgery", "General Pediatrics", "Endocrinology & Metabolism",
|
116 |
+
"Vascular Surgery", "Radiology & Imaging", "Obstetrics & Gynecology", "Orthopedic Surgery", "Neurology",
|
117 |
+
"Family Medicine & Primary Care", "Psychology & Behavioral Health", "Otorhinolaryngology (ENT)", "General Internal Medicine",
|
118 |
+
"Anesthesiology", "Physical & Rehabilitation Medicine", "Medical Education", "Healthcare Administration & Management",
|
119 |
+
"Non-Medical Sciences & Disciplines", "Dermatology", "Critical Care & Intensive Care", "Urology", "Complementary & Alternative Medicine",
|
120 |
+
"Cardiothoracic Surgery", "Neurosurgery", "Pediatric Subspecialties", "Occupational & Environmental Health", "Ophthalmology",
|
121 |
+
"Emergency Medicine", "Dental & Oral Medicine", "Biomedical Engineering", "Pathology & Laboratory Medicine", "Transplant Surgery",
|
122 |
+
"Preventive Medicine", "Genetics", "Nursing", "Allied Health Professions", "Plastic & Reconstructive Surgery", "Others",
|
123 |
+
"Toxicology", "General Medicine"
|
124 |
+
]
|
125 |
+
year_options = [str(y) for y in range(2021, 1792, -1)]
|
126 |
+
specialty_dropdown = gr.Dropdown(choices=specialty_options, value="General Medicine", label="Specialty", scale=4)
|
127 |
+
year_dropdown = gr.Dropdown(choices=year_options, value="2021", label="Year", scale=2)
|
128 |
with gr.Row():
|
129 |
user_input = gr.Textbox(placeholder="Type a medical question...", show_label=False, lines=1, scale=8, elem_id="user-input")
|
130 |
submit_btn = gr.Button(value="➤", scale=1, elem_id="submit-btn")
|
|
|
132 |
def suggestion_click(q, history):
|
133 |
return qa_bot(q, history)
|
134 |
|
135 |
+
submit_btn.click(qa_bot, inputs=[user_input, state, year_dropdown, specialty_dropdown], outputs=[chatbot, state])
|
136 |
+
user_input.submit(qa_bot, inputs=[user_input, state, year_dropdown, specialty_dropdown], outputs=[chatbot, state])
|
137 |
for btn, q in zip(suggestion_buttons, sample_questions):
|
138 |
btn.click(suggestion_click, inputs=[gr.State(q), state], outputs=[chatbot, state])
|
139 |
|