From 81c0ab7cca445ecbd26ef4272534352eeb4233fa Mon Sep 17 00:00:00 2001 From: duwanze Date: Tue, 26 May 2026 13:58:05 +0800 Subject: [PATCH] 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 --- backend/app/services/oasis_profile_generator.py | 17 +++++++++++------ backend/app/utils/llm_client.py | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/app/services/oasis_profile_generator.py b/backend/app/services/oasis_profile_generator.py index 7704a627..580bbd85 100644 --- a/backend/app/services/oasis_profile_generator.py +++ b/backend/app/services/oasis_profile_generator.py @@ -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 diff --git a/backend/app/utils/llm_client.py b/backend/app/utils/llm_client.py index 6c1a81f4..86fbf8a8 100644 --- a/backend/app/utils/llm_client.py +++ b/backend/app/utils/llm_client.py @@ -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)