feat(hub): rolling chat summary to cap AI context and prevent mid-session failures
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
"""中控 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() + "…"
|
||||
Reference in New Issue
Block a user