Spaces:
Sleeping
Sleeping
Jonas
commited on
Commit
·
e8c0366
1
Parent(s):
f4b6beb
Enhance report_source_tool to return a descriptive message when no data is available and update example drug names in the interface.
Browse files
app.py
CHANGED
|
@@ -164,9 +164,11 @@ def report_source_tool(drug_name: str):
|
|
| 164 |
drug_name (str): The name of the drug.
|
| 165 |
|
| 166 |
Returns:
|
| 167 |
-
A Plotly figure.
|
| 168 |
"""
|
| 169 |
data = get_report_source_data(drug_name)
|
|
|
|
|
|
|
| 170 |
chart = create_pie_chart(data, drug_name)
|
| 171 |
return chart
|
| 172 |
|
|
@@ -256,7 +258,8 @@ interface5 = gr.Interface(
|
|
| 256 |
outputs=[gr.Plot(label="Report Source Breakdown")],
|
| 257 |
title="Report Source Breakdown",
|
| 258 |
description="Show a pie chart breaking down the source of the reports (e.g., Consumer, Physician).",
|
| 259 |
-
examples=[["Lisinopril"], ["
|
|
|
|
| 260 |
)
|
| 261 |
|
| 262 |
demo = gr.TabbedInterface(
|
|
|
|
| 164 |
drug_name (str): The name of the drug.
|
| 165 |
|
| 166 |
Returns:
|
| 167 |
+
A Plotly figure or a descriptive string if no data is available.
|
| 168 |
"""
|
| 169 |
data = get_report_source_data(drug_name)
|
| 170 |
+
if not data or not data.get("results"):
|
| 171 |
+
return f"No report source data found for '{drug_name}'. The drug may not be in the database or it might be misspelled."
|
| 172 |
chart = create_pie_chart(data, drug_name)
|
| 173 |
return chart
|
| 174 |
|
|
|
|
| 258 |
outputs=[gr.Plot(label="Report Source Breakdown")],
|
| 259 |
title="Report Source Breakdown",
|
| 260 |
description="Show a pie chart breaking down the source of the reports (e.g., Consumer, Physician).",
|
| 261 |
+
examples=[["Lisinopril"], ["Ibuprofen"]],
|
| 262 |
+
allow_flagging="never"
|
| 263 |
)
|
| 264 |
|
| 265 |
demo = gr.TabbedInterface(
|