Skip to content

fix(channel): declare native embeddings and rerank routes for SiliconFlow - #834

Merged
tbphp merged 1 commit into
tbphp:mainfrom
hheei:fix/siliconflow-rerank-embeddings
Oct 8, 2026
Merged

tbphp merged 1 commit into
tbphp:mainfrom
hheei:fix/siliconflow-rerank-embeddings

Conversation

@hheei

@hheei hheei commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

关联 Issue / Related Issue

Closes #833

变更内容 / Change Content

  • Bug 修复 / Bug fix

内置渠道 SiliconFlow 的路由表没有声明它原生支持的 openai-embeddings 与 rerank,导致用该渠道建组后 /v1/embeddings 和 /v1/rerank 全部返回 503 no_available_candidate。

internal/channel/modules/siliconflow.go 绑定的是 ProviderOpenAICompatible + FixedBaseURL: https://api.siliconflow.cn/v1,执行层对此 provider kind 已经放行这两个协议:

  • internal/execution/bifrost/capabilities.go:nativeRouteImplemented 对 ProviderOpenAICompatible 放行 protocol.Rerank,并在 OpenAIEmbeddings 分支放行 OperationEmbeddingsCreate / OperationProbe。
  • internal/execution/bifrost/rerank.go:prepareRerank 对非网关 provider 使用 path /rerank,配合固定 base URL 正好拼成 https://api.siliconflow.cn/v1/rerank。
  • 同样的凭据把 openai_compatible 渠道的 base_url 指向同一地址时,两个端点都能 200,说明缺口只在预设渠道的路由声明。

改动内容:

  1. internal/channel/modules/siliconflow.go:新增 4 条 native 路由(OpenAIEmbeddings 的 create/probe、Rerank 的 rerank/probe)。
  2. internal/channel/rerank_module_test.go:把 SiliconFlow 加入 rerank 能力白名单。
  3. internal/channel/embeddings_module_test.go:把 SiliconFlow 加入 embeddings 能力白名单。
  4. internal/channel/route_golden_test.go:更新内置路由契约摘要 wantDigest。

自查清单 / Checklist

  • 我已运行 make check,或在说明中写明无法运行的原因和未验证范围。
  • 本 PR 范围聚焦,未包含无关改动。
  • 我已更新必要的公开文档或发布说明。
  • 我已确认提交、日志和测试数据不包含敏感信息。
  • 如适用,我已说明兼容性或数据迁移影响。

补充说明:

  • 已运行 gofmt -l(干净)、go vet ./internal/channel/... ./internal/execution/...(无输出)、go test -count=1 . ./internal/...(7773 passed / 41 skipped)。唯一的失败 internal/gateway 的 TestCodexLiveCreatesAcrossGroupsPinsOwnerAndLogsOnce(websocket: bad handshake)与本改动无关且不稳定,单独重跑一次通过。
  • 未运行 make check 中的前端 lint/format/build 与 make release-simulate(本机未安装 pnpm 及验收所需的 DBX 辅助脚本);改动不涉及 web/。
  • 兼容性/迁移:仅扩展渠道能力声明,不改变存储结构、迁移或既有渠道行为;原先用 openai_compatible + base_url=https://api.siliconflow.cn/v1 的绕过配置不受影响。注意 rerank 请求路径对 ProviderOpenAICompatible 是 base_url + /rerank,故 base URL 需保持包含 /v1 的形式(预设默认值即 https://api.siliconflow.cn/v1)。
  • 实测验证(本地源码构建):改动前 siliconflow 渠道的 /v1/rerank、/v1/embeddings 均 503 no_available_candidate;改动后两者均 200 并返回真实结果。rerank 走别名 bge-reranker-v2-m3 正常,未配置别名的上游 ID 不在模型列表中,行为与其他渠道一致。

…Flow

The SiliconFlow preset binds provider kind `openai-compatible` with a fixed
base URL of https://api.siliconflow.cn/v1, but its route table only declared
chat completions, model listing and probe plus converted Responses/Anthropic/
Gemini. It never declared the two protocols SiliconFlow serves natively:

- POST /v1/embeddings (e.g. BAAI/bge-m3)
- POST /v1/rerank     (e.g. BAAI/bge-reranker-v2-m3)

The execution layer already supports both for this provider kind:
`nativeRouteImplemented` accepts rerank for `ProviderOpenAICompatible`, and
`prepareRerank` resolves the upstream URL as base URL + `/rerank`, which is
exactly https://api.siliconflow.cn/v1/rerank. The generic `openai_compatible`
channel pointed at the same base URL already works, so only the preset route
declaration was missing and every SiliconFlow group answered
`no_available_candidate` (HTTP 503) for embeddings and rerank.

Declare the four routes and update the contracts that freeze the route table:
the rerank/embeddings capability tests and the built-in route golden digest.

Verified with a local build against the real upstream: before the change a
SiliconFlow group returned 503 `no_available_candidate` for both endpoints;
after the change /v1/rerank and /v1/embeddings return 200.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 4728a146-5a49-4bcd-bf58-ab7fc5e352f5
📥 Commits

Reviewing files that changed from the base of the PR and between b771ef0 and 413dbf8.

📒 Files selected for processing (4)
  • internal/channel/embeddings_module_test.go
  • internal/channel/modules/siliconflow.go
  • internal/channel/rerank_module_test.go
  • internal/channel/route_golden_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

SiliconFlow 新增 OpenAI Embeddings 创建与探测路由,以及 Rerank 执行与探测路由。对应能力测试现将 SiliconFlow 纳入预期支持的渠道。内置路由摘要的预期值也已更新,摘要计算和不匹配时的失败逻辑保持不变。

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 413db

The new routes resolve to the intended SiliconFlow embeddings and rerank endpoints, and the updated capability checks and route contract include them. No actionable merge risk is evident.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:为 SiliconFlow 声明原生 embeddings 和 rerank 路由。内容具体、简洁,且与改动范围一致。
Description check ✅ Passed 描述完整包含关联 Issue、变更内容、自查清单、测试结果、未验证范围及兼容性影响。内容与 PR 改动和目标一致。
Linked Issues check ✅ Passed PR 满足开放的直接关联 Issue #833 的编码要求。internal/channel/modules/siliconflow.go 新增 OpenAIEmbeddings 的 create/probe 原生路由和 Rerank 的 rerank/probe 原生路由。相关能力测试白名单和内置路由 golden 摘要同步更新。该实现与 Issue 要求的 SiliconFlow …
Out of Scope Changes check ✅ Passed 变更范围与 Issue #833 一致。修改仅涉及 SiliconFlow 路由声明、embeddings/rerank 能力契约测试和路由 golden 契约。未发现与该修复无关的源代码、数据结构或其他行为变更。
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tbphp tbphp self-assigned this Oct 8, 2026
@tbphp tbphp added enhancement New feature or request good first issue A well-defined task suitable for first-time contributors. labels Oct 8, 2026
@tbphp tbphp added this to the v2.0.0 milestone Oct 8, 2026
@tbphp
tbphp merged commit 6c6380a into tbphp:main Oct 8, 2026
7 checks passed
XMZO pushed a commit to DesuwaDev/gpt-load that referenced this pull request Oct 9, 2026
Sync upstream through 6c6380a (tbphp#828, tbphp#832, tbphp#834): Bifrost compatible
assistant tool turn merging, SiliconFlow native embeddings and rerank
routes, and README sponsorship update. No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfNx753nmeMu5mT6AX6bpt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue A well-defined task suitable for first-time contributors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(channel): SiliconFlow 预设渠道缺少原生 embeddings / rerank 路由声明

2 participants