feat: 添加账号时支持同步上游支持的模型#2892
Open
Arron196 wants to merge 1 commit into
Open
Conversation
新增 POST /admin/accounts/models/sync-upstream-preview 端点, 允许在创建账号流程中直接使用凭证同步上游支持的模型, 无需先保存账号获取 ID。 - 后端: 新增 SyncUpstreamModelsPreview handler - 前端: 新增 syncUpstreamModelsPreview API 函数 - 前端: ModelWhitelistSelector 支持 syncCredentials prop - 前端: CreateAccountModal 传递凭证给 ModelWhitelistSelector
0968355 to
57d9e15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在编辑账号时,用户可以通过"同步上游支持的模型"按钮自动获取上游服务(如 Anthropic、OpenAI)支持的模型列表。但在添加账号时,这个按钮不存在,用户需要手动输入模型列表,体验不一致。
改动内容
后端(Go)
POST /admin/accounts/models/sync-upstream-preview{ platform, type, base_url, api_key }参数,直接使用凭证调用上游 API 获取模型列表前端(Vue/TypeScript)
accounts.ts: 新增syncUpstreamModelsPreview()API 函数ModelWhitelistSelector.vue:syncCredentialspropcanSyncUpstream逻辑,支持通过凭证触发同步accountId或syncCredentials调用不同端点CreateAccountModal.vue:syncPreviewCredentials计算属性,从表单中提取凭证ModelWhitelistSelector传递:sync-credentials补充修复
main合并态下的单测失败TestDefaultPricingIncludesCodexAutoReview将codex-auto-review的价格硬编码为旧值,而主干里的model_prices_and_context_window.json已更新codex-auto-review默认值,避免后续同步价格文件时再次误伤无关 PR支持的平台
测试情况
编译验证
go build ./...通过vue-tsc --noEmit类型检查通过补充验证
go test -tags=unit ./internal/service -run TestDefaultPricingIncludesCodexAutoReview -count=1 -v通过go test -tags=unit ./internal/service -count=1通过代码审查
SyncUpstreamModelshandler 一致边界情况
改动文件