ZepCloudChatMessageHistory#

class langchain_community.chat_message_histories.zep_cloud.ZepCloudChatMessageHistory(session_id: str, api_key: str, *, memory_type: MemoryGetRequestMemoryType | None = None, lastn: int | None = None, ai_prefix: str | None = None, human_prefix: str | None = None, summary_instruction: str | None = None)[source]#

Chat message history that uses Zep Cloud as a backend.

Recommended usage:

# Set up Zep Chat History
zep_chat_history = ZepChatMessageHistory(
    session_id=session_id,
    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 - Recall, understand, and extract data from chat histories. Power personalized AI experiences.

Zep is a long-term memory service for AI Assistant apps. With Zep, you can provide AI assistants with the ability to recall past conversations, no matter how distant, while also reducing hallucinations, latency, and cost.

see Zep Cloud Docs: https://help.getzep.com

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

For more information on the zep-python package, see: getzep/zep-python

Attributes

messages

Retrieve messages from Zep memory

zep_facts

Retrieve conversation facts from Zep memory

zep_messages

Retrieve summary from Zep memory

zep_summary

Retrieve summary from Zep memory

Methods

__init__(session_id, 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) –

  • api_key (str) –

  • memory_type (Optional[MemoryGetRequestMemoryType]) –

  • lastn (Optional[int]) –

  • ai_prefix (Optional[str]) –

  • human_prefix (Optional[str]) –

  • summary_instruction (Optional[str]) –

__init__(session_id: str, api_key: str, *, memory_type: MemoryGetRequestMemoryType | None = None, lastn: int | None = None, ai_prefix: str | None = None, human_prefix: str | None = None, summary_instruction: str | None = None) None[source]#
Parameters:
  • session_id (str) –

  • api_key (str) –

  • memory_type (Optional[MemoryGetRequestMemoryType]) –

  • lastn (Optional[int]) –

  • ai_prefix (Optional[str]) –

  • human_prefix (Optional[str]) –

  • summary_instruction (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: Dict[str, Any] | None = 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 (Dict[str, Any] | None) – Optional metadata to attach to the message.

Return type:

None

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

Append the message to the Zep memory history

Parameters:
  • message (BaseMessage) –

  • metadata (Dict[str, Any] | None) –

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: Dict[str, Any] | None = 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 (Dict[str, Any] | None) – 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: Dict | None = None, search_scope: SearchScope = 'messages', search_type: SearchType = 'similarity', mmr_lambda: float | None = None, limit: int | None = 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]

Examples using ZepCloudChatMessageHistory