Skip to content

Commit f01d85f

Browse files
Update demos/embeddings/search.js
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
1 parent 44e1ccd commit f01d85f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

demos/embeddings/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class SemanticSearch {
5656

5757
cosineSimilarity(vecA, vecB) {
5858
if (vecA.length !== vecB.length) {
59-
throw new Error('Vectors must have the same length');
59+
console.warn('cosineSimilarity: Vectors must have the same length. Skipping invalid result.');
60+
return null;
6061
}
6162

6263
// Validate that all elements are finite numbers

0 commit comments

Comments
 (0)