Fix DashScope rerank path and optimize batch embedding#566
Fix DashScope rerank path and optimize batch embedding#566greatyue6-byte wants to merge 5 commits intoCortexReach:masterfrom
Conversation
AliceLJY
left a comment
There was a problem hiding this comment.
代码审查通过,变更逻辑清晰,结构合理。
审查了以下内容:
-
DashScope rerank 路径修复(P0):新增
dashscope-rerank.tsprovider,endpoint 路由正确(/services/rerank/text-rerank/text-rerank),qwen3-vl-rerank的请求体格式与通用 rerank model 区分处理,fetchDashScopeRerank按 index 排序保证对齐——逻辑正确。 -
Batch embedding index 对齐修复(P1):
embedMany现在使用item.index而非数组位置来映射结果,当 API 返回顺序与输入不一致时不会错位。fallback 到validIndices[indexOf]保证向后兼容。 -
DashScope batch embedding 优化(P2):
embedBatchQuery/embedBatchPassage走embedMany单次 API 调用,不再逐条 Promise.all,减少请求数。dashscope-embedding.ts的 multimodal embedding 格式(contents数组 +enable_fusion)与 DashScope 文档一致。 -
其他:provider 类型扩展、CLI 模式跳过 service 注册、darwin-x64 LanceDB fallback 错误提示、config schema 同步——均无问题。
小建议(非阻塞):isDashScopeProvider() 每次调用都重新执行 detectEmbeddingProviderProfile(),结果对同一 Embedder 实例是不变的,可以在构造函数中缓存。不影响正确性,仅供后续优化参考。
|
The underlying bugs are real: wrong DashScope rerank endpoint and silent Must fix
Nice to have
Fix the blockers above and this will be in good shape. |
rwmjhb
left a comment
There was a problem hiding this comment.
感谢这次修复——DashScope rerank 路径错误和 batch embedding 位置错乱都是真实 bug。有几个阻塞项:
Must Fix
EF1 — TypeScript build 失败,阻塞 CI merge
build_status=fail,怀疑根因是 src/embedder.ts 新增的 any 类型参数在 strict mode 下触发编译错误。所有运行时测试通过,说明是 tsc 类型检查失败而非逻辑错误。
F2(核心 bug)— P1 fix 在输入含空字符串时仍错位(src/embedder.ts:1015-1022)
当前修复用 item.index(在 validTexts 中的位置)写入 results,但正确位置应该是 validIndices[item.index](在原始 texts 中的位置)。例如:
texts = ['', 'hello', 'world'] → validIndices = [1, 2]
DashScope 返回 index:0 for 'hello'
当前代码:results[0] = embedding ✗
正确应为:results[validIndices[0]] = results[1] = embedding ✓
现有测试 ['first', 'second'] 两个都非空,validIndices=[0,1] 与位置重合,无法检出此 bug。请在测试中加入空字符串用例验证。
EF4 — 新增对齐测试未覆盖其声称修复的空字符串场景
测试用 ['first', 'second'],两个都非空,测试能通过但不验证任何对齐逻辑(见 F2)。
MR1 — logReg() 和 isCliMode() 在 diff 中无定义
index.ts 引入这两个函数但 diff 中未见定义。如果是已有内部工具函数,请确认它们在 PR 修改后仍可访问;如果是新增的,需要包含定义。
MR3 — batch embedding 的 abort/timeout 管道不完整
AbortController 被创建但未传递给底层 fetch,timeout 触发后请求仍在进行。
Nice to Have
- F6 (
src/retriever.ts:369-382):buildRerankRequest中的dashscopecase 是死代码——DashScope 在 line 1213 已经走独立的fetchDashScopeRerank分支提前 return,不会进入buildRerankRequest。建议移除或加注释说明。 - F7 (
openclaw.plugin.json:359): Schema 描述写的是gte-rerank-v2,但代码默认用qwen3-vl-rerank,两者请求格式不同,容易误导用户配置。 - EF2:
embedWithDashScopeRetry的payload: any参数可能是 EF1 build failure 的根因,建议改为具体类型。
方向正确,修复 build error 和 F2 对齐 bug 后可以合并。
Summary
indexdashscope-embedding.tsno longer contains the old rerank residueIncluded commits
Validation
node test/retriever-rerank-regression.mjsnode test/embedder-batch-index-alignment.test.mjsnode test/smart-memory-lifecycle.mjsNotes
dashscope-embedding.tscleanup item was re-checked and required no code change because the residue was already gone