From 7f1345a625fe23dd8dd4f2f0d1a137930e9262fa Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Fri, 4 Apr 2025 09:12:40 -0700 Subject: [PATCH 1/2] fix: Add setter for Chat Message History messages Fixes mypy error: langchain_postgres/chat_message_histories.py:344: error: Cannot override writeable attribute with read-only property [override] Found 1 error in 1 file (checked 37 source files) --- langchain_postgres/chat_message_histories.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/langchain_postgres/chat_message_histories.py b/langchain_postgres/chat_message_histories.py index 85f2aef7..8b6f5442 100644 --- a/langchain_postgres/chat_message_histories.py +++ b/langchain_postgres/chat_message_histories.py @@ -340,11 +340,17 @@ async def aget_messages(self) -> List[BaseMessage]: messages = messages_from_dict(items) return messages - @property # type: ignore[override] + @property def messages(self) -> List[BaseMessage]: """The abstraction required a property.""" return self.get_messages() + @messages.setter + def messages(self, value: list[BaseMessage]) -> None: + """Clear the stored messages and appends a list of messages to the record in AlloyDB.""" + self.clear() + self.add_messages(value) + def clear(self) -> None: """Clear the chat message history for the GIVEN session.""" if self._connection is None: From 762616cbd8ec1e8880d1355d2389b9949288457d Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Fri, 4 Apr 2025 11:42:50 -0700 Subject: [PATCH 2/2] Update langchain_postgres/chat_message_histories.py Co-authored-by: Eugene Yurtsev --- langchain_postgres/chat_message_histories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/langchain_postgres/chat_message_histories.py b/langchain_postgres/chat_message_histories.py index 8b6f5442..c1ff7cc3 100644 --- a/langchain_postgres/chat_message_histories.py +++ b/langchain_postgres/chat_message_histories.py @@ -347,7 +347,7 @@ def messages(self) -> List[BaseMessage]: @messages.setter def messages(self, value: list[BaseMessage]) -> None: - """Clear the stored messages and appends a list of messages to the record in AlloyDB.""" + """Clear the stored messages and appends a list of messages.""" self.clear() self.add_messages(value)