mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-01 12:52:11 +03:00
* fix(rerank): add voyage format adapter for request/response translation (#7809) Voyage AI is not Cohere-compatible: - Uses top_k instead of top_n (top_n is rejected with 400) - Rejects empty-string documents (Cohere tolerates them) - Returns {data:[{relevance_score,index}]} not {results:[…]} Add format: 'voyage' to the registry entry and implement both transformRequestForProvider and transformResponseFromProvider adapters: Request: map top_n→top_k, filter empty/whitespace-only documents Response: map data[]→results[], remap filtered indices back to caller's original document positions, sort by score desc, honor top_n Follows the existing nvidia/deepinfra adapter pattern. 13 new tests, all existing rerank tests still pass. * fix(rerank): preserve whitespace-only documents in voyage adapter Voyage API accepts whitespace-only documents (probed live). Changed filter from text.trim() to text !== '' so only exact empty strings are dropped. Updated both request adapter and response index-map reconstruction, plus tests pinning the behavior. * fix(rerank): force return_documents:false upstream + isolate voyage-7809 test DB Voyage echoes documents as plain strings (not Cohere {text}); we never rely on that echo (document text is always synthesized locally from the caller's originals), so force return_documents:false on the upstream request to make that explicit and never trust an echoed document. Folds in the corresponding delta from the now-closed #7811. Also isolates tests/unit/rerank-voyage-7809.test.ts's SQLite usage behind a temp DATA_DIR + core.resetDbInstance() in test.after, since importing open-sse/handlers/rerank.ts pulls in @/lib/usageDb (migrations run on import) — the test must never touch the shared/real DB. Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> --------- Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com> Co-authored-by: Diego Rodrigues de Sa e Souza <diegosouza.pw@gmail.com>