Repository navigation
feat: 获取模型列表按钮白名单 - #1885
feat: 获取模型列表按钮白名单#1885Calcium-Ion merged 2 commits into
获取模型列表按钮白名单#1885Conversation
WalkthroughAdds support for fetching upstream models for ChannelTypeZhipu_v4 in the backend. Updates the frontend modal to show the “获取模型列表” button only for specific channel types via a new MODEL_FETCHABLE_TYPES set. No exported signatures changed; existing fetch logic remains. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant M as EditChannelModal (UI)
participant S as Server API
participant Z as Zhipu v4 Upstream
rect rgb(240,248,255)
note over M: Render form
M->>M: Check inputs.type ∈ MODEL_FETCHABLE_TYPES
alt Supported type
M->>U: Show “获取模型列表” button
U->>M: Click fetch
M->>S: GET /channels/:id/models
alt ChannelTypeZhipu_v4
S->>Z: GET {baseURL}/api/paas/v4/models
Z-->>S: 200 Model list
else Other supported types
S->>S: Route to respective upstream
end
S-->>M: Model list
M-->>U: Display models
else Unsupported type
M->>U: Button hidden
end
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
controller/channel.go(1 hunks)web/src/components/table/channels/modals/EditChannelModal.jsx(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.
Applied to files:
web/src/components/table/channels/modals/EditChannelModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.
Applied to files:
web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (1)
controller/channel.go (1)
constant/channel.go (1)
ChannelTypeZhipu_v4(30-30)
🔇 Additional comments (2)
web/src/components/table/channels/modals/EditChannelModal.jsx (2)
88-106: Keeping fetch support explicit looks goodThanks for centralizing the fetchable channel types in a single Set; having the whitelist up top makes the support surface easy to audit and keeps the UI aligned with backend capabilities.
1895-1903: Conditional render matches the new whitelistScoping the button render with
MODEL_FETCHABLE_TYPES.has(inputs.type)cleanly prevents unsupported channels from triggering the upstream fetch flow. This keeps the UX consistent with the backend restriction.
…e-fetch-model-button feat: `获取模型列表`按钮白名单
…e-fetch-model-button feat: `获取模型列表`按钮白名单
…e-fetch-model-button feat: `获取模型列表`按钮白名单
PR 类型
PR 是否包含破坏性更新?
仅为适当的渠道渲染
获取模型列表按钮,新的渠道类型如果需要获取模型列表的功能,需要手动在web/src/components/table/channels/modals/EditChannelModal.jsx中加入白名单PR 描述
获取模型列表按钮智谱

火山
