Forrest Wargo commited on
Commit
5dca6b2
·
1 Parent(s): 6b2981b

unification

Browse files
Files changed (1) hide show
  1. handler.py +24 -0
handler.py CHANGED
@@ -181,6 +181,30 @@ class EndpointHandler:
181
  if width and height:
182
  out.update({"width": width, "height": height})
183
  out.update({"task": task})
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  return out
185
 
186
  @staticmethod
 
181
  if width and height:
182
  out.update({"width": width, "height": height})
183
  out.update({"task": task})
184
+
185
+ # Print prompt, dimensions, and raw output
186
+ try:
187
+ print(f"[moondream-endpoint] Prompt: {text_piece}")
188
+ except Exception:
189
+ pass
190
+ if width and height:
191
+ try:
192
+ print(f"[moondream-endpoint] Received image size: {width}x{height}")
193
+ except Exception:
194
+ pass
195
+ try:
196
+ print(f"[moondream-endpoint] Raw output: {json.dumps(out)}")
197
+ except Exception:
198
+ pass
199
+
200
+ # Ensure strict shape for point task: include points[] and raw
201
+ if task == "point":
202
+ # Ensure points array exists
203
+ if not isinstance(out.get("points"), list) or not out["points"]:
204
+ return {"error": "No points returned"}
205
+ # Attach raw for strict client and drop width/height from payload
206
+ return {"points": out["points"], "raw": out}
207
+
208
  return out
209
 
210
  @staticmethod