Skip to content
Snippets Groups Projects
Commit 7bace207 authored by timothycarambat's avatar timothycarambat
Browse files

Improve VoyageAI error responses and textChunk handler

resolves #1491
parent 3ef009de
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,10 @@ class VoyageAiEmbedder {
Array.isArray(textInput) ? textInput : [textInput],
{ modelName: this.model }
);
return result || [];
// If given an array return the native Array[Array] format since that should be the outcome.
// But if given a single string, we need to flatten it so that we have a 1D array.
return (Array.isArray(textInput) ? result : result.flat()) || [];
}
async embedChunks(textChunks = []) {
......@@ -50,6 +53,12 @@ class VoyageAiEmbedder {
return embeddings;
} catch (error) {
console.error("Voyage AI Failed to embed:", error);
if (
error.message.includes(
"Cannot read properties of undefined (reading '0')"
)
)
throw new Error("Voyage AI failed to embed: Rate limit reached");
throw error;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment