datdevsteve commited on
Commit
7d314da
·
verified ·
1 Parent(s): 52c2511

Update nivra_agent.py

Browse files
Files changed (1) hide show
  1. 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
- image_base64: base64-encoded image string
167
- hint_text: optional user description
168
  """
169
 
170
  try:
171
- image_result = analyze_symptom_image.invoke(image_base64)
 
 
 
172
  except Exception as e:
173
- return f"""
174
- [TOOLS USED] analyze_symptom_image [/TOOLS USED]
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 ANALYSIS:
186
- {image_result}
187
 
188
  USER CONTEXT:
189
  {hint_text}
190
 
191
- Provide medical image-based preliminary assessment:
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)