fix: KimiClient适配kimi-k系列模型(temperature强制为1)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user