Registry / llm-agents / zep-python

zep-python

JSON →
library2.0.2pypypi✓ verified 82d ago

Zep is an open-source platform for long-term memory for AI agents, providing capabilities for summarization, embedding, and document management. The `zep-python` library offers an asynchronous client to interact with the Zep API, facilitating the management of user sessions, messages, and document collections. It is currently at version 2.0.2 and maintains an active release cadence with frequent updates and patches.

pip install zep-python
INSTALL
IMPORT
SIG · ZEP-PYTHON
Z
zep-python
llm-agentspythonv2.0.2
Install
3.8s avg
Import
Disk
30MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 32.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.8s · import 0.000s · 32MB
30MB installed
● package 30MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Memory
from zep_python import Memory
from zep_python import ZepClient
Message
from zep_python import Message
Session
from zep_python import Session

This quickstart demonstrates initializing the ZepClient, creating a new session (or handling an existing one), adding messages to that session, and then retrieving the session's memory. All client operations are asynchronous and require `await`.

import asyncio import os from zep_python import ZepClient from zep_python.models import Message, Memory async def main(): # Ensure ZEP_API_URL is set in your environment or provide a default api_url = os.environ.get("ZEP_API_URL", "http://localhost:8000") api_key = os.environ.get("ZEP_API_KEY", "") # Zep API key if authentication is enabled client = ZepClient(api_url=api_url, api_key=api_key) session_id = "my-test-session-123" user_id = "test_user" # Optional try: # Sessions must be explicitly created before adding messages (Zep v2+) await client.add_session(session_id=session_id, user_id=user_id, metadata={"project": "chatbot"}) print(f"Session '{session_id}' created.") except Exception as e: # Session might already exist, or another error occurred if "already exists" in str(e): print(f"Session '{session_id}' already exists.") else: print(f"Error creating session '{session_id}': {e}") # Add messages to the session messages_to_add = [ Message(role="user", content="Hello, my name is Alice."), Message(role="assistant", content="Hi Alice, how can I help you today?") ] await client.add_transcript(session_id=session_id, messages=messages_to_add) print(f"Added {len(messages_to_add)} messages to session '{session_id}'.") # Retrieve memory for the session memory: Memory = await client.get_memory(session_id=session_id) if memory and memory.messages: print(f"\nRetrieved memory for session '{session_id}':") for msg in memory.messages: print(f" {msg.role}: {msg.content}") else: print(f"\nNo memory found or memory is empty for session '{session_id}'.") # Clean up: delete the session (uncomment to enable) # await client.delete_session(session_id=session_id) # print(f"Session '{session_id}' deleted.") # Close the client session await client.close() if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
breakingZep Python Client v2.x is a complete rewrite and is **not backward compatible** with v1.x. It is an asynchronous-only client, uses `httpx` internally, and has significant API changes.
fix
Migrate your code to use the new async API. All client methods are now `await`able. Refer to the official Zep v2 migration guide.
affects: >=2.0.0
breakingThe `ZepClient` constructor and many core methods have changed names and signatures in v2. For example, `add_message` is now `add_transcript`, and `get_session_memory` is `get_memory`.
fix
Update method calls to their new v2 equivalents. Always `await` client method calls as they are now asynchronous.
affects: >=2.0.0
gotchaIn Zep v2+, you must explicitly create a session using `client.add_session()` before you can add messages or interact with its memory. Attempting to add messages to a non-existent session will result in a `NotFoundError`.
fix
Ensure you call `await client.add_session(session_id=...)` first, wrapping it in a `try-except` block to handle cases where the session might already exist.
affects: >=2.0.0
gotchaThe `zep-python` client is fully asynchronous. Forgetting `await` before client method calls (`client.add_session()`, `client.get_memory()`, etc.) will lead to runtime errors or unexpected behavior.
fix
Always prepend `await` to any Zep client method call. Ensure your application's entry point uses `asyncio.run()`.
affects: >=2.0.0
Upgrade
Version history
2.0.2latest on PyPI · released Sep 26, 2024
Audit
Dependencies
httpxrequiredAsynchronous HTTP client for API communication.
pydanticrequiredData validation and settings management for models.
Agent activity
52 hits · last 30 days
node
46
Perplexity
1
OpenAI (training)
1
Resources
zep-python — pip install zep-python · libregistry