Skip to content

Commit 7759afd

Browse files
author
Fangrui Liu
committed
fixed unittest and lint
1 parent fc92205 commit 7759afd

File tree

6 files changed

+186
-380
lines changed

6 files changed

+186
-380
lines changed

docs/modules/indexes/retrievers/examples/qdrant_self_query.ipynb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"id": "13afcae7",
67
"metadata": {},
@@ -13,12 +14,13 @@
1314
]
1415
},
1516
{
17+
"attachments": {},
1618
"cell_type": "markdown",
1719
"id": "68e75fb9",
1820
"metadata": {},
1921
"source": [
2022
"## Creating a Qdrant vectorstore\n",
21-
"First we'll want to create a Chroma VectorStore and seed it with some data. We've created a small demo set of documents that contain summaries of movies.\n",
23+
"First we'll want to create a Qdrant VectorStore and seed it with some data. We've created a small demo set of documents that contain summaries of movies.\n",
2224
"\n",
2325
"NOTE: The self-query retriever requires you to have `lark` installed (`pip install lark`). We also need the `qdrant-client` package."
2426
]
@@ -36,6 +38,7 @@
3638
]
3739
},
3840
{
41+
"attachments": {},
3942
"cell_type": "markdown",
4043
"id": "83811610-7df3-4ede-b268-68a6a83ba9e2",
4144
"metadata": {},
@@ -100,6 +103,7 @@
100103
]
101104
},
102105
{
106+
"attachments": {},
103107
"cell_type": "markdown",
104108
"id": "5ecaab6d",
105109
"metadata": {},
@@ -149,6 +153,7 @@
149153
]
150154
},
151155
{
156+
"attachments": {},
152157
"cell_type": "markdown",
153158
"id": "ea9df8d4",
154159
"metadata": {},
@@ -309,6 +314,7 @@
309314
]
310315
},
311316
{
317+
"attachments": {},
312318
"cell_type": "markdown",
313319
"id": "39bd1de1-b9fe-4a98-89da-58d8a7a6ae51",
314320
"metadata": {},

langchain/retrievers/self_query/myscale.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212
)
1313

1414

15-
def DEFAULT_COMPOSER(op: Union[Comparator, Operator]) -> Callable:
15+
def DEFAULT_COMPOSER(op_name: str) -> Callable:
1616
def f(*args: Any) -> str:
17-
args = map(str, args)
18-
return f" {op} ".join(args)
17+
args: Tuple[str] = map(str, args)
18+
return f" {op_name} ".join(args)
1919
return f
2020

2121

22-
def FUNCTION_COMPOSER(op: Union[Comparator, Operator]) -> Callable:
22+
def FUNCTION_COMPOSER(op_name: str) -> Callable:
2323
def f(*args: Any) -> str:
24-
args = map(str, args)
25-
return f"{op}({','.join(args)})"
26-
24+
args: Tuple[str] = map(str, args)
25+
return f"{op_name}({','.join(args)})"
2726
return f
2827

2928

@@ -50,8 +49,8 @@ class MyScaleTranslator(Visitor):
5049
Comparator.EQ: DEFAULT_COMPOSER("="),
5150
Comparator.GT: DEFAULT_COMPOSER(">"),
5251
Comparator.GTE: DEFAULT_COMPOSER(">="),
53-
Comparator.LT: DEFAULT_COMPOSER("<="),
54-
Comparator.LTE: DEFAULT_COMPOSER("<"),
52+
Comparator.LT: DEFAULT_COMPOSER("<"),
53+
Comparator.LTE: DEFAULT_COMPOSER("<="),
5554
Comparator.CONTAIN: FUNCTION_COMPOSER("has"),
5655
Comparator.LIKE: DEFAULT_COMPOSER("ILIKE"),
5756
}

langchain/vectorstores/mongodb_atlas.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
Iterable,
1010
List,
1111
Optional,
12+
Sequence,
13+
Mapping,
1214
Tuple,
1315
TypeVar,
1416
Union,
@@ -129,7 +131,7 @@ def _insert_texts(self, texts: List[str], metadatas: List[Dict[str, Any]]) -> Li
129131
return []
130132
# Embed and create the documents
131133
embeddings = self._embedding.embed_documents(texts)
132-
to_insert = [
134+
to_insert: List[MongoDBDocumentType] = [
133135
{self._text_key: t, self._embedding_key: embedding, **m}
134136
for t, m, embedding in zip(texts, metadatas, embeddings)
135137
]
@@ -172,7 +174,7 @@ def similarity_search_with_score(
172174
}
173175
if pre_filter:
174176
knn_beta["filter"] = pre_filter
175-
pipeline = [
177+
pipeline: Sequence[Mapping[str, Any]] = [
176178
{
177179
"$search": {
178180
"index": self._index_name,

0 commit comments

Comments
 (0)