feat(ai-chat): AI客服去掉授权,改为免费引导功能
- 前端 license.ts 移除 /ai-chat(14->13);服务端 PROTECTED_TOOLS 移除(16->15) - 同步移除 _handle_aichat 的 check() 闸门(check对清单外工具返回403,只删清单会弄坏功能) - log_usage 保留;移出后自然归入文本组 - 验证:无授权无试用下 POST /ai/chat 返回200并给出真实回复;在线翻译试用耗尽仍403; /ai-chat 页无浮条无弹窗;受控工具CTA=13 - 成本提示:AI客服走NewAPI计费,去授权后任何人可消耗token,建议必要时加频控
This commit is contained in:
1 parent
170f504689
commit
8744e046c0
5 files changed
+19
-8
No files matched your search
@@ -46,7 +46,7 @@ TRIAL_FILE = os.environ.get("TRIAL_FILE", "/app/data/trials.json")
|
||||
TRIAL_MS = int(os.environ.get("TRIAL_MS_MIN", "30")) * 60 * 1000
|
||||
DAY_MS = 24 * 60 * 60 * 1000
|
||||
TZ_OFFSET_MS = 8 * 60 * 60 * 1000 # 北京时间 UTC+8 —— 重置对齐自然日 0 点
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools", "text-to-image", "ai-image-tools", "ai-chat", "copywriting", "screenshot-qa", "video-subtitle", "ai-gen"}
|
||||
PROTECTED_TOOLS = {"translator", "image-ocr", "pdf-ocr", "ai-retouch", "doc-convert", "image-tools", "pdf-tools", "video-tools", "audio-tools", "text-to-image", "ai-image-tools", "copywriting", "screenshot-qa", "video-subtitle", "ai-gen"}
|
||||
MACHINE_RE = re.compile(r"^\d{10,16}$")
|
||||
|
||||
# verify() messages that unconditionally block activation
|
||||
@@ -1990,11 +1990,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self._reply(502, json.dumps({"code": 502, "message": f"AI 服务异常: {e}"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
def _handle_aichat(self):
|
||||
# AI 客服为免费引导功能(帮助用户发现工具),不做授权校验
|
||||
payload = self._read_payload()
|
||||
machine = str(payload.get("machine") or "")
|
||||
if check(machine, "ai-chat") != 200:
|
||||
self._reply(403, json.dumps({"code": 403, "message": "需要授权或今日免费试用已用完"}, ensure_ascii=False).encode("utf-8"), "application/json")
|
||||
return
|
||||
prompt = str(payload.get("prompt") or "").strip()[:4000]
|
||||
if not prompt:
|
||||
self._reply(400, json.dumps({"code": 400, "message": "请输入问题"}, ensure_ascii=False).encode(), "application/json")
|
||||
|
||||
Reference in new issue
Block a user