diff --git a/libs/langchain/langchain/vectorstores/pgvector.py b/libs/langchain/langchain/vectorstores/pgvector.py index 6e6bdcead7e..41deb51f10a 100644 --- a/libs/langchain/langchain/vectorstores/pgvector.py +++ b/libs/langchain/langchain/vectorstores/pgvector.py @@ -147,6 +147,10 @@ class PGVector(VectorStore): self.create_tables_if_not_exists() self.create_collection() + def __del__(self) -> None: + if self._conn: + self._conn.close() + @property def embeddings(self) -> Embeddings: return self.embedding_function