feat(gateway): 支持 OpenAI Embeddings API - #496
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: QUIET Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthrough新增 OpenAI Embeddings 协议和 Merge Risk: 🟡 Moderate · up to The PR adds the embeddings endpoint and automatically enables it for existing AccessKeys without explicit protocol filters; additionally, credential probing may validate a different upstream target than actual requests, causing incorrect health results or routing decisions. Merge should wait for explicit acceptance or correction of the target-consistency risk and rollout ownership. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches✨ Simplify code
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.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (2)
internal/gateway/response_representation.go-744-756 (1)
744-756: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick winSensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor
Reachability: External · Exploitability: Difficult
收窄
embeddingsJSONOpaqueVector的传播范围。当
data[*].embedding是对象时,当前逻辑会跳过其键和值的凭据扫描。上游可将凭据放入嵌套对象并原样转发。对象分支不要继承不透明状态;保留数组分支对向量元素的传播,并增加嵌套对象回归测试。internal/execution/bifrost/executor.go-481-481 (1)
481-481: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win将 Embeddings 探针改用规范化的目标配置。
对于
ProviderOpenAI和ProviderOpenAICompatible,探针使用原始的spec.TargetConfig,而创建请求使用resolved.TargetConfig。ResolveExecutionTarget会规范化base_url,因此原始配置可能使探针解析失败或访问不同目标。请将探针分支改为使用
resolved.TargetConfig。
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: QUIET
Plan: Pro Plus
Run ID: 9c232d39-7778-475f-9d6d-d719c559b5b6
📒 Files selected for processing (77)
README.mdREADME_CN.mdinternal/channel/compiler.gointernal/channel/embeddings_module_test.gointernal/channel/modules/openai.gointernal/channel/modules/openai_compatible.gointernal/channel/modules/openrouter.gointernal/channel/route_golden_test.gointernal/container/container.gointernal/container/container_test.gointernal/control/access_keys_test.gointernal/control/credential_probe.gointernal/control/credential_probe_test.gointernal/control/route_inspect_test.gointernal/control/validation.gointernal/control/validation_test.gointernal/dialect/openai_embeddings.gointernal/dialect/openai_embeddings_test.gointernal/dialect/openai_embeddings_usage.gointernal/dialect/openai_embeddings_usage_test.gointernal/dialect/standard_request.gointernal/execution/bifrost/capabilities.gointernal/execution/bifrost/embedding_wire_test.gointernal/execution/bifrost/embeddings.gointernal/execution/bifrost/embeddings_probe_test.gointernal/execution/bifrost/embeddings_test.gointernal/execution/bifrost/executor.gointernal/execution/bifrost/list_models.gointernal/execution/bifrost/list_models_test.gointernal/execution/bifrost/runtime.gointernal/execution/bifrost/runtime_manager_test.gointernal/execution/contracts.gointernal/execution/contracts_test.gointernal/execution/resource_limits.gointernal/execution/resource_limits_test.gointernal/execution/responsealias/response_alias.gointernal/execution/responsealias/response_alias_test.gointernal/execution/validation.gointernal/gateway/embeddings_response_representation_test.gointernal/gateway/execution_forward.gointernal/gateway/execution_forward_test.gointernal/gateway/models.gointernal/gateway/models_test.gointernal/gateway/request_log.gointernal/gateway/request_log_test.gointernal/gateway/response_representation.gointernal/gateway/router.gointernal/gateway/router_test.gointernal/health/execution_judge.gointernal/health/execution_judge_v2_test.gointernal/protocol/protocol.gointernal/protocol/protocol_test.gointernal/state/snapshot.gointernal/state/snapshot_test.goweb/src/api/control/protocols.tsweb/src/app/resources/channels.tsweb/src/app/resources/request-logs.tsweb/src/app/resources/route-inspection.tsweb/src/features/access-keys/AccessKeyCollection.vueweb/src/features/access-keys/AccessKeyScopeEditor.vueweb/src/features/groups/credentials/CredentialTestDialog.vueweb/src/features/models/ModelSpecSheet.vueweb/src/features/monitor/InspectorForm.vueweb/src/features/monitor/InspectorTab.vueweb/src/features/monitor/LogsAdvancedFilterDrawer.vueweb/src/i18n/locales/en-US/access-keys.tsweb/src/i18n/locales/en-US/core.tsweb/src/i18n/locales/en-US/models.tsweb/src/i18n/locales/en-US/monitor.tsweb/src/i18n/locales/ja-JP/access-keys.tsweb/src/i18n/locales/ja-JP/core.tsweb/src/i18n/locales/ja-JP/models.tsweb/src/i18n/locales/ja-JP/monitor.tsweb/src/i18n/locales/zh-CN/access-keys.tsweb/src/i18n/locales/zh-CN/core.tsweb/src/i18n/locales/zh-CN/models.tsweb/src/i18n/locales/zh-CN/monitor.ts
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.
关联 Issue / Related Issue
N/A(基于已确认的技术方案实施)
变更内容 / Change Content
Bug 修复 / Bug fix
新功能 / New feature
其他改动 / Other changes
新增严格原生
POST /v1/embeddings,仅支持 OpenAI Embeddings wire,不做协议转换。覆盖 OpenAI、OpenRouter、OpenAI Compatible 三类 API Key 渠道;订阅渠道保持不支持。
复用现有 Bifrost、DirectKey、调度、重试、健康、日志、usage 与定价流程,并为 embedding-only 模型增加有界 Probe fallback。
模型发现、AccessKey 过滤、Route Inspector、请求日志和三语管理 UI 同步支持
openai-embeddings/embeddings_create。对大向量响应执行解码后限额、敏感字段扫描和零拷贝投影,避免向量内容进入日志或被额外物化。
更新中英文 README 的能力矩阵、渠道边界和 AccessKey 兼容性说明。
兼容性:无数据库迁移。未配置协议过滤的 AccessKey 会自动获得新协议;显式过滤仍按原配置生效。降级前应先移除显式
openai-embeddings过滤值。自查清单 / Checklist
make check,或在说明中写明无法运行的原因和未验证范围。 / I ranmake check, or documented why it could not run and what remains unverified.Summary by CodeRabbit
新功能
POST /v1/embeddings创建文本向量。改进