Skip to content

fix(embeddings): 国产平台分组按分组平台调度账号 - #8353

Closed
ychy7001 wants to merge 1 commit into
Wei-Shaw:mainfrom
ychy7001:fix/embeddings-group-platform
Closed

ychy7001 wants to merge 1 commit into
Wei-Shaw:mainfrom
ychy7001:fix/embeddings-group-platform

Conversation

@ychy7001

Copy link
Copy Markdown
Contributor

问题

/v1/embeddings 入口(handler/openai_embeddings.go)调用 SelectAccountWithSchedulerForCapability 时没有传平台,调度器默认按 openai 平台选号。分组平台为 zhipu、deepseek 等国产平台时,组内账号都选不到,请求返回无可用账号;无可用账号的错误分类也写死成 PlatformOpenAI。chat completions、responses 等入口已经用 openAICompatibleRequestPlatform 解析请求平台,只有 embeddings 漏掉了。

复现

  1. 建一个平台为 zhipu 的分组,里面放一个 zhipu API Key 账号(base_url 指向它的 OpenAI 兼容地址)。
  2. 用这个分组的 key 请求 POST /v1/embeddings,例如 {"model":"embedding-3","input":"hi"}。
  3. 结果返回无可用账号,预期是转发到 zhipu 账号。

修改内容

  • 用 openAICompatibleRequestPlatform(ctx, apiKey) 解析请求平台,通过 platformOverride 传给调度器。
  • 两处 classifyNoAccountErrorFromGin 改用同一个请求平台。

测试

  • 新增 TestEmbeddingsDomesticGroupSelectsGroupPlatformAccount:zhipu 分组里同时有 openai 和 zhipu 账号时,请求只会打到 zhipu 账号,URL 为 <base_url>/embeddings。不加修复时这个用例失败。
  • go test -tags unit ./internal/handler/... 通过。

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

Embeddings 入口调用 SelectAccountWithSchedulerForCapability 时未传平台,
调度器默认按 openai 平台选号;分组平台为 zhipu 等国产平台时选不到账号,
无可用账号的错误分类也按 openai 判断。改为与 chat completions 一致,
使用 openAICompatibleRequestPlatform 解析的请求平台。
@ychy7001
ychy7001 force-pushed the fix/embeddings-group-platform branch from 9ac5cde to 3ae3085 Compare October 26, 2026 09:19
hjkl950217 added a commit to hjkl950217/sub2api that referenced this pull request Nov 6, 2026
@ychy7001 ychy7001 closed this by deleting the head repository Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant