Fix Voyage AI rerank response parsing#6543
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the VoyageAIRerank class to include top_k in the API request payload, support both the new data and legacy results response formats from the Voyage API, and use slice instead of splice to return the final results. Additionally, a new test suite has been added to verify these behaviors. The review feedback recommends adding defensive checks to safely parse the API response, including verifying that the results format is an array and ensuring that the documents exist at the returned indices before modifying their metadata.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Summary
data.resultsresponse shape.top_kand add regression coverage for both response shapes.Fixes #6492
Tests
pnpm --filter flowise-components exec jest nodes/retrievers/VoyageAIRetriever/VoyageAIRerank.test.ts --runInBandpnpm --filter flowise-components exec eslint nodes/retrievers/VoyageAIRetriever/VoyageAIRerank.ts nodes/retrievers/VoyageAIRetriever/VoyageAIRerank.test.ts --ext ts --max-warnings 0pnpm --filter flowise-components exec tsc --noEmit --pretty false