Add ZepMemory; improve ZepChatMessageHistory handling of metadata; Fix bugs (#7444)

Hey @hwchase17 - 

This PR adds a `ZepMemory` class, improves handling of Zep's message
metadata, and makes it easier for folks building custom chains to
persist metadata alongside their chat history.

We've had plenty confused users unfamiliar with ChatMessageHistory
classes and how to wrap the `ZepChatMessageHistory` in a
`ConversationBufferMemory`. So we've created the `ZepMemory` class as a
light wrapper for `ZepChatMessageHistory`.

Details:
- add ZepMemory, modify notebook to demo use of ZepMemory
- Modify summary to be SystemMessage
- add metadata argument to add_message; add Zep metadata to
Message.additional_kwargs
- support passing in metadata
This commit is contained in:
Daniel Chalef
2023-07-09 22:53:49 -07:00
committed by GitHub
parent 8f8e8d701e
commit c7f7788d0b
5 changed files with 257 additions and 97 deletions

View File

@@ -4,7 +4,7 @@ import pytest
from pytest_mock import MockerFixture
from langchain.memory.chat_message_histories import ZepChatMessageHistory
from langchain.schema.messages import AIMessage, HumanMessage
from langchain.schema.messages import AIMessage, HumanMessage, SystemMessage
if TYPE_CHECKING:
from zep_python import ZepClient
@@ -39,7 +39,7 @@ def test_messages(mocker: MockerFixture, zep_chat: ZepChatMessageHistory) -> Non
result = zep_chat.messages
assert len(result) == 3
assert isinstance(result[0], HumanMessage) # summary
assert isinstance(result[0], SystemMessage) # summary
assert isinstance(result[1], AIMessage)
assert isinstance(result[2], HumanMessage)