Motivation: JSONCombine was failing with 'dict' has no attribute 'strip' when receiving dictionary inputs, and strict APIs (like Qwen) returned 400 Errors when receiving the non-standard 'seed' field in the payload. Implementation: Updated JSONCombine in json_builder.py to handle both string and dict types safely. Removed the seed field from the API payload in openai_compatible.py to strictly follow CONTRIBUTING.md Rule 3.1 and ensure standard OpenAI compatibility.
1.4 KiB
1.4 KiB
任务追踪:修复 API Seed 参数类型错误
阶段与进度
- 定位错误源头 ->
nodes/openai_compatible.py文件中向payload添加seed时。 - 分析为什么 seed 不是 integer -> 虽然 Python 中转换为了
int(seed),但是 ComfyUI 传入的随机种子可能是 64 位无符号整数(非常巨大),导致发送给云厂商(如阿里云大模型)时超出了某些强类型解析器支持的最大整型(通常是 32 位),使其被错误识别或解析为指数浮点数(float),进而抛出“必须是 Integer”的报错。 - 修复代码转换 -> 根据
CONTRIBUTING.md的规范(3.1 节),非标准的seed应当完全从 payload 抽离,而不能传给远端接口。 - 验证修复 -> 已删去构建
seed参数的逻辑,并使用测试脚本检查模拟的 LLMClient 参数,由于seed未进入到字典里,已完美避免此“must be Integer/Float”的大模型解析异常并在本地安全屏蔽了这个 ComfyUI-LLMs-Toolkit 发送错误。
决策与思考
- 初始阶段:用户反馈
[Error] [BAD_REQUEST] 请求参数有误 API: 'seed' must be Integer,这通常发生在调用大模型 API(如 qwen3-vl-plus)时,传入的seed字段格式不对(可能是 float 或是 string)。 - 搜索发生点:主要在
ComfyUI-LLMs-Toolkit中的openai_compatible.py文件,我需要抓取seed关键字。
遇到的错误
无