Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add corrections following maintainer suggestions #4

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions libs/langchain/langchain/vectorstores/sqlitevss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down