Skip to content

Commit b554b3a

Browse files
committed
address issue for mmr calculation
1 parent 8883129 commit b554b3a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

langchain_postgres/_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ def cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray:
3030

3131
X = np.array(X, dtype=np.float32)
3232
Y = np.array(Y, dtype=np.float32)
33-
Z = 1 - simd.cdist(X, Y, metric="cosine")
34-
if isinstance(Z, float):
35-
return np.array([Z])
36-
return np.array(Z)
33+
Z = 1 - np.array(simd.cdist(X, Y, metric="cosine"))
34+
return Z
3735
except ImportError:
3836
logger.debug(
3937
"Unable to import simsimd, defaulting to NumPy implementation. If you want "

0 commit comments

Comments
 (0)