Spaces:
Running
Running
Update nivra_agent.py
Browse files- nivra_agent.py +10 -16
nivra_agent.py
CHANGED
|
@@ -163,32 +163,26 @@ Provide diagnosis:
|
|
| 163 |
|
| 164 |
def nivra_vision(image_base64: str, hint_text: str = "") -> str:
|
| 165 |
"""
|
| 166 |
-
|
| 167 |
-
hint_text: optional user description
|
| 168 |
"""
|
| 169 |
|
| 170 |
try:
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
| 172 |
except Exception as e:
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
[SYMPTOMS] Image could not be analyzed [/SYMPTOMS]
|
| 176 |
-
[PRIMARY DIAGNOSIS] Unable to assess from image [/PRIMARY DIAGNOSIS]
|
| 177 |
-
[DIAGNOSIS DESCRIPTION]
|
| 178 |
-
Image analysis failed. Please try again with a clearer image.
|
| 179 |
-
[/DIAGNOSIS DESCRIPTION]
|
| 180 |
-
[FIRST AID] Consult a healthcare professional [/FIRST AID]
|
| 181 |
-
[EMERGENCY CONSULTATION REQUIRED] Yes [/EMERGENCY CONSULTATION REQUIRED]
|
| 182 |
-
"""
|
| 183 |
|
| 184 |
final_prompt = f"""
|
| 185 |
-
IMAGE
|
| 186 |
-
{
|
| 187 |
|
| 188 |
USER CONTEXT:
|
| 189 |
{hint_text}
|
| 190 |
|
| 191 |
-
|
| 192 |
"""
|
| 193 |
|
| 194 |
return call_groq(final_prompt)
|
|
|
|
| 163 |
|
| 164 |
def nivra_vision(image_base64: str, hint_text: str = "") -> str:
|
| 165 |
"""
|
| 166 |
+
Image-based medical inference
|
|
|
|
| 167 |
"""
|
| 168 |
|
| 169 |
try:
|
| 170 |
+
image_tool_result = analyze_symptom_image.invoke({
|
| 171 |
+
"image_base64": image_base64,
|
| 172 |
+
"image_description": hint_text
|
| 173 |
+
})
|
| 174 |
except Exception as e:
|
| 175 |
+
print("❌ Image tool failed:", e)
|
| 176 |
+
image_tool_result = "[IMAGE TOOL FAILURE]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
final_prompt = f"""
|
| 179 |
+
IMAGE TOOL OUTPUT:
|
| 180 |
+
{image_tool_result}
|
| 181 |
|
| 182 |
USER CONTEXT:
|
| 183 |
{hint_text}
|
| 184 |
|
| 185 |
+
Generate a preliminary medical assessment using the standard format.
|
| 186 |
"""
|
| 187 |
|
| 188 |
return call_groq(final_prompt)
|