Skip to content

The agent engineering platform.

fix: vectorstore pgvector ensure compatibility #3884 (#4248)

玄猫deffc65693e8
diff --git a/langchain/vectorstores/pgvector.py b/langchain/vectorstores/pgvector.py
index b75839d660..b29e5b3d4f 100644
--- a/langchain/vectorstores/pgvector.py
+++ b/langchain/vectorstores/pgvector.py
@@ -164,12 +164,12 @@ class PGVector(VectorStore):
self.logger.exception(e)
def create_tables_if_not_exists(self) -> None:
- Base.metadata.create_all(self._conn)
- self._conn.commit()
+ with self._conn.begin():
+ Base.metadata.create_all(self._conn)
def drop_tables(self) -> None:
- Base.metadata.drop_all(self._conn)
- self._conn.commit()
+ with self._conn.begin():
+ Base.metadata.drop_all(self._conn)
def create_collection(self) -> None:
if self.pre_delete_collection: