Skip to content

Commit 2883be6

Browse files
fix: Add setter for Chat Message History messages (#174)
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) --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
1 parent be2fc47 commit 2883be6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

langchain_postgres/chat_message_histories.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,17 @@ async def aget_messages(self) -> List[BaseMessage]:
340340
messages = messages_from_dict(items)
341341
return messages
342342

343-
@property # type: ignore[override]
343+
@property
344344
def messages(self) -> List[BaseMessage]:
345345
"""The abstraction required a property."""
346346
return self.get_messages()
347347

348+
@messages.setter
349+
def messages(self, value: list[BaseMessage]) -> None:
350+
"""Clear the stored messages and appends a list of messages."""
351+
self.clear()
352+
self.add_messages(value)
353+
348354
def clear(self) -> None:
349355
"""Clear the chat message history for the GIVEN session."""
350356
if self._connection is None:

0 commit comments

Comments
 (0)