"""中控 AI 文本小工具。""" def is_ai_error_reply(text: str) -> bool: t = (text or "").strip() return t.startswith("AI 调用失败") or t.startswith("AI 生成失败") def clip_text(text: str, max_chars: int) -> str: s = str(text or "").strip() limit = max(200, int(max_chars or 0)) if len(s) <= limit: return s return s[: limit - 1].rstrip() + "…"