fix(provider): Cerebras 等严格验证参数的 provider 返回 422 错误#1056
fix(provider): Cerebras 等严格验证参数的 provider 返回 422 错误#1056cdxiaodong wants to merge 1 commit intoiOfficeAI:mainfrom
Conversation
aioncli-core 的 OpenAIContentGenerator.generateContentStream() 硬编码了
stream_options: { include_usage: true },Cerebras API 严格验证请求参数,
遇到不支持的字段直接返回 422。
通过 patch-package 添加 shouldIncludeStreamOptions() 方法,对已知会
拒绝 stream_options 的 provider(如 Cerebras)不发送此参数。
关联 iOfficeAI#1038
|
@cdxiaodong Thanks for investigating the Cerebras 422 issue! However, the
The correct approach is to submit the Could you open a PR against |
|
@kuishou68 Thanks for the review! You're right — the fix should go upstream. I've submitted the upstream PR: iOfficeAI/aioncli#32 Once it's merged and a new version of |
|
@cdxiaodong The code logic itself is correct and follows the existing 1. Patch will not be appliedThe project uses Bun's native patching ( 2. Version mismatch
Recommended path forwardAs discussed earlier, the fix should go upstream in the |
概述
修复 Cerebras provider 在创建 chat 时返回
422 status code (no body)的问题。根因分析
@office-ai/aioncli-core的OpenAIContentGenerator.generateContentStream()在构造流式请求时硬编码了stream_options: { include_usage: true }参数。这也解释了为什么模型列表正常(简单 GET 请求,无 body)但聊天失败(POST 请求包含不支持的参数)。
修复方案
通过
patch-package给@office-ai/aioncli-core打补丁:shouldIncludeStreamOptions()方法,检查当前 provider 的 hostnamestream_options的 provider(如api.cerebras.ai)不发送此参数影响文件
patches/@office-ai+aioncli-core+0.24.5.patch(新增)测试计划
Closes #1038