feat(channel): 使用表单配置获取上游模型 - #5949
Conversation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe channel model-fetching flow was refactored end-to-end. The backend now binds channel-shaped request data and returns upstream model IDs, while the frontend builds fetch payloads from form state and adjusts the Fetch Models dialog wiring. ChangesChannel model fetching refactor
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Signed-off-by: zuiho <2324465096@qq.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@controller/channel.go`:
- Around line 1171-1204: FetchModels currently binds the full model.Channel,
which lets client-supplied fields influence fetchChannelUpstreamModelIDs and
downstream GetNextEnabledKey/CacheGetChannelInfo behavior. Replace the
ShouldBindJSON target with a narrow request DTO containing only request-scoped
fields needed for model fetching, then resolve any persisted channel state
server-side before calling fetchChannelUpstreamModelIDs. Keep the existing
FetchModels flow and validation logic, but ensure channel.Id and
channel.ChannelInfo are not accepted from the client payload.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5b3978f3-be90-4cd6-8594-7a28e28e1565
📒 Files selected for processing (5)
controller/channel.gocontroller/channel_fetch_models_test.goweb/default/src/features/channels/api.tsweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxweb/default/src/features/channels/lib/channel-form.ts
Signed-off-by: zuiho <2324465096@qq.com>
51fdfc5 to
2b6f1df
Compare
Important
📝 变更描述 / Description
当前在创建或编辑渠道时,获取上游模型的行为没有完全使用表单里的未保存配置:创建模式只提交 type/key/base_url,后端单独手写了一套模型列表请求逻辑;编辑模式在未保存新 key 时仍使用已保存渠道配置。这会导致表单里刚填的代理设置、header override 等配置无法参与获取模型,也容易和已保存渠道的正式获取逻辑不一致。
本 PR 将
POST /api/channel/fetch_models改为接收渠道表单配置并复用现有fetchChannelUpstreamModelIDs。这样 provider 特殊路径、代理、header override、Ollama/Gemini 等逻辑都和已保存渠道获取上游模型保持一致。前端新增从渠道表单生成获取模型 payload 的转换函数。创建渠道时会直接用当前表单中的 key、Base URL、代理设置和 header override 拉取模型;编辑已有渠道时,只有用户在表单中填入新 key 才会走表单配置请求,未填写新 key 时仍保持原有按已保存渠道获取的行为,避免把已保存密钥发送到任意未保存的 Base URL。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix。📸 运行证明 / Proof of Work
已执行:
说明:当前本地 Windows 环境未安装
go/gofmt,因此 Go 编译与格式检查由 CI 继续验证。Summary by CodeRabbit
New Features
Bug Fixes
Tests