Muhammad Abdiel Al Hafiz
commited on
Commit
·
b3627a5
1
Parent(s):
6704e8f
adjust output for disease explanation
Browse files
app.py
CHANGED
@@ -25,7 +25,12 @@ def get_disease_detail(disease_name):
|
|
25 |
"Reminder: Always seek professional help, such as a doctor."
|
26 |
)
|
27 |
response = genai.GenerativeModel("gemini-1.5-flash").generate_content(prompt)
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
def safe_extract_section(text, start_keyword, end_keyword):
|
31 |
""" Safely extract sections from the Gemini response based on start and end keywords."""
|
|
|
25 |
"Reminder: Always seek professional help, such as a doctor."
|
26 |
)
|
27 |
response = genai.GenerativeModel("gemini-1.5-flash").generate_content(prompt)
|
28 |
+
|
29 |
+
# Make sure we check for candidates and handle possible missing attributes correctly
|
30 |
+
if response.candidates and response.candidates[0].text:
|
31 |
+
return response.candidates[0].text.strip()
|
32 |
+
else:
|
33 |
+
return "No detailed explanation available."
|
34 |
|
35 |
def safe_extract_section(text, start_keyword, end_keyword):
|
36 |
""" Safely extract sections from the Gemini response based on start and end keywords."""
|