fix: handle case where distance is 0 by setting score to infinity

This commit is contained in:
Ibrahim Haroon 2025-06-03 19:20:31 -04:00
parent ef885d2147
commit fea01c5a25

View file

@ -112,7 +112,7 @@ class FaissIndex(EmbeddingIndex):
if i < 0:
continue
chunks.append(self.chunk_by_index[int(i)])
scores.append(1.0 / float(d))
scores.append(1.0 / float(d) if d != 0 else float("inf"))
return QueryChunksResponse(chunks=chunks, scores=scores)