Files
kefu/deploy/ark-chat-config-20260917/model_protocol.py.diff
T
2026-09-21 10:34:06 +08:00

38 lines
1.6 KiB
Diff

--- before/wechat_rpa/model_protocol.py
+++ wechat_rpa/model_protocol.py
@@ -51,6 +51,24 @@
ENDPOINT_MODES = ("auto", "exact")
+
+
+def chat_config_error(kind: str, base_url: str, model: str = "") -> str:
+ """Identify known video configurations before sending a chat request."""
+ if detect_kind(kind, base_url) != "openai":
+ return ""
+ path = (urlparse(base_url or "").path or "").lower().rstrip("/")
+ model_name = str(model or "").strip().lower().rsplit("/", 1)[-1]
+ video_path = path.endswith("/contents/generations/tasks") or "/contents/generations/tasks/" in path
+ video_model = model_name.startswith(("doubao-seedance-", "seedance-"))
+ if video_path or video_model:
+ return (
+ "配置的是 Seedance 视频生成模型或视频任务接口,不能用于客服聊天。"
+ "请在火山方舟开通支持 Chat API 的文本/视觉理解模型,填写其模型 ID 或推理接入点 ID;"
+ "接口地址使用 https://ark.cn-beijing.volces.com/api/v3/chat/completions。"
+ "完整地址开关只控制路径拼接,不会转换接口协议。"
+ )
+ return ""
def endpoint_url(kind: str, base_url: str, mode: str = "auto") -> str:
@@ -196,6 +214,9 @@
) -> dict:
"""按各家的形状拼请求体。"""
kind = detect_kind(kind, base_url)
+ config_error = chat_config_error(kind, base_url, model)
+ if config_error:
+ raise ValueError(config_error)
if kind == "claude":
system_text, turns = claude_messages(messages)
payload = {