langchain_community.chat_message_histories.zep.ZepChatMessageHistory¶

class langchain_community.chat_message_histories.zep.ZepChatMessageHistory(session_id: str, url: str = 'http://localhost:8000', api_key: Optional[str] = None)[source]¶

Chat message history that uses Zep as a backend.

Recommended usage:

# Set up Zep Chat History
zep_chat_history = ZepChatMessageHistory(
    session_id=session_id,
    url=ZEP_API_URL,
    api_key=<your_api_key>,
)

# Use a standard ConversationBufferMemory to encapsulate the Zep chat history
memory = ConversationBufferMemory(
    memory_key="chat_history", chat_memory=zep_chat_history
)

Zep provides long-term conversation storage for LLM apps. The server stores, summarizes, embeds, indexes, and enriches conversational AI chat histories, and exposes them via simple, low-latency APIs.

For server installation instructions and more, see: https://docs.getzep.com/deployment/quickstart/

This class is a thin wrapper around the zep-python package. Additional Zep functionality is exposed via the zep_summary and zep_messages properties.

For more information on the zep-python package, see: https://github.com/getzep/zep-python

Attributes

messages

Retrieve messages from Zep memory

zep_messages

Retrieve summary from Zep memory

zep_summary

Retrieve summary from Zep memory

Methods

__init__(session_id[, url, api_key])

add_ai_message(message[, metadata])

Convenience method for adding an AI message string to the store.

add_message(message[, metadata])

Append the message to the Zep memory history

add_user_message(message[, metadata])

Convenience method for adding a human message string to the store.

clear()

Clear session memory from Zep.

search(query[, metadata, limit])

Search Zep memory for messages matching the query

__init__(session_id: str, url: str = 'http://localhost:8000', api_key: Optional[str] = None) None[source]¶
add_ai_message(message: str, metadata: Optional[Dict[str, Any]] = None) None[source]¶

Convenience method for adding an AI message string to the store.

Parameters
  • message – The string contents of an AI message.

  • metadata – Optional metadata to attach to the message.

add_message(message: BaseMessage, metadata: Optional[Dict[str, Any]] = None) None[source]¶

Append the message to the Zep memory history

add_user_message(message: str, metadata: Optional[Dict[str, Any]] = None) None[source]¶

Convenience method for adding a human message string to the store.

Parameters
  • message – The string contents of a human message.

  • metadata – Optional metadata to attach to the message.

clear() None[source]¶

Clear session memory from Zep. Note that Zep is long-term storage for memory and this is not advised unless you have specific data retention requirements.

search(query: str, metadata: Optional[Dict] = None, limit: Optional[int] = None) List[MemorySearchResult][source]¶

Search Zep memory for messages matching the query