From 3efc044ff6cf0892daa278411f1ab814fa15728e Mon Sep 17 00:00:00 2001 From: Alex Leidwein Date: Wed, 29 May 2024 16:15:23 +0200 Subject: [PATCH] Fix transactions not being committed --- langchain_postgres/chat_message_histories.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/langchain_postgres/chat_message_histories.py b/langchain_postgres/chat_message_histories.py index 85f2aef..c18c70d 100644 --- a/langchain_postgres/chat_message_histories.py +++ b/langchain_postgres/chat_message_histories.py @@ -320,6 +320,7 @@ def get_messages(self) -> List[BaseMessage]: with self._connection.cursor() as cursor: cursor.execute(query, {"session_id": self._session_id}) items = [record[0] for record in cursor.fetchall()] + self._connection.commit() messages = messages_from_dict(items) return messages @@ -336,6 +337,7 @@ async def aget_messages(self) -> List[BaseMessage]: async with self._aconnection.cursor() as cursor: await cursor.execute(query, {"session_id": self._session_id}) items = [record[0] for record in await cursor.fetchall()] + await self._aconnection.commit() messages = messages_from_dict(items) return messages