Fix error after sending an empty value to the Voyage reranker API (#1902)

* Return early if query is empty

* Check if chunks are empty
This commit is contained in:
George 2024-08-03 00:23:04 +01:00 • committed by GitHub
parent 228bc30e89
commit 402b157f15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,6 +12,9 @@ export class VoyageReranker implements Reranker {
) {}
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
if (!query || chunks.length === 0) {
return [];
}
const resp = await fetch("https://api.voyageai.com/v1/rerank", {
method: "POST",
headers: {