LiamKhoaLe commited on
Commit
b27a873
·
1 Parent(s): 6796fdc

Debug flow

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -280,18 +280,17 @@ async def chat_endpoint(req: Request):
280
  lang = body.get("lang", "EN")
281
  image_base64 = body.get("image_base64", None)
282
  img_desc = body.get("img_desc", "Describe and investigate any clinical findings from this medical image.")
 
 
283
  # LLM Only
284
  if not image_base64:
285
  logger.info("[BOT] LLM scenario.")
286
- start = time.time()
287
- # If image is present → diagnose first
288
- image_diagnosis = ""
289
- # Img size safe processor
290
- safe_load = len(image_base64.encode("utf-8"))
291
- if image_base64 and safe_load > 5_000_000:
292
- return JSONResponse({"response": "⚠️ Image too large. Please upload smaller images (<5MB)."})
293
  # LLM+VLM
294
- if image_base64:
 
 
 
 
295
  logger.info("[BOT] VLM+LLM scenario.")
296
  logger.info(f"[VLM] Process medical image size: {safe_load}, desc: {img_desc}, {lang}.")
297
  image_diagnosis = process_medical_image(image_base64, img_desc, lang)
 
280
  lang = body.get("lang", "EN")
281
  image_base64 = body.get("image_base64", None)
282
  img_desc = body.get("img_desc", "Describe and investigate any clinical findings from this medical image.")
283
+ start = time.time()
284
+ image_diagnosis = ""
285
  # LLM Only
286
  if not image_base64:
287
  logger.info("[BOT] LLM scenario.")
 
 
 
 
 
 
 
288
  # LLM+VLM
289
+ else:
290
+ # If image is present → diagnose first
291
+ safe_load = len(image_base64.encode("utf-8"))
292
+ if safe_load > 5_000_000: # Img size safe processor
293
+ return JSONResponse({"response": "⚠️ Image too large. Please upload smaller images (<5MB)."})
294
  logger.info("[BOT] VLM+LLM scenario.")
295
  logger.info(f"[VLM] Process medical image size: {safe_load}, desc: {img_desc}, {lang}.")
296
  image_diagnosis = process_medical_image(image_base64, img_desc, lang)