diff --git a/deploy/profile-scripts/llm_client.py b/deploy/profile-scripts/llm_client.py index 85fb3495..686bcd24 100644 --- a/deploy/profile-scripts/llm_client.py +++ b/deploy/profile-scripts/llm_client.py @@ -290,38 +290,18 @@ def call_llm(prompt, model=None, max_tokens=4096, timeout=150, ok, result = _post(ch_url, ch_headers, payload, timeout) elapsed = time.monotonic() - t0 if ok: - # ── 空输出视为失败:先同 key 升 FALLBACK_MODEL(pro),仍空则不返回, - # 落到外循环切下一个 key(2026-07-22 实测:空输出会"假成功"阻断轮换)── + # ── 空输出视为失败(2026-08-14 老莫:不换pro,OCG router 内部空输出自动换 key)── + # ocg_router 已内置空输出检测(_forward_request 检测 content 为空 → 自动换下一个 key) + # llm_client 不再升级 pro,空输出直接失败(依赖 ocg_router 换 key) if not result.strip(): # SenseNova 不托管 deepseek-v4-pro(404),空输出直接切下一通道 if ch_name == "sensenova": print(f" [LLM] {ch_name} 空输出视为失败,切换下一通道...", flush=True) last_err = "empty content" continue - if model_name != FALLBACK_MODEL and ch_name.startswith("ocg"): - print(f" [LLM] {ch_name} {model_name} 空输出({elapsed:.1f}s)," - f"升级 {FALLBACK_MODEL} 重试...", flush=True) - esc_payload = json.dumps({ - "model": FALLBACK_MODEL, "messages": messages, - "max_tokens": max_tokens, - }).encode() - try: - ok2, result2 = _post(ch_url, ch_headers, esc_payload, timeout) - total_attempts += 1 - if ok2 and result2.strip(): - print(f" [LLM] 升级 {FALLBACK_MODEL} 成功, 输出{len(result2)}字", flush=True) - return { - "ok": True, "content": result2, "error": None, - "model": FALLBACK_MODEL, - "elapsed": time.monotonic() - t_start, - "attempts": total_attempts, "channel": ch_name + "+esc", - } - print(f" [LLM] {ch_name} 升级 {FALLBACK_MODEL} 仍空", flush=True) - except Exception as e2: - print(f" [LLM] 升级 {FALLBACK_MODEL} 异常: {str(e2)[:100]}", flush=True) - # 仍空 → 不 return,作为本通道失败处理,外循环切下一个 key + # ocg_router 通道:空输出视为失败(ocg_router 内部已自动换 key 重试,到这说明所有 key 都空) last_err = "empty content" - print(f" [LLM] {ch_name} 空输出视为失败,切换下一 key...", flush=True) + print(f" [LLM] {ch_name} 空输出视为失败,切换下一通道...", flush=True) continue print(f" [LLM] {ch_name} 尝试{attempt+1}/{retries+1} 成功, " f"{elapsed:.1f}s, 输出{len(result)}字, model={model_name}", flush=True)