Skip to content

fix(cloudflare): 保留 embeddings 响应数据与 usage - #175

Merged
woncc merged 1 commit into
mainfrom
cursor/upstream-issue-165-b08ee86fe-20261105
Nov 5, 2026
Merged

woncc merged 1 commit into
mainfrom
cursor/upstream-issue-165-b08ee86fe-20261105

Conversation

@woncc

@woncc woncc commented Nov 5, 2026

Copy link
Copy Markdown

🔗 关联任务 / Related Issue

Closes #165

上游:b08ee86fe2a899dcf9060d8cde7858c93c2b770c(QuantumNous#8041)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)

📝 变更描述 / Description

Cloudflare embeddings 原先进入聊天响应转换,导致向量数据丢失并覆盖上游 usage。改用现有 OpenAI handler,保留单条、批量、base64 embedding 和额外字段;缺失 usage 时沿用输入估算。

仅移植指定上游的两个文件,patch-id 与上游一致;保留 fork 既有兼容性用例。AI 辅助移植与验证,人工独立审查待完成。

📸 运行证明 / Proof of Work

仓库根目录执行:

GOMAXPROCS=2 RAYON_NUM_THREADS=2 GOWORK=off go test -p=2 ./controller/ ./relay/channel/cloudflare/ -run '^TestCloudflareEmbeddingResponseCompatibility$' -count=1 -v

仅加入回归测试、尚未修改 adaptor 时,4 个子用例全部失败,复现数据丢失及 usage 不匹配。

修复后执行:

GOMAXPROCS=2 RAYON_NUM_THREADS=2 GOWORK=off go test -p=2 ./controller/ ./relay/channel/cloudflare/ -run '^(TestCloudflareEmbeddingResponseCompatibility|TestChannelTestOpenAIChatCompatibility|TestOpenAIChatSamplingCompatibility|TestOpenAIChatTokenLimitCompatibility|TestDirectOpenAIResponsesKeepsExistingParameters)$' -count=1 -v
git diff --check

结果:controller 所选测试全部通过;cloudflare 包编译通过(无独立测试);差异检查通过。未运行完整套件或真实 Cloudflare 网络请求;不涉及数据库行为、独立模块或认证修改。

✅ 提交前检查项 / Checklist

@woncc
woncc merged commit d5ced20 into main Nov 5, 2026
@woncc
woncc deleted the cursor/upstream-issue-165-b08ee86fe-20261105 branch December 2, 2026 15:32
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.

[上游/现在能解] b08ee86fe fix(cloudflare): preserve embedding response data (#8041)

1 participant