From 566439631b7c2b3c5d1bd448325a05bfc2709d82 Mon Sep 17 00:00:00 2001 From: Philippe Oger Date: Fri, 1 Sep 2023 11:46:21 +0200 Subject: [PATCH] Add corrections following maintainer suggestions --- libs/langchain/langchain/vectorstores/sqlitevss.py | 7 +++---- .../tests/integration_tests/vectorstores/test_sqlitevss.py | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/langchain/langchain/vectorstores/sqlitevss.py b/libs/langchain/langchain/vectorstores/sqlitevss.py index 5234ba8c2a330..d311ffafcb980 100644 --- a/libs/langchain/langchain/vectorstores/sqlitevss.py +++ b/libs/langchain/langchain/vectorstores/sqlitevss.py @@ -42,8 +42,8 @@ def __init__( import sqlite_vss # noqa # pylint: disable=unused-import except ImportError: raise ImportError( - "Could not import sqlite_vss python package. " - "Please install it with `pip install sqlite_vss`." + "Could not import sqlite-vss python package. " + "Please install it with `pip install sqlite-vss`." ) if not connection: @@ -151,8 +151,7 @@ def similarity_search_with_score_by_vector( for row in results: metadata = json.loads(row["metadata"]) or {} doc = Document(page_content=row["text"], metadata=metadata) - score = self._euclidean_relevance_score_fn(row["distance"]) - documents.append((doc, score)) + documents.append((doc, row["distance"])) return documents diff --git a/libs/langchain/tests/integration_tests/vectorstores/test_sqlitevss.py b/libs/langchain/tests/integration_tests/vectorstores/test_sqlitevss.py index ce0a304a9ad79..0896706d89247 100644 --- a/libs/langchain/tests/integration_tests/vectorstores/test_sqlitevss.py +++ b/libs/langchain/tests/integration_tests/vectorstores/test_sqlitevss.py @@ -38,13 +38,13 @@ def test_sqlitevss_with_score() -> None: docsearch = _sqlite_vss_from_texts(metadatas=metadatas) output = docsearch.similarity_search_with_score("foo", k=3) docs = [o[0] for o in output] - scores = [o[1] for o in output] + distances = [o[1] for o in output] assert docs == [ Document(page_content="foo", metadata={"page": 0}), Document(page_content="bar", metadata={"page": 1}), Document(page_content="baz", metadata={"page": 2}), ] - assert scores[0] > scores[1] > scores[2] + assert distances[0] < distances[1] < distances[2] @pytest.mark.requires("sqlite-vss")