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,