Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ShorthillsAI authored Nov 20, 2023
2 parents 997dece + 10418ab commit d450038
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/langchain/langchain/vectorstores/deeplake.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def _search(
distance_metric=distance_metric,
filter=filter,
exec_option=exec_option,
return_tensors=["embedding", "metadata", "text", "id"],
return_tensors=["embedding", "metadata", "text", self._id_tensor_name],
deep_memory=deep_memory,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,25 @@ def test_add_texts(deeplake_datastore: DeepLake) -> None:
texts=texts,
metada=metadatas,
)


def test_ids_backwards_compatibility() -> None:
"""Test that ids are backwards compatible."""
db = DeepLake(
dataset_path="mem://test_path",
embedding_function=FakeEmbeddings(),
tensor_params=[
{"name": "ids", "htype": "text"},
{"name": "text", "htype": "text"},
{"name": "embedding", "htype": "embedding"},
{"name": "metadata", "htype": "json"},
],
)
db.vectorstore.add(
ids=["1", "2", "3"],
text=["foo", "bar", "baz"],
embedding=FakeEmbeddings().embed_documents(["foo", "bar", "baz"]),
metadata=[{"page": str(i)} for i in range(3)],
)
output = db.similarity_search("foo", k=1)
assert len(output) == 1

0 comments on commit d450038

Please sign in to comment.