feat: add Alibaba Cloud Token Plan channel type 新增阿里云百炼 Token Plan 渠道类型#5770
feat: add Alibaba Cloud Token Plan channel type 新增阿里云百炼 Token Plan 渠道类型#5770shuaiZend wants to merge 1 commit into
Conversation
Add dedicated channel type for Alibaba Cloud Bailian Token Plan service,
enabling proper /v1/responses endpoint support (required for Codex tools).
Problem:
- Token Plan uses compatible-mode API at token-plan.cn-beijing.maas.aliyuncs.com
- Using the existing 'Ali Qianwen' channel type routes responses requests to
DashScope-specific paths (/api/v2/apps/protocols/...) which Token Plan doesn't support
- This causes 500 errors on /v1/responses while /v1/chat/completions works
Solution:
- New channel type 59 (ChannelTypeAliTokenPlan) with dedicated adaptor
- Adaptor inherits from ali.Adaptor but overrides:
- GetRequestURL: routes to /compatible-mode/v1/{responses,chat/completions,...}
- SetupRequestHeader: removes DashScope-specific headers (X-DashScope-SSE)
- DoRequest: ensures Go embedding method dispatch calls overridden methods
- Registered in both classic and default frontends with model fetch support
- Default base URL: https://token-plan.cn-beijing.maas.aliyuncs.com
Closes QuantumNous#5763
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughAdds a new Ali Token Plan channel type end-to-end: backend constants, adaptor selection, request routing, stream support, and web channel options. The adaptor maps relay requests to Ali compatible-mode endpoints and sets request headers for the new channel. ChangesAli Token Plan channel support
Sequence Diagram(s)sequenceDiagram
participant relay.GetAdaptor
participant ali_token_plan.Adaptor
participant channel.DoApiRequest
participant channel.SetupApiRequestHeader
participant Ali compatible-mode API
relay.GetAdaptor->>ali_token_plan.Adaptor: return &ali_token_plan.Adaptor{}
ali_token_plan.Adaptor->>channel.DoApiRequest: DoRequest(...)
channel.DoApiRequest->>ali_token_plan.Adaptor: GetRequestURL(info)
channel.DoApiRequest->>ali_token_plan.Adaptor: SetupRequestHeader(c, req, info)
ali_token_plan.Adaptor->>channel.SetupApiRequestHeader: baseline headers
channel.DoApiRequest->>Ali compatible-mode API: send relay request
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Important
📝 变更描述 / Description
背景:
Token Plan 的 API 地址为 token-plan.cn-beijing.maas.aliyuncs.com,使用标准 OpenAI 兼容协议(/compatible-mode/v1/...)。但现有"阿里千问"渠道类型的适配器会将 responses 请求路由到 DashScope 专有路径(/api/v2/apps/protocols/...),并注入 X-DashScope-SSE: enable 等专有头部,导致 Token Plan 返回 500 错误。
实现: 创建 ali_token_plan 适配器包,嵌入 ali.Adaptor 并覆写三个方法:
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
已部署至生产环境,完整验证所有端点:
Summary by CodeRabbit
New Features
Bug Fixes