diff --git a/运营中枢/scripts/karuo_ai_gateway/main.py b/运营中枢/scripts/karuo_ai_gateway/main.py index 1f4d9eaf..d6048828 100644 --- a/运营中枢/scripts/karuo_ai_gateway/main.py +++ b/运营中枢/scripts/karuo_ai_gateway/main.py @@ -252,6 +252,24 @@ def _build_provider_queue(llm_cfg: Dict[str, Any]) -> List[Dict[str, str]]: return providers +def _is_unusable_llm_reply(text: str) -> bool: + s = (text or "").strip().lower() + if not s: + return True + refusal_signals = [ + "i'm sorry", + "i am sorry", + "not able to assist", + "can't assist", + "cannot assist", + "无法协助", + "不能协助", + ] + if any(sig in s for sig in refusal_signals) and len(s) <= 160: + return True + return False + + def _send_provider_alert(cfg: Dict[str, Any], errors: List[str], prompt: str, matched_skill: str, skill_path: str) -> None: """ 当所有 LLM 接口都失败时,发邮件告警(支持 QQ SMTP)。 @@ -302,7 +320,19 @@ def _send_provider_alert(cfg: Dict[str, Any], errors: List[str], prompt: str, ma ) msg.set_content(body) - with smtplib.SMTP_SSL(smtp_host, smtp_port, timeout=15) as s: + # 先走 SSL(465),失败再尝试 STARTTLS(587) + try: + with smtplib.SMTP_SSL(smtp_host, smtp_port, timeout=15) as s: + s.login(smtp_user, smtp_pass) + s.send_message(msg) + return + except Exception: + pass + + with smtplib.SMTP(smtp_host, 587, timeout=15) as s: + s.ehlo() + s.starttls() + s.ehlo() s.login(smtp_user, smtp_pass) s.send_message(msg) @@ -335,7 +365,11 @@ def build_reply_with_llm(prompt: str, cfg: Dict[str, Any], matched_skill: str, s ) if r.status_code == 200: data = r.json() - return data["choices"][0]["message"]["content"] + reply = data["choices"][0]["message"]["content"] + if _is_unusable_llm_reply(reply): + errors.append(f"provider#{idx} unusable_reply={reply[:120]}") + continue + return reply errors.append(f"provider#{idx} status={r.status_code} body={r.text[:120]}") except Exception as e: errors.append(f"provider#{idx} exception={type(e).__name__}: {str(e)[:160]}") diff --git a/运营中枢/工作台/gitea_push_log.md b/运营中枢/工作台/gitea_push_log.md index c652768b..8e94d0ae 100644 --- a/运营中枢/工作台/gitea_push_log.md +++ b/运营中枢/工作台/gitea_push_log.md @@ -140,3 +140,4 @@ | 2026-02-25 10:26:04 | 🔄 卡若AI 同步 2026-02-25 10:26 | 更新:水桥平台对接、水溪整理归档 | 排除 >20MB: 13 个 | | 2026-02-25 11:03:16 | 🔄 卡若AI 同步 2026-02-25 11:03 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 13 个 | | 2026-02-25 11:52:39 | 🔄 卡若AI 同步 2026-02-25 11:52 | 更新:水溪整理归档、运营中枢、运营中枢工作台 | 排除 >20MB: 13 个 | +| 2026-02-25 12:07:57 | 🔄 卡若AI 同步 2026-02-25 12:07 | 更新:Cursor规则、水桥平台对接、运营中枢、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 | diff --git a/运营中枢/工作台/代码管理.md b/运营中枢/工作台/代码管理.md index 3f5ae58d..466051be 100644 --- a/运营中枢/工作台/代码管理.md +++ b/运营中枢/工作台/代码管理.md @@ -143,3 +143,4 @@ | 2026-02-25 10:26:04 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 10:26 | 更新:水桥平台对接、水溪整理归档 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) | | 2026-02-25 11:03:16 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 11:03 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) | | 2026-02-25 11:52:39 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 11:52 | 更新:水溪整理归档、运营中枢、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) | +| 2026-02-25 12:07:57 | 成功 | 成功 | 🔄 卡若AI 同步 2026-02-25 12:07 | 更新:Cursor规则、水桥平台对接、运营中枢、运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 13 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |