fix: skip response_format parameter for MiniMax models

MiniMax API does not support the response_format parameter with
json_object type, causing 400 errors. Added model name detection
to conditionally skip this parameter for MiniMax models.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
duwanze 2026-05-26 13:58:05 +08:00
parent 96096ea0ff
commit 81c0ab7cca
2 changed files with 13 additions and 7 deletions

View File

@ -527,16 +527,21 @@ class OasisProfileGenerator:
for attempt in range(max_attempts):
try:
response = self.client.chat.completions.create(
model=self.model_name,
messages=[
# MiniMax 不支持 response_format 参数,跳过
kwargs = {
"model": self.model_name,
"messages": [
{"role": "system", "content": self._get_system_prompt(is_individual)},
{"role": "user", "content": prompt}
],
response_format={"type": "json_object"},
temperature=0.7 - (attempt * 0.1) # 每次重试降低温度
"temperature": 0.7 - (attempt * 0.1) # 每次重试降低温度
# 不设置max_tokens让LLM自由发挥
)
}
if "MiniMax" not in self.model_name and "minimax" not in self.model_name:
kwargs["response_format"] = {"type": "json_object"}
response = self.client.chat.completions.create(**kwargs)
content = response.choices[0].message.content

View File

@ -58,7 +58,8 @@ class LLMClient:
"max_tokens": max_tokens,
}
if response_format:
# MiniMax 不支持 response_format 参数,跳过
if response_format and "MiniMax" not in self.model and "minimax" not in self.model:
kwargs["response_format"] = response_format
response = self.client.chat.completions.create(**kwargs)