From 2809a54b29ed7793c0c592983d6ed56a7b38050d Mon Sep 17 00:00:00 2001 From: wjl2023 Date: Sat, 14 Mar 2026 20:44:29 +0800 Subject: [PATCH] fix: Add moonshot API temperature=1.0 constraint - Moonshot API (like Kimi) only accepts temperature=1.0 - Added 'moonshot' detection alongside 'kimi' in both raw_ask methods - Prevents 400 errors when using moonshot models --- llmcore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llmcore.py b/llmcore.py index 108a876..c7011d1 100644 --- a/llmcore.py +++ b/llmcore.py @@ -84,7 +84,7 @@ class ClaudeSession: return result[::-1] or messages[-2:] def raw_ask(self, messages, model=None, temperature=0.5, max_tokens=6144): model = model or self.default_model - if 'kimi' in model.lower(): temperature = 1.0 # kimi only accepts temp 1.0 + if 'kimi' in model.lower() or 'moonshot' in model.lower(): temperature = 1.0 # kimi/moonshot only accepts temp 1.0 headers = {"x-api-key": self.api_key, "Content-Type": "application/json", "anthropic-version": "2023-06-01"} payload = {"model": model, "messages": messages, "temperature": temperature, "max_tokens": max_tokens, "stream": True} try: @@ -169,7 +169,7 @@ class LLMSession: def raw_ask(self, messages, model=None, temperature=0.5): if model is None: model = self.default_model - if 'kimi' in model.lower(): temperature = 1.0 # kimi only accepts temp 1.0 + if 'kimi' in model.lower() or 'moonshot' in model.lower(): temperature = 1.0 # kimi/moonshot only accepts temp 1.0 headers = {"Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json", "Accept": "text/event-stream"} if self.api_mode == "responses": url = auto_make_url(self.api_base, "responses")