The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
Fix normalizing the cosine distance in Qdrant (#12934)
Kacper Łukawski621419f71e19
diff --git a/libs/langchain/langchain/vectorstores/qdrant.py b/libs/langchain/langchain/vectorstores/qdrant.pyindex b364c99153..b85edabcdc 100644--- a/libs/langchain/langchain/vectorstores/qdrant.py+++ b/libs/langchain/langchain/vectorstores/qdrant.py@@ -1837,6 +1837,11 @@ class Qdrant(VectorStore):)return qdrant+ @staticmethod+ def _cosine_relevance_score_fn(distance: float) -> float:+ """Normalize the distance to a score on a scale [0, 1]."""+ return (distance + 1.0) / 2.0+def _select_relevance_score_fn(self) -> Callable[[float], float]:"""The 'correct' relevance function