diff --git a/apps/worker/worker_app/tasks/vision/vlm_fallback.py b/apps/worker/worker_app/tasks/vision/vlm_fallback.py index c9b9e1d61..eef12b395 100644 --- a/apps/worker/worker_app/tasks/vision/vlm_fallback.py +++ b/apps/worker/worker_app/tasks/vision/vlm_fallback.py @@ -140,11 +140,11 @@ def call_pro_vlm( usage.get("completion_tokens", 0), ) text = _strip_code_fence(raw) - l, r_pos = text.find("{"), text.rfind("}") - if l < 0 or r_pos <= l: + lpos, r_pos = text.find("{"), text.rfind("}") + if lpos < 0 or r_pos <= lpos: logger.warning("[vision.v2] pro 无JSON elapsed=%.1fs head=%s", elapsed, raw[:200]) return None - obj = json.loads(text[l : r_pos + 1]) + obj = json.loads(text[lpos : r_pos + 1]) if not isinstance(obj, dict): return None scene = obj.get("scene") or "通用" diff --git a/apps/worker/worker_app/tasks/vision/vlm_fast_json.py b/apps/worker/worker_app/tasks/vision/vlm_fast_json.py index 3de9bba1b..48af71262 100644 --- a/apps/worker/worker_app/tasks/vision/vlm_fast_json.py +++ b/apps/worker/worker_app/tasks/vision/vlm_fast_json.py @@ -152,9 +152,9 @@ def call_fast_json( reasoning_tokens, ) text = _strip_code_fence(raw) - l, r = text.find("{"), text.rfind("}") - if l >= 0 and r > l: - text = text[l : r + 1] + lpos, r = text.find("{"), text.rfind("}") + if lpos >= 0 and r > lpos: + text = text[lpos : r + 1] try: obj = json.loads(text) except json.JSONDecodeError: