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:
parent
228bc30e89
commit
402b157f15
1 changed files with 3 additions and 0 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue