Skip to content

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

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

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

Conversation

@ychy7001

@ychy7001 ychy7001 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Resubmission of #8353. The original pull request was automatically closed when its head fork was accidentally deleted. This pull request restores the original head 3ae308590f33 and carries over the original validation below.

问题

/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/... 通过。

Embeddings 入口调用 SelectAccountWithSchedulerForCapability 时未传平台,
调度器默认按 openai 平台选号;分组平台为 zhipu 等国产平台时选不到账号,
无可用账号的错误分类也按 openai 判断。改为与 chat completions 一致,
使用 openAICompatibleRequestPlatform 解析的请求平台。
xiaoguai1818 pushed a commit to xiaoguai1818/sub2api that referenced this pull request Nov 21, 2026
Restore Antigravity Responses custom-tool roundtrips and correct Embeddings platform scheduling. Harden OAuth probe fencing, request-scoped Gemini 403 behavior, OpenAI stream failover and WebSocket current-turn safety.

Preserve Claude/GPT-6.2/Grok protocol details and model observations; correct Fable/Kimi quota refreshes and user-vs-account cost reporting. Bound scheduler fallback, request memory retention and shutdown/stream lifecycles without unapproved pricing or schema changes.

Local checks: complete Go unit packages, PostgreSQL 18.1/Redis 8.4 repository and audit integration, focused -race, frontend typecheck/lint/1858 Vitest/build, backend lint 0 issues and embedded server build. Remote CI/Security Scan remain pending.

Upstream references: Wei-Shaw/sub2api Wei-Shaw#8833 Wei-Shaw#8875 Wei-Shaw#8856 Wei-Shaw#8730 Wei-Shaw#8990 Wei-Shaw#8806 Wei-Shaw#8832 Wei-Shaw#8809 Wei-Shaw#8164 Wei-Shaw#8804 Wei-Shaw#8773 Wei-Shaw#8309.
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