fix(llm): unify JSON output handling across providers and fix tool+json_output compatibility

- Remove redundant `response_format` injection for VOLCANO provider since it's unsupported; rely on system prompt injection instead
- Extend system prompt JSON injection logic to cover VOLCANO and tool-enabled cases universally
- Simplify model parameter construction by removing redundant `params["model_kwargs"] = model_kwargs` assignments
- Refactor `CompatibleChatOpenAI._get_request_payload` to strip `response_format` when tools are present, avoiding strict validation errors in langchain_openai
- Fix timestamp calculation order in `datetime_tool.py` to avoid integer truncation before multiplication
This commit is contained in:
Timebomb2018
2026-04-17 14:19:40 +08:00
parent 52f7ea7456
commit 377ddd2b9b
5 changed files with 51 additions and 26 deletions

View File

@@ -226,9 +226,12 @@ class LLMNode(BaseNode):
self.messages = [{"role": "user", "content": rendered}]
# ChatTongyi 要求 messages 含 'json' 字样才能使用 response_format在 system prompt 中注入
if (self.typed_config.json_output
and model_info.provider.lower() == ModelProvider.DASHSCOPE
and not model_info.is_omni):
# VOLCANO 模型不支持 response_format同样需要 system prompt 注入
need_json_prompt = self.typed_config.json_output and (
(model_info.provider.lower() == ModelProvider.DASHSCOPE and not model_info.is_omni)
or model_info.provider.lower() == ModelProvider.VOLCANO
)
if need_json_prompt:
system_msg = next((m for m in self.messages if m["role"] == "system"), None)
if system_msg:
system_msg["content"] += "\n请以JSON格式输出。"