fix: 移除 response_format=json_object,改为依赖 prompt 约束
回退上一条推断式修复(模型名匹配没有官方依据)。 改为在 script_service 调用层直接移除该参数: - system prompt 已明确要求'只输出纯 JSON' - safe_parse_ai_json_response 已做容错解析和 markdown 清洗 - 不依赖特定模型对 response_format 的支持
This commit is contained in:
@@ -181,12 +181,7 @@ class VolcengineProvider(LLMProvider):
|
||||
if "reasoning_effort" in kwargs:
|
||||
request_params["extra_body"] = {"reasoning_effort": kwargs["reasoning_effort"]}
|
||||
|
||||
# 豆包系列模型不支持 response_format.type="json_object"
|
||||
# 仅对兼容模型(如 DeepSeek、GPT 系列)启用
|
||||
if (
|
||||
kwargs.get("response_format") == "json_object"
|
||||
and "doubao" not in (model_id or "").lower()
|
||||
):
|
||||
if kwargs.get("response_format") == "json_object":
|
||||
request_params["response_format"] = {"type": "json_object"}
|
||||
|
||||
# 调用 API
|
||||
|
||||
@@ -71,13 +71,13 @@ class ScriptService:
|
||||
)
|
||||
|
||||
# 调用 AI 生成
|
||||
# 注意:system prompt 中已要求"只输出纯 JSON",不依赖 response_format 参数
|
||||
result = await model_router.generate(
|
||||
prompt=user_prompt,
|
||||
system_prompt=system_prompt,
|
||||
model_id=model,
|
||||
task_type="script",
|
||||
temperature=0.7,
|
||||
response_format="json_object",
|
||||
)
|
||||
|
||||
if not result.content or not result.content.strip():
|
||||
|
||||
Reference in New Issue
Block a user