From 3a3627f73cb75fa0f68b494bf975e6b77b8a1d11 Mon Sep 17 00:00:00 2001 From: lacerate551 <128470311+lacerate551@users.noreply.github.com> Date: Sat, 20 Jun 2026 22:10:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(server-release):=20=E4=BF=AE=E5=A4=8D=20sel?= =?UTF-8?q?ect=5Fimages=20P1.5=20=E8=A1=A8=E6=A0=BC=E5=85=B3=E8=81=94?= =?UTF-8?q?=E5=9B=BE=E7=89=87=20UnboundLocalError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit P1.5 处理表格 images_json 时引用了 P1 块内的变量 s, 但两者在独立的 if 分支中,s 未定义导致 UnboundLocalError。 改用 ctx.get("score", 0) 获取当前切片分数。 --- api/chat_routes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/chat_routes.py b/api/chat_routes.py index bd3a81f..9d076f4 100644 --- a/api/chat_routes.py +++ b/api/chat_routes.py @@ -1650,7 +1650,8 @@ def select_images(contexts: List[Dict], query: str) -> List[Dict]: existing_ids = {img['id'] for img in scored_images} if img_id and img_id not in existing_ids: # 为关联图片计算分数(继承主表格分数,略低) - assoc_score = s - 1.0 if s >= MIN_SCORE else MIN_SCORE - 1.0 + ctx_score = ctx.get("score", 0) + assoc_score = ctx_score - 1.0 if ctx_score >= MIN_SCORE else MIN_SCORE - 1.0 if assoc_score >= MIN_SCORE: scored_images.append({ 'score': assoc_score,