Persisting and Retrieving Memory
Getting Started with Zep Memory
Understanding Zep’s different memory APIs
The Zep Memory API
provides a high-level interface for persisting and retrieving memory artifacts such as Messages, Sessions, and Facts. The Memory API
is Session-specific, opinionated,
and offers a number of different Memory Types designed for different memory retrieval use cases.
The Zep Search APIs
provide fine-grained control over memory artifact retrieval and are significantly more flexible than the Memory API
.
The Zep Session
and Message APIs
are lower-level APIs that offer Create
, Read
, Update
, and Delete
operations against individual Session and Message records and their associated memory artifacts.
Persisting Memory
The Zep Memory API
makes it simple to persist one or more Messages to a Session.
Python
TypeScript
Go
Retrieving Memory
Using the Memory API
The Zep Memory API
makes it simple to retrieve memory artifacts from a Session. Depending on the Type
of memory specific and available artifacts, a Memory
object is returned with one or more of the following properties:
messages
: An array ofMessage
objects for the lastN
messages in the session.relevant_facts
: An array ofFact
objects relevant to the last 4 messages in the session.
Python
TypeScript
Go
Using the Search API
The Memory Search API
provides a fine-grained interface for retrieving memory artifacts from a single Session, multiple Sessions, all Sessions for a User, or all Services project-wide.
Zep uses semantic similarity search to find the most relevant memory artifacts for a given text query.
Key features of this API:
- Supports searching over Messages, and Facts.
- Search queries may filtered by Message metadata.
- Results may be reranked using Maximum Marginal Relevance (MMR), inceasing the diversity of relevant results.
Python
TypeScript
Go
Using the Session and Message API
content
, role
, and role_type
are immutable. They may only be deleted when an entire Session is deleted. You may however update the metadata for a Message.
Have a use case for updating a Message? Let us know via the in-app chat!The Session
and Message
APIs provide a lower-level interface for managing Session and Message records and their associated memory artifacts. You may create, read, update, and delete Session and Message records.