From 52f5b91b84c363c6a72379fb68a2f6ddf9f2f4bd Mon Sep 17 00:00:00 2001 From: hp0912 <809211365@qq.com> Date: Sat, 2 May 2026 01:08:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skills/voice-message/scripts/voice_message.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/skills/voice-message/scripts/voice_message.py b/skills/voice-message/scripts/voice_message.py index 9716a55..d713d0a 100644 --- a/skills/voice-message/scripts/voice_message.py +++ b/skills/voice-message/scripts/voice_message.py @@ -667,7 +667,14 @@ def _read_mimo_non_stream_response(response, audio_format: str) -> tuple[bytes, try: payload = json.loads(raw_body) except json.JSONDecodeError as exc: - raise RuntimeError(f"解析 mimo 响应失败: {exc}, 响应内容: {raw_body}") from exc + snippet = raw_body[:300] + if " tuple[bytes, str]: if not api_key: raise RuntimeError("mimo api_key 不能为空") + # 兼容用户把 base_url 配成不带 /v1 的根地址(如 New API / OneAPI 等网关), + # 避免请求被前端 SPA 兜底返回 index.html。 + parsed_base = urllib.parse.urlsplit(base_url) + base_path = parsed_base.path or "" + if not base_path or base_path == "/": + base_url = f"{base_url}/v1" + url = f"{base_url}/chat/completions" payload, audio_format, stream = _build_mimo_payload(config, params) request_data = json.dumps(payload, ensure_ascii=False).encode("utf-8")