Spaces:
Running
Running
Update nivra_agent.py
Browse files- nivra_agent.py +22 -18
nivra_agent.py
CHANGED
|
@@ -162,36 +162,40 @@ Provide diagnosis:
|
|
| 162 |
# ==================================================
|
| 163 |
|
| 164 |
def nivra_vision(image_url: str, hint_text: str = "") -> str:
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
return f"""
|
| 172 |
[TOOLS USED] analyze_symptom_image [/TOOLS USED]
|
| 173 |
-
[SYMPTOMS]
|
| 174 |
[PRIMARY DIAGNOSIS] Inconclusive [/PRIMARY DIAGNOSIS]
|
| 175 |
[DIAGNOSIS DESCRIPTION]
|
| 176 |
-
|
| 177 |
[/DIAGNOSIS DESCRIPTION]
|
| 178 |
-
[FIRST AID]
|
| 179 |
[EMERGENCY CONSULTATION REQUIRED] No [/EMERGENCY CONSULTATION REQUIRED]
|
| 180 |
-
"""
|
| 181 |
|
|
|
|
| 182 |
final_prompt = f"""
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
Vision tool result:
|
| 186 |
{tool_output}
|
| 187 |
|
| 188 |
-
|
| 189 |
{hint_text}
|
| 190 |
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
"""
|
| 194 |
-
|
| 195 |
|
| 196 |
return call_groq(final_prompt)
|
| 197 |
|
|
|
|
| 162 |
# ==================================================
|
| 163 |
|
| 164 |
def nivra_vision(image_url: str, hint_text: str = "") -> str:
|
| 165 |
+
"""
|
| 166 |
+
Image-based medical analysis using vision tool + Groq reasoning
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
+
print("🖼️ nivra_vision called")
|
| 170 |
+
|
| 171 |
+
tool_output = analyze_symptom_image.invoke({
|
| 172 |
+
"image_url": image_url,
|
| 173 |
+
"image_description": hint_text
|
| 174 |
+
})
|
| 175 |
+
|
| 176 |
+
# 🚨 If vision tool already failed, DO NOT call Groq
|
| 177 |
+
if "ERROR" in tool_output.upper():
|
| 178 |
return f"""
|
| 179 |
[TOOLS USED] analyze_symptom_image [/TOOLS USED]
|
| 180 |
+
[SYMPTOMS] Unable to analyze image [/SYMPTOMS]
|
| 181 |
[PRIMARY DIAGNOSIS] Inconclusive [/PRIMARY DIAGNOSIS]
|
| 182 |
[DIAGNOSIS DESCRIPTION]
|
| 183 |
+
{tool_output}
|
| 184 |
[/DIAGNOSIS DESCRIPTION]
|
| 185 |
+
[FIRST AID] Please consult a medical professional [/FIRST AID]
|
| 186 |
[EMERGENCY CONSULTATION REQUIRED] No [/EMERGENCY CONSULTATION REQUIRED]
|
| 187 |
+
""".strip()
|
| 188 |
|
| 189 |
+
# Keep Groq prompt SMALL
|
| 190 |
final_prompt = f"""
|
| 191 |
+
VISION TOOL OUTPUT:
|
|
|
|
|
|
|
| 192 |
{tool_output}
|
| 193 |
|
| 194 |
+
USER CONTEXT:
|
| 195 |
{hint_text}
|
| 196 |
|
| 197 |
+
Provide a cautious preliminary medical assessment.
|
| 198 |
+
""".strip()
|
|
|
|
|
|
|
| 199 |
|
| 200 |
return call_groq(final_prompt)
|
| 201 |
|