Skip to content

Commit 555e37a

Browse files
committed
x
1 parent 94179ea commit 555e37a

5 files changed

+13
-24
lines changed

examples/migrate_pgvector_to_pgvectorstore.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@
280280
"outputs": [],
281281
"source": [
282282
"from langchain_core.embeddings import FakeEmbeddings\n",
283-
"\n",
284283
"from langchain_postgres import PGVectorStore\n",
285284
"from langchain_postgres.utils.pgvector_migrator import amigrate_pgvector_collection\n",
286285
"\n",

examples/pg_vectorstore.ipynb

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@
136136
},
137137
"outputs": [],
138138
"source": [
139-
"from sqlalchemy.exc import ProgrammingError\n",
140-
"\n",
141139
"from langchain_postgres import Column\n",
140+
"from sqlalchemy.exc import ProgrammingError\n",
142141
"\n",
143142
"try:\n",
144143
" await pg_engine.ainit_vectorstore_table(\n",
@@ -150,7 +149,7 @@
150149
" Column(\"topic\", \"TEXT\"),\n",
151150
" ],\n",
152151
" )\n",
153-
"except ProgrammingError:\n",
152+
"except ProgrammingError as e:\n",
154153
" # Catching the exception here\n",
155154
" print(\"Table already exists. Skipping creation.\")"
156155
]
@@ -192,7 +191,7 @@
192191
"source": [
193192
"from langchain_openai import OpenAIEmbeddings\n",
194193
"\n",
195-
"embedding = OpenAIEmbeddings(model=\"text-embedding-3-small\")"
194+
"embedding = OpenAIEmbeddings(model=\"text-embedding-3-small\")"
196195
]
197196
},
198197
{
@@ -227,7 +226,7 @@
227226
" engine=pg_engine,\n",
228227
" table_name=TABLE_NAME,\n",
229228
" embedding_service=embedding,\n",
230-
" metadata_columns=[\"location\", \"topic\"],\n",
229+
" metadata_columns=[\"location\", \"topic\"]\n",
231230
")"
232231
]
233232
},
@@ -253,9 +252,9 @@
253252
"outputs": [],
254253
"source": [
255254
"import uuid\n",
256-
"\n",
257255
"from langchain_core.documents import Document\n",
258256
"\n",
257+
"\n",
259258
"docs = [\n",
260259
" Document(\n",
261260
" id=uuid.uuid4(),\n",
@@ -389,9 +388,7 @@
389388
},
390389
"outputs": [],
391390
"source": [
392-
"await vectorstore.asimilarity_search(\n",
393-
" \"birds\", filter={\"$or\": [{\"topic\": \"animals\"}, {\"location\": \"market\"}]}\n",
394-
")"
391+
"await vectorstore.asimilarity_search(\"birds\", filter={\"$or\": [{\"topic\": \"animals\"}, {\"location\": \"market\"}]})"
395392
]
396393
},
397394
{
@@ -413,9 +410,7 @@
413410
},
414411
"outputs": [],
415412
"source": [
416-
"await vectorstore.asimilarity_search(\n",
417-
" \"apple\", filter={\"topic\": {\"$in\": [\"food\", \"animals\"]}}\n",
418-
")"
413+
"await vectorstore.asimilarity_search(\"apple\", filter={\"topic\": {\"$in\": [\"food\", \"animals\"]}})"
419414
]
420415
},
421416
{
@@ -426,9 +421,7 @@
426421
},
427422
"outputs": [],
428423
"source": [
429-
"await vectorstore.asimilarity_search(\n",
430-
" \"sales of fruit\", filter={\"topic\": {\"$ne\": \"animals\"}}\n",
431-
")"
424+
"await vectorstore.asimilarity_search(\"sales of fruit\", filter={\"topic\": {\"$ne\": \"animals\"}})"
432425
]
433426
},
434427
{
@@ -457,7 +450,7 @@
457450
"source": [
458451
"from langchain_postgres.v2.indexes import IVFFlatIndex\n",
459452
"\n",
460-
"index = IVFFlatIndex() # Add an index using a default index name\n",
453+
"index = IVFFlatIndex() # Add an index using a default index name\n",
461454
"await vectorstore.aapply_vector_index(index)"
462455
]
463456
},

examples/pg_vectorstore_how_to.ipynb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,8 @@
278278
"metadata": {},
279279
"outputs": [],
280280
"source": [
281-
"import uuid\n",
282-
"\n",
283281
"from langchain_core.documents import Document\n",
282+
"import uuid\n",
284283
"\n",
285284
"docs = [\n",
286285
" Document(\n",
@@ -401,7 +400,7 @@
401400
"metadata": {},
402401
"outputs": [],
403402
"source": [
404-
"from langchain_postgres.v2.indexes import HNSWIndex, IVFFlatIndex\n",
403+
"from langchain_postgres.v2.indexes import IVFFlatIndex, HNSWIndex\n",
405404
"\n",
406405
"index = IVFFlatIndex()\n",
407406
"await store.aapply_vector_index(index)\n",
@@ -462,7 +461,7 @@
462461
"outputs": [],
463462
"source": [
464463
"await store.adrop_vector_index() # Delete index using the default name\n",
465-
"await store.adrop_vector_index(\"my-hnsw-index\") # Delete index using the index name"
464+
"await store.adrop_vector_index(\"my-hnsw-index\") # Delete index using the index name"
466465
]
467466
},
468467
{

examples/vectorstore.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@
6868
"outputs": [],
6969
"source": [
7070
"from langchain_cohere import CohereEmbeddings\n",
71-
"from langchain_core.documents import Document\n",
72-
"\n",
7371
"from langchain_postgres.vectorstores import PGVector\n",
72+
"from langchain_core.documents import Document\n",
7473
"\n",
7574
"# See docker command above to launch a postgres instance with pgvector enabled.\n",
7675
"connection = \"postgresql+psycopg://langchain:langchain@localhost:6024/langchain\"\n",

langchain_postgres/chat_message_histories.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
This client provides support for both sync and async via psycopg 3.
44
"""
5-
65
from __future__ import annotations
76

87
import json

0 commit comments

Comments
 (0)