From 274242a7dd62da6634607f9d167960edf9986437 Mon Sep 17 00:00:00 2001 From: Disha Prakash Date: Wed, 19 Mar 2025 21:14:12 +0000 Subject: [PATCH 1/4] chore: Add deprecation warning for PGVector --- langchain_postgres/vectorstores.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index 044bece6..6f2d0892 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -19,6 +19,7 @@ Type, Union, ) +import warnings from typing import ( cast as typing_cast, ) @@ -48,6 +49,8 @@ from langchain_postgres._utils import maximal_marginal_relevance +warnings.simplefilter('always', PendingDeprecationWarning) + class DistanceStrategy(str, enum.Enum): """Enumerator of the Distance strategies.""" @@ -428,6 +431,11 @@ def __init__( self._async_engine: Optional[AsyncEngine] = None self._async_init = False + warnings.warn("PGVector is being deprecated and will be removed in a future version. " + "Please migrate to PGVectorStore. " + "Refer to the migration guide at [https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md] for details.", + PendingDeprecationWarning) + if isinstance(connection, str): if async_mode: self._async_engine = create_async_engine( From ab18197c46ade56a4bcb0268c01463e2ee21ca71 Mon Sep 17 00:00:00 2001 From: Disha Prakash Date: Wed, 19 Mar 2025 21:15:42 +0000 Subject: [PATCH 2/4] Linter fix --- langchain_postgres/vectorstores.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index 6f2d0892..674dc0e6 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -49,7 +49,7 @@ from langchain_postgres._utils import maximal_marginal_relevance -warnings.simplefilter('always', PendingDeprecationWarning) +warnings.simplefilter("always", PendingDeprecationWarning) class DistanceStrategy(str, enum.Enum): @@ -431,10 +431,12 @@ def __init__( self._async_engine: Optional[AsyncEngine] = None self._async_init = False - warnings.warn("PGVector is being deprecated and will be removed in a future version. " - "Please migrate to PGVectorStore. " - "Refer to the migration guide at [https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md] for details.", - PendingDeprecationWarning) + warnings.warn( + "PGVector is being deprecated and will be removed in a future version. " + "Please migrate to PGVectorStore. " + "Refer to the migration guide at [https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md] for details.", + PendingDeprecationWarning, + ) if isinstance(connection, str): if async_mode: From 4934419c51a3061e87b66e5ff9b8c79b396fd399 Mon Sep 17 00:00:00 2001 From: Disha Prakash Date: Wed, 19 Mar 2025 21:21:07 +0000 Subject: [PATCH 3/4] change warning stmt --- langchain_postgres/vectorstores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index 674dc0e6..bb5322ce 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -432,7 +432,7 @@ def __init__( self._async_init = False warnings.warn( - "PGVector is being deprecated and will be removed in a future version. " + "PGVector is being deprecated and will be removed in the future. " "Please migrate to PGVectorStore. " "Refer to the migration guide at [https://github.com/langchain-ai/langchain-postgres/blob/main/examples/migrate_pgvector_to_pgvectorstore.md] for details.", PendingDeprecationWarning, From 24779dd9fbcc04e44d1ee51863c0f7600fa40b7e Mon Sep 17 00:00:00 2001 From: Disha Prakash Date: Tue, 25 Mar 2025 11:01:13 +0000 Subject: [PATCH 4/4] Review changes --- langchain_postgres/vectorstores.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain_postgres/vectorstores.py b/langchain_postgres/vectorstores.py index bb5322ce..3f741b8b 100644 --- a/langchain_postgres/vectorstores.py +++ b/langchain_postgres/vectorstores.py @@ -49,7 +49,7 @@ from langchain_postgres._utils import maximal_marginal_relevance -warnings.simplefilter("always", PendingDeprecationWarning) +warnings.simplefilter("once", PendingDeprecationWarning) class DistanceStrategy(str, enum.Enum):