langchain-postgres 0.0.16__tar.gz → 0.0.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.github/workflows/_lint.yml +3 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.github/workflows/_release.yml +3 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.github/workflows/_test.yml +3 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.github/workflows/ci.yml +3 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/DEVELOPMENT.md +2 -1
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/PKG-INFO +8 -5
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/README.md +4 -1
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/pg_vectorstore.ipynb +29 -5
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/pg_vectorstore_how_to.ipynb +88 -13
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/async_vectorstore.py +294 -30
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/vectorstores.py +96 -2
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/pyproject.toml +12 -4
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/fixtures/metadata_filtering_data.py +8 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v1/test_vectorstore.py +4 -5
- langchain_postgres-0.0.18/tests/unit_tests/v2/test_async_pg_vectorstore.py +678 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_async_pg_vectorstore_search.py +80 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_pg_vectorstore.py +78 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_pg_vectorstore_search.py +113 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/uv.lock +657 -374
- langchain_postgres-0.0.16/tests/unit_tests/v2/test_async_pg_vectorstore.py +0 -338
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.github/actions/uv_setup/action.yml +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/.gitignore +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/CONTRIBUTING.md +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/LICENSE +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/Makefile +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/docker-compose.yml +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/docs/v2_design_overview.md +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/migrate_pgvector_to_pgvectorstore.ipynb +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/migrate_pgvector_to_pgvectorstore.md +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/vectorstore.ipynb +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/_utils.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/chat_message_histories.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/py.typed +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/translator.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/utils/pgvector_migrator.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/engine.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/hybrid_search_config.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/v2/indexes.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/langchain_postgres/vectorstores.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/security.md +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/fake_embeddings.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/fixtures/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/fixtures/filtering_test_cases.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/query_constructors/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/query_constructors/test_pgvector.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/test_imports.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v1/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v1/test_chat_histories.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v1/test_vectorstore_standard_tests.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/__init__.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_async_pg_vectorstore_from_methods.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_async_pg_vectorstore_index.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_engine.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_hybrid_search_config.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_indexes.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_pg_vectorstore_from_methods.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_pg_vectorstore_index.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/unit_tests/v2/test_pg_vectorstore_standard_suite.py +0 -0
- {langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/tests/utils.py +0 -0
|
@@ -13,6 +13,9 @@ on:
|
|
|
13
13
|
# There's no point in testing an outdated version of the code. GitHub only allows
|
|
14
14
|
# a limited number of job runners to be active at the same time, so it's better to cancel
|
|
15
15
|
# pointless jobs early so that more useful jobs can run sooner.
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
16
19
|
concurrency:
|
|
17
20
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
18
21
|
cancel-in-progress: true
|
|
@@ -13,7 +13,7 @@ source .venv/bin/activate
|
|
|
13
13
|
|
|
14
14
|
Install package in editable mode.
|
|
15
15
|
```shell
|
|
16
|
-
|
|
16
|
+
uv sync --group test
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Start PostgreSQL/PGVector.
|
|
@@ -28,5 +28,6 @@ docker run --rm -it --name pgvector-container \
|
|
|
28
28
|
|
|
29
29
|
Invoke test cases.
|
|
30
30
|
```shell
|
|
31
|
+
export POSTGRES_PORT=6024
|
|
31
32
|
pytest -vvv
|
|
32
33
|
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: langchain-postgres
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.18
|
|
4
4
|
Summary: An integration package connecting Postgres and LangChain
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
License-File: LICENSE
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
8
|
Requires-Dist: asyncpg>=0.30.0
|
|
9
|
-
Requires-Dist: langchain-core<2.0,>=
|
|
9
|
+
Requires-Dist: langchain-core<2.0,>=1.2.11
|
|
10
10
|
Requires-Dist: numpy<3,>=1.21
|
|
11
11
|
Requires-Dist: pgvector<0.4,>=0.2.5
|
|
12
12
|
Requires-Dist: psycopg-pool<4,>=3.2.1
|
|
@@ -51,6 +51,9 @@ pip install -U langchain-postgres
|
|
|
51
51
|
* [Quickstart](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore.ipynb)
|
|
52
52
|
* [How-to](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore_how_to.ipynb)
|
|
53
53
|
|
|
54
|
+
> [!TIP]
|
|
55
|
+
> For developing, debugging, and deploying AI agents and LLM applications, see [LangSmith](https://docs.langchain.com/langsmith/home).
|
|
56
|
+
|
|
54
57
|
### Example
|
|
55
58
|
|
|
56
59
|
```python
|
|
@@ -59,7 +62,7 @@ from langchain_core.embeddings import DeterministicFakeEmbedding
|
|
|
59
62
|
from langchain_postgres import PGEngine, PGVectorStore
|
|
60
63
|
|
|
61
64
|
# Replace the connection string with your own Postgres connection string
|
|
62
|
-
CONNECTION_STRING = "postgresql+
|
|
65
|
+
CONNECTION_STRING = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain"
|
|
63
66
|
engine = PGEngine.from_connection_string(url=CONNECTION_STRING)
|
|
64
67
|
|
|
65
68
|
# Replace the vector size with your own vector size
|
|
@@ -35,6 +35,9 @@ pip install -U langchain-postgres
|
|
|
35
35
|
* [Quickstart](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore.ipynb)
|
|
36
36
|
* [How-to](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/pg_vectorstore_how_to.ipynb)
|
|
37
37
|
|
|
38
|
+
> [!TIP]
|
|
39
|
+
> For developing, debugging, and deploying AI agents and LLM applications, see [LangSmith](https://docs.langchain.com/langsmith/home).
|
|
40
|
+
|
|
38
41
|
### Example
|
|
39
42
|
|
|
40
43
|
```python
|
|
@@ -43,7 +46,7 @@ from langchain_core.embeddings import DeterministicFakeEmbedding
|
|
|
43
46
|
from langchain_postgres import PGEngine, PGVectorStore
|
|
44
47
|
|
|
45
48
|
# Replace the connection string with your own Postgres connection string
|
|
46
|
-
CONNECTION_STRING = "postgresql+
|
|
49
|
+
CONNECTION_STRING = "postgresql+psycopg://langchain:langchain@localhost:6024/langchain"
|
|
47
50
|
engine = PGEngine.from_connection_string(url=CONNECTION_STRING)
|
|
48
51
|
|
|
49
52
|
# Replace the vector size with your own vector size
|
|
@@ -258,22 +258,22 @@
|
|
|
258
258
|
"\n",
|
|
259
259
|
"docs = [\n",
|
|
260
260
|
" Document(\n",
|
|
261
|
-
" id=uuid.uuid4(),\n",
|
|
261
|
+
" id=str(uuid.uuid4()),\n",
|
|
262
262
|
" page_content=\"there are cats in the pond\",\n",
|
|
263
263
|
" metadata={\"likes\": 1, \"location\": \"pond\", \"topic\": \"animals\"},\n",
|
|
264
264
|
" ),\n",
|
|
265
265
|
" Document(\n",
|
|
266
|
-
" id=uuid.uuid4(),\n",
|
|
266
|
+
" id=str(uuid.uuid4()),\n",
|
|
267
267
|
" page_content=\"ducks are also found in the pond\",\n",
|
|
268
268
|
" metadata={\"likes\": 30, \"location\": \"pond\", \"topic\": \"animals\"},\n",
|
|
269
269
|
" ),\n",
|
|
270
270
|
" Document(\n",
|
|
271
|
-
" id=uuid.uuid4(),\n",
|
|
271
|
+
" id=str(uuid.uuid4()),\n",
|
|
272
272
|
" page_content=\"fresh apples are available at the market\",\n",
|
|
273
273
|
" metadata={\"likes\": 20, \"location\": \"market\", \"topic\": \"food\"},\n",
|
|
274
274
|
" ),\n",
|
|
275
275
|
" Document(\n",
|
|
276
|
-
" id=uuid.uuid4(),\n",
|
|
276
|
+
" id=str(uuid.uuid4()),\n",
|
|
277
277
|
" page_content=\"the market also sells fresh oranges\",\n",
|
|
278
278
|
" metadata={\"likes\": 5, \"location\": \"market\", \"topic\": \"food\"},\n",
|
|
279
279
|
" ),\n",
|
|
@@ -283,6 +283,30 @@
|
|
|
283
283
|
"await vectorstore.aadd_documents(documents=docs)"
|
|
284
284
|
]
|
|
285
285
|
},
|
|
286
|
+
{
|
|
287
|
+
"cell_type": "markdown",
|
|
288
|
+
"metadata": {},
|
|
289
|
+
"source": [
|
|
290
|
+
"## Get collection\n",
|
|
291
|
+
"\n",
|
|
292
|
+
"Get collection from the vectorstore using filters and parameters."
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"cell_type": "code",
|
|
297
|
+
"execution_count": null,
|
|
298
|
+
"metadata": {},
|
|
299
|
+
"outputs": [],
|
|
300
|
+
"source": [
|
|
301
|
+
"documents_with_apple = await vectorstore.aget(\n",
|
|
302
|
+
" where_document={\"$ilike\": \"%apple%\"}, include=\"documents\"\n",
|
|
303
|
+
")\n",
|
|
304
|
+
"paginated_ids = await vectorstore.aget(limit=3, offset=3)\n",
|
|
305
|
+
"\n",
|
|
306
|
+
"print(documents_with_apple[\"documents\"])\n",
|
|
307
|
+
"print(paginated_ids[\"ids\"])"
|
|
308
|
+
]
|
|
309
|
+
},
|
|
286
310
|
{
|
|
287
311
|
"cell_type": "markdown",
|
|
288
312
|
"metadata": {},
|
|
@@ -359,7 +383,7 @@
|
|
|
359
383
|
"cell_type": "markdown",
|
|
360
384
|
"metadata": {},
|
|
361
385
|
"source": [
|
|
362
|
-
"To
|
|
386
|
+
"To achieve performant search with filters, it is crucial to declare the columns you want to filter on within the `metadata_columns` when creating the table, as filtering directly on these columns is far more efficient than attempting to filter on fields within a metadata JSON column. The vectorstore supports a set of filters that can be applied against the metadata fields of the documents.\n",
|
|
363
387
|
"\n",
|
|
364
388
|
"`PGVectorStore` currently supports the following operators.\n",
|
|
365
389
|
"\n",
|
{langchain_postgres-0.0.16 → langchain_postgres-0.0.18}/examples/pg_vectorstore_how_to.ipynb
RENAMED
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
"cell_type": "code",
|
|
76
|
-
"execution_count":
|
|
76
|
+
"execution_count": null,
|
|
77
77
|
"id": "irl7eMFnSPZr",
|
|
78
78
|
"metadata": {
|
|
79
79
|
"id": "irl7eMFnSPZr"
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"cell_type": "code",
|
|
120
|
-
"execution_count":
|
|
120
|
+
"execution_count": null,
|
|
121
121
|
"metadata": {},
|
|
122
122
|
"outputs": [],
|
|
123
123
|
"source": [
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
},
|
|
132
132
|
{
|
|
133
133
|
"cell_type": "code",
|
|
134
|
-
"execution_count":
|
|
134
|
+
"execution_count": null,
|
|
135
135
|
"metadata": {},
|
|
136
136
|
"outputs": [],
|
|
137
137
|
"source": [
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
153
|
"cell_type": "code",
|
|
154
|
-
"execution_count":
|
|
154
|
+
"execution_count": null,
|
|
155
155
|
"metadata": {},
|
|
156
156
|
"outputs": [],
|
|
157
157
|
"source": [
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
},
|
|
179
179
|
{
|
|
180
180
|
"cell_type": "code",
|
|
181
|
-
"execution_count":
|
|
181
|
+
"execution_count": null,
|
|
182
182
|
"metadata": {
|
|
183
183
|
"id": "avlyHEMn6gzU"
|
|
184
184
|
},
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
"cell_type": "code",
|
|
222
|
-
"execution_count":
|
|
222
|
+
"execution_count": null,
|
|
223
223
|
"metadata": {
|
|
224
224
|
"colab": {
|
|
225
225
|
"base_uri": "https://localhost:8080/"
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
249
|
"cell_type": "code",
|
|
250
|
-
"execution_count":
|
|
250
|
+
"execution_count": null,
|
|
251
251
|
"metadata": {
|
|
252
252
|
"id": "z-AZyzAQ7bsf"
|
|
253
253
|
},
|
|
@@ -327,13 +327,39 @@
|
|
|
327
327
|
"await store.aadd_texts(all_texts, metadatas=metadatas, ids=ids)"
|
|
328
328
|
]
|
|
329
329
|
},
|
|
330
|
+
{
|
|
331
|
+
"cell_type": "markdown",
|
|
332
|
+
"metadata": {},
|
|
333
|
+
"source": [
|
|
334
|
+
"### Get collection\n",
|
|
335
|
+
"\n",
|
|
336
|
+
"Get collection from the vectorstore using filters and parameters."
|
|
337
|
+
]
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"cell_type": "code",
|
|
341
|
+
"execution_count": null,
|
|
342
|
+
"metadata": {},
|
|
343
|
+
"outputs": [],
|
|
344
|
+
"source": [
|
|
345
|
+
"documents_with_apple = await store.aget(\n",
|
|
346
|
+
" where_document={\"$ilike\": \"%apple%\"}, include=\"documents\"\n",
|
|
347
|
+
")\n",
|
|
348
|
+
"paginated_ids = await store.aget(limit=3, offset=3)\n",
|
|
349
|
+
"\n",
|
|
350
|
+
"print(documents_with_apple[\"documents\"])\n",
|
|
351
|
+
"print(paginated_ids[\"ids\"])"
|
|
352
|
+
]
|
|
353
|
+
},
|
|
330
354
|
{
|
|
331
355
|
"cell_type": "markdown",
|
|
332
356
|
"metadata": {},
|
|
333
357
|
"source": [
|
|
334
358
|
"### Delete documents\n",
|
|
335
359
|
"\n",
|
|
336
|
-
"Documents can be deleted using
|
|
360
|
+
"Documents can be deleted using IDs or metadata filters.\n",
|
|
361
|
+
"\n",
|
|
362
|
+
"#### Delete by IDs"
|
|
337
363
|
]
|
|
338
364
|
},
|
|
339
365
|
{
|
|
@@ -345,6 +371,47 @@
|
|
|
345
371
|
"await store.adelete([ids[1]])"
|
|
346
372
|
]
|
|
347
373
|
},
|
|
374
|
+
{
|
|
375
|
+
"cell_type": "markdown",
|
|
376
|
+
"metadata": {},
|
|
377
|
+
"source": [
|
|
378
|
+
"#### Delete by metadata filter\n",
|
|
379
|
+
"\n",
|
|
380
|
+
"You can delete documents based on metadata filters. This is useful for bulk deletion operations."
|
|
381
|
+
]
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"cell_type": "code",
|
|
385
|
+
"execution_count": null,
|
|
386
|
+
"metadata": {},
|
|
387
|
+
"outputs": [],
|
|
388
|
+
"source": [
|
|
389
|
+
"# Delete all documents with a specific metadata value\n",
|
|
390
|
+
"await store.adelete(filter={\"source\": \"documentation\"})"
|
|
391
|
+
]
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"cell_type": "code",
|
|
395
|
+
"execution_count": null,
|
|
396
|
+
"metadata": {},
|
|
397
|
+
"outputs": [],
|
|
398
|
+
"source": [
|
|
399
|
+
"# Delete documents matching complex filter criteria\n",
|
|
400
|
+
"await store.adelete(\n",
|
|
401
|
+
" filter={\"$and\": [{\"category\": \"obsolete\"}, {\"year\": {\"$lt\": 2020}}]}\n",
|
|
402
|
+
")"
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"cell_type": "code",
|
|
407
|
+
"execution_count": null,
|
|
408
|
+
"metadata": {},
|
|
409
|
+
"outputs": [],
|
|
410
|
+
"source": [
|
|
411
|
+
"# Delete by both IDs and filter (must match both criteria)\n",
|
|
412
|
+
"await store.adelete(ids=[\"id1\", \"id2\"], filter={\"status\": \"archived\"})"
|
|
413
|
+
]
|
|
414
|
+
},
|
|
348
415
|
{
|
|
349
416
|
"cell_type": "markdown",
|
|
350
417
|
"metadata": {},
|
|
@@ -496,7 +563,7 @@
|
|
|
496
563
|
},
|
|
497
564
|
{
|
|
498
565
|
"cell_type": "code",
|
|
499
|
-
"execution_count":
|
|
566
|
+
"execution_count": null,
|
|
500
567
|
"metadata": {},
|
|
501
568
|
"outputs": [],
|
|
502
569
|
"source": [
|
|
@@ -530,7 +597,7 @@
|
|
|
530
597
|
"source": [
|
|
531
598
|
"### Search for documents with metadata filter\n",
|
|
532
599
|
"\n",
|
|
533
|
-
"A Vector Store can take advantage of relational data to filter similarity searches. The vectorstore supports a set of filters that can be applied against the metadata fields of the documents. See the [migration guide](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.ipynb) for details on how to migrate to use metadata columns.\n",
|
|
600
|
+
"A Vector Store can take advantage of relational data to filter similarity searches. The vectorstore supports a set of filters that can be applied against the metadata fields of the documents. See the [migration guide](https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.ipynb) for details on how to migrate to use metadata columns for efficient filtering.\n",
|
|
534
601
|
"\n",
|
|
535
602
|
"`PGVectorStore` currently supports the following operators and all Postgres data types.\n",
|
|
536
603
|
"\n",
|
|
@@ -645,7 +712,7 @@
|
|
|
645
712
|
"\n",
|
|
646
713
|
"- **`metadata_columns=[\"name\", \"category\", \"price_usd\", \"quantity\", \"sku\", \"image_url\"]`**: These columns are treated as metadata for each product. Metadata provides additional information about a product, such as its name, category, price, quantity available, SKU (Stock Keeping Unit), and an image URL. This information is useful for displaying product details in search results or for filtering and categorization.\n",
|
|
647
714
|
"\n",
|
|
648
|
-
"- **`metadata_json_column=\"metadata\"`**: The `metadata` column can store any additional information about the products in a flexible JSON format. This allows for storing varied and complex data that doesn't fit into the standard columns.\n"
|
|
715
|
+
"- **`metadata_json_column=\"metadata\"`**: The `metadata` column can store any additional information about the products in a flexible JSON format. This allows for storing varied and complex data that doesn't fit into the standard columns. Note that filtering on fields within the JSON but not in `metadata_columns` will be less efficient.\n"
|
|
649
716
|
]
|
|
650
717
|
},
|
|
651
718
|
{
|
|
@@ -959,6 +1026,13 @@
|
|
|
959
1026
|
"source": [
|
|
960
1027
|
"await pg_engine.adrop_table(TABLE_NAME)"
|
|
961
1028
|
]
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"cell_type": "code",
|
|
1032
|
+
"execution_count": null,
|
|
1033
|
+
"metadata": {},
|
|
1034
|
+
"outputs": [],
|
|
1035
|
+
"source": []
|
|
962
1036
|
}
|
|
963
1037
|
],
|
|
964
1038
|
"metadata": {
|
|
@@ -967,7 +1041,8 @@
|
|
|
967
1041
|
"toc_visible": true
|
|
968
1042
|
},
|
|
969
1043
|
"kernelspec": {
|
|
970
|
-
"display_name": "
|
|
1044
|
+
"display_name": ".venv",
|
|
1045
|
+
"language": "python",
|
|
971
1046
|
"name": "python3"
|
|
972
1047
|
},
|
|
973
1048
|
"language_info": {
|
|
@@ -980,7 +1055,7 @@
|
|
|
980
1055
|
"name": "python",
|
|
981
1056
|
"nbconvert_exporter": "python",
|
|
982
1057
|
"pygments_lexer": "ipython3",
|
|
983
|
-
"version": "3.12.
|
|
1058
|
+
"version": "3.12.11"
|
|
984
1059
|
}
|
|
985
1060
|
},
|
|
986
1061
|
"nbformat": 4,
|