Skip to content

Commit cc08f2b

Browse files
committed
array to list
1 parent dfbf4a6 commit cc08f2b

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

README.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,11 @@ retriever.get_relevant_documents("What are some movies about dinosaurs")
264264
```
265265

266266
Output:
267-
Output:
268-
269267
```
270-
[Document(metadata={'genre': 'science fiction', 'rating': array(7.7), 'year': array(1993)}, page_content='A bunch of scientists bring back dinosaurs and mayhem breaks loose'),
271-
Document(metadata={'genre': 'science fiction', 'rating': array(7.7), 'year': array(1993)}, page_content='A bunch of scientists bring back dinosaurs and mayhem breaks loose'),
272-
Document(metadata={'genre': 'animated', 'year': array(1995)}, page_content='Toys come alive and have a blast doing so'),
273-
Document(metadata={'genre': 'animated', 'year': array(1995)}, page_content='Toys come alive and have a blast doing so')]
268+
[Document(metadata={'genre': 'science fiction', 'rating': 7.7, 'year': 1993}, page_content='A bunch of scientists bring back dinosaurs and mayhem breaks loose'),
269+
Document(metadata={'genre': 'science fiction', 'rating': 7.7, 'year': 1993}, page_content='A bunch of scientists bring back dinosaurs and mayhem breaks loose'),
270+
Document(metadata={'genre': 'animated', 'year': 1995}, page_content='Toys come alive and have a blast doing so'),
271+
Document(metadata={'genre': 'animated', 'year': 1995}, page_content='Toys come alive and have a blast doing so')]
274272
```
275273

276274
Now we can run a query to find movies that are above a certain ranking:
@@ -282,12 +280,11 @@ retriever.get_relevant_documents("I want to watch a movie rated higher than 8.5"
282280

283281
Output:
284282
```
285-
[Document(metadata={'director': 'Satoshi Kon', 'rating': array(8.6), 'year': array(2006)}, page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea'),
286-
Document(metadata={'director': 'Andrei Tarkovsky', 'genre': 'science fiction', 'rating': array(9.9), 'year': array(1979)}, page_content='Three men walk into the Zone, three men walk out of the Zone'),
287-
Document(metadata={'director': 'Satoshi Kon', 'rating': array(8.6), 'year': array(2006)}, page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea'),
288-
Document(metadata={'director': 'Andrei Tarkovsky', 'genre': 'science fiction', 'rating': array(9.9), 'year': array(1979)}, page_content='Three men walk into the Zone, three men walk out of the Zone'), Document(metadata={'director': 'Satoshi Kon', 'rating': array(8.6), 'year': array(2006)}, page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea'), Document(metadata={'director': 'Andrei Tarkovsky', 'genre': 'science fiction', 'rating': array(9.9), 'year': array(1979)}, page_content='Three men walk into the Zone, three men walk out of the Zone')]
283+
[Document(metadata={'director': 'Satoshi Kon', 'rating': 8.6, 'year': 2006}, page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea'),
284+
Document(metadata={'director': 'Andrei Tarkovsky', 'genre': 'science fiction', 'rating': 9.9, 'year': 1979}, page_content='Three men walk into the Zone, three men walk out of the Zone'),
285+
Document(metadata={'director': 'Satoshi Kon', 'rating': 8.6, 'year': 2006}, page_content='A psychologist / detective gets lost in a series of dreams within dreams within dreams and Inception reused the idea'),
286+
Document(metadata={'director': 'Andrei Tarkovsky', 'genre': 'science fiction', 'rating': 9.9, 'year': 1979}, page_content='Three men walk into the Zone, three men walk out of the Zone')]
289287
```
290288

291289

292290
Congrats! You just used the Deep Lake Vector Store in LangChain to create a Q&A App! 🎉
293-

langchain_deeplake/vectorstores.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def get_by_ids(self, ids: List[str], **kwargs: Any) -> List[Document]:
158158
docs = results["documents"][:]
159159
metadatas = results["metadata"][:]
160160
return [
161-
Document(page_content=docs[i], metadata=metadatas[i].to_dict())
161+
Document(page_content=docs[i], metadata=metadatas[i].to_dict(convert_numpy_to_list=True))
162162
for i in range(len(results))
163163
]
164164

@@ -250,7 +250,7 @@ def similarity_search_with_score(
250250
for i in range(len(results)):
251251
doc = Document(
252252
page_content=docs_with_scores_columnar["documents"][i],
253-
metadata=docs_with_scores_columnar["metadata"][i].to_dict(),
253+
metadata=docs_with_scores_columnar["metadata"][i].to_dict(convert_numpy_to_list=True),
254254
)
255255
score = docs_with_scores_columnar["score"][i] if has_score else None
256256
docs_with_scores.append((doc, score))

pyproject.toml

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@ build-backend = "poetry.core.masonry.api"
66
name = "langchain-deeplake"
77
version = "0.1.0"
88
description = "An integration package connecting Deeplake and LangChain"
9-
authors = []
109
readme = "README.md"
10+
authors = ["activeloop.ai <[email protected]>"]
1111
repository = "https://github.com/activeloopai/langchain-deeplake"
1212
license = "MIT"
1313

1414
[tool.mypy]
1515
disallow_untyped_defs = "True"
1616

17-
[tool.poetry.urls]
18-
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/partners/deeplake"
19-
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22deeplake%3D%3D0%22&expanded=true"
20-
2117
[tool.poetry.dependencies]
22-
python = ">=3.9,<4.0"
23-
langchain-core = "^0.3.15"
18+
python = ">=3.8,<4.0"
19+
langchain-core = ">=0.2.43"
2420
deeplake = ">=4.1"
2521

2622
[tool.ruff.lint]

0 commit comments

Comments
 (0)