nat.plugins.zep_cloud.zep_editor#
Attributes#
Classes#
Wrapper class that implements NAT interfaces for Zep v3 Integrations Async. |
Module Contents#
- logger#
- class ZepEditor(zep_client: zep_cloud.client.AsyncZep)#
Bases:
nat.memory.interfaces.MemoryEditorWrapper class that implements NAT interfaces for Zep v3 Integrations Async. Uses thread-based memory management with automatic user creation.
Initialize class with Zep v3 AsyncZep Client.
- Args:
zep_client (AsyncZep): Async client instance.
- _client#
- async _ensure_user_exists(user_id: str) None#
Ensure a user exists in Zep v3, creating if necessary.
- Args:
user_id (str): The user ID to check/create.
- async add_items(items: list[nat.memory.models.MemoryItem], \*\*kwargs) None#
Insert Multiple MemoryItems into the memory using Zep v3 thread API. Each MemoryItem is translated and uploaded to a thread. Uses conversation_id from NAT context as thread_id for multi-thread support.
- Args:
items (list[MemoryItem]): The items to be added. kwargs (dict): Provider-specific keyword arguments.
ignore_roles (list[str], optional): List of role types to ignore when adding messages to graph memory. Available roles: system, assistant, user, function, tool.
- async search(
- query: str,
- top_k: int = 5,
- \*\*kwargs,
Retrieve memory from Zep v3 using the high-level get_user_context API. Uses conversation_id from NAT context as thread_id for multi-thread support.
Zep returns pre-formatted memory optimized for LLM consumption, including relevant facts, timestamps, and structured information from its knowledge graph.
- Args:
query (str): The query string (not used by Zep’s high-level API, included for interface compatibility). top_k (int): Maximum number of items to return (not used by Zep’s context API). kwargs: Zep-specific keyword arguments.
user_id (str, required for response construction): Used only to construct the returned MemoryItem. Zep v3’s thread.get_user_context() only requires thread_id.
mode (str, optional): Retrieval mode. Zep server default is “summary”. This implementation uses mode=”basic” (NAT’s default) for performance (P95 < 200ms). “summary” provides more comprehensive memory at the cost of latency.
- Returns:
list[MemoryItem]: A single MemoryItem containing the formatted context from Zep.
- async remove_items(\*\*kwargs) None#
Remove memory items based on provided criteria.
Supports two deletion modes:
Delete a specific thread by thread_id
Delete all threads for a user by user_id
- Args:
kwargs: Additional parameters.
thread_id (str, optional): Thread ID to delete a specific thread.
user_id (str, optional): User ID to delete all threads for that user.