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])

aadd_messages(messages)

Append the messages to the Zep memory history asynchronously

aclear()

Clear session memory from Zep asynchronously.

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_messages(messages)

Append the messages to the Zep memory history

add_user_message(message[, metadata])

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

aget_messages()

Async version of getting messages.

clear()

Clear session memory from Zep.

search(query[, metadata, search_scope, ...])

Search Zep memory for messages matching the query

Parameters
  • session_id (str) –

  • url (str) –

  • api_key (Optional[str]) –

__init__(session_id: str, url: str = 'http://localhost:8000', api_key: Optional[str] = None) None[source]
Parameters
  • session_id (str) –

  • url (str) –

  • api_key (Optional[str]) –

Return type

None

async aadd_messages(messages: Sequence[BaseMessage]) None[source]

Append the messages to the Zep memory history asynchronously

Parameters

messages (Sequence[BaseMessage]) –

Return type

None

async aclear() None[source]

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

Return type

None

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 (str) – The string contents of an AI message.

  • metadata (Optional[Dict[str, Any]]) – Optional metadata to attach to the message.

Return type

None

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

Append the message to the Zep memory history

Parameters
  • message (BaseMessage) –

  • metadata (Optional[Dict[str, Any]]) –

Return type

None

add_messages(messages: Sequence[BaseMessage]) None[source]

Append the messages to the Zep memory history

Parameters

messages (Sequence[BaseMessage]) –

Return type

None

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 (str) – The string contents of a human message.

  • metadata (Optional[Dict[str, Any]]) – Optional metadata to attach to the message.

Return type

None

async aget_messages() List[BaseMessage]

Async version of getting messages.

Can over-ride this method to provide an efficient async implementation.

In general, fetching messages may involve IO to the underlying persistence layer.

Return type

List[BaseMessage]

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.

Return type

None

search(query: str, metadata: Optional[Dict] = None, search_scope: SearchScope = SearchScope.messages, search_type: SearchType = SearchType.similarity, mmr_lambda: Optional[float] = None, limit: Optional[int] = None) List[MemorySearchResult][source]

Search Zep memory for messages matching the query

Parameters
  • query (str) –

  • metadata (Optional[Dict]) –

  • search_scope (SearchScope) –

  • search_type (SearchType) –

  • mmr_lambda (Optional[float]) –

  • limit (Optional[int]) –

Return type

List[MemorySearchResult]