From 5f565f4dffed3f141940054b97353d6ea043aca2 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Mon, 31 Aug 2026 17:31:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20KimiClient=E9=80=82=E9=85=8Dkimi-k?= =?UTF-8?q?=E7=B3=BB=E5=88=97=E6=A8=A1=E5=9E=8B(temperature=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E4=B8=BA1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bossai.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bossai.py b/bossai.py index 5cf7a06..7add04d 100644 --- a/bossai.py +++ b/bossai.py @@ -2874,7 +2874,13 @@ class KimiClient: raise RuntimeError("KIMI_API_KEY is not configured") def chat(self, messages: list[dict], temperature: float = 0.2, timeout: int = 60) -> str: - """调用云端模型,超时 60s。""" + """调用云端模型,超时 60s。 + + kimi-k 系列模型只允许 temperature=1,自动适配。 + """ + # kimi-k 系列模型只允许 temperature=1 + if self.model.startswith("kimi-k"): + temperature = 1.0 body = json.dumps({"model": self.model, "messages": messages, "temperature": temperature}).encode() req = Request(self.base_url + "/chat/completions", data=body, headers={"Authorization": "Bearer " + self.api_key, "Content-Type": "application/json"}) with urlopen(req, timeout=timeout) as response: @@ -2889,6 +2895,9 @@ class KimiClient: Raises: Exception: API 错误或超时 """ + # kimi-k 系列模型只允许 temperature=1 + if self.model.startswith("kimi-k"): + temperature = 1.0 body = json.dumps({ "model": self.model, "messages": messages,