Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revised README #359

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 99 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</p>

<h1 align="center">
Zep: Long-Term Memory for ‍AI Assistants.
Zep: The Memory Foundation For Your AI Stack
</h1>
<h2 align="center">Recall, understand, and extract data from chat histories. Power personalized AI experiences.</h2>
<h2 align="center">Build AI agents that continually learn. Power personalized experiences.</h2>
<br />
<p align="center">
<a href="https://discord.gg/W8Kw6bsgXQ"><img
Expand All @@ -25,80 +25,99 @@ Zep: Long-Term Memory for ‍AI Assistants.
</p>

<p align="center">
<a href="https://docs.getzep.com/deployment/quickstart/">Quick Start</a> |
<a href="https://docs.getzep.com/">Documentation</a> |
<a href="https://docs.getzep.com/sdk/langchain/">LangChain</a> and
<a href="https://docs.getzep.com/sdk/langchain/">LlamaIndex</a> Support |
<a href="https://discord.gg/W8Kw6bsgXQ">Discord</a><br />
<a href="https://www.getzep.com">www.getzep.com</a>
<a href="https://help.getzep.com/ce/quickstart">Quick Start</a> |
<a href="https://help.getzep.com/memory">Documentation</a> |
<a href="https://help.getzep.com">Zep Cloud Docs</a>
</p>

## What is Zep? 💬
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.
## What is Zep? 💬

### How Zep works
Zep continually learns from user interactions, improving your AI agent's knowledge over time. With Zep, you can personalize user experiences and significantly improve agent accuracy.

Zep persists and recalls chat histories, and automatically generates summaries and other artifacts from these chat histories. It also embeds messages and summaries, enabling you to search Zep for relevant context from past conversations. Zep does all of this asyncronously, ensuring these operations don't impact your user's chat experience. Data is persisted to database, allowing you to scale out when growth demands.
Zep is powered by a temporal Knowledge Graph. As your user's conversation with an agent progresses, new facts are added to the graph. Zep maintains historical context, helping your agent reason with state change and offering data provenance insights.

Zep also provides a simple, easy to use abstraction for document vector search called Document Collections. This is designed to complement Zep's core memory features, but is not designed to be a general purpose vector database.
Retrieving facts is simple and very fast, with both semantic and graph search used to ensure facts are relevant to the current conversation. Fact retrieval does not require LLM inference, with the slowest activity being embedding the search query.

Zep allows you to be more intentional about constructing your prompt:
1. automatically adding a few recent messages, with the number customized for your app;
2. a summary of recent conversations prior to the messages above;
3. and/or contextually relevant summaries or messages surfaced from the entire chat session.
4. and/or relevant Business data from Zep Document Collections.
Zep supports:

## What is Zep Cloud? ⚡️
- Adding chat history messages.
- Ingestion of JSON and unstructured text.
- Session, user, and group-level graphs. Group graphs allow for capturing organizational knowledge.

[Zep Cloud](https://www.getzep.com/) is a managed service with Zep Open Source at its core. In addition to Zep Open Source's memory management features, Zep Cloud offers:
- **Fact Extraction:** Automatically build fact tables from conversations, without having to define a data schema upfront.
- **Dialog Classification:** Instantly and accurately classify chat dialog. Understand user intent and emotion, segment users, and more. Route chains based on semantic context, and trigger events.
- **Structured Data Extraction:** Quickly extract business data from chat conversations using a schema you define. Understand what your Assistant should ask for next in order to complete its task.
## Simple APIs with SDKs for Python, TypeScript, and Go

## Why use Zep for long-term memory?
Persisting chat history memory is simple and fast.

### Why not just include the entire chat history in the prompt?
```python
result = await client.memory.add(session_id, messages=messages)
```

With increased LLM context lengths, it may be tempting to include entire an chat history in a prompt, alongside RAG results, and other instructions. Unfortunately, we've seen poor recall, hallucinations, and slow and expensive inference as a result.
Zep's high-level memory API offers an optionated retrieval API, which uses BM25, semantic, and graph search to retrieve facts relevant to the current conversation. Results are reranked by distance from the user node, further improving relevance.

### Why not use Redis, Postgres, a Vector Database, or ... to persist chat histories?
```python
memory = client.memory.get(session_id="session_id")
```

Our goal with Zep is to elevate the layer of abstraction for memory management. We believe developer productivity is best served by infrastructure with well-designed abstractions, rather than building peristence, summarization, extraction, embedding management, and search from the ground up.
Lower-level APIs for search and CRUD are also available.

### Is Zep a vector database?
## Why does Zep use a temporal Knowledge Graph?

No. Zep uses embeddings and vector database capaiblities under the hood to power many of its features, but is not designed to be a general purpose vector database.
> A Knowledge Graph is a network of interconnected facts, such as “Kendra loves Adidas shoes.” Each fact is a “triplet” represented by two entities, or nodes (”Kendra”, “Adidas shoes”), and their relationship, or edge (”loves”).

### Zep is purpose-built for Assistant applications
Knowledge Graphs allow us to model an agent's complex world and offer a superior approach to retrieval than semantic search alone, which is commonly used in RAG. Most approaches to buiilding Knowledge Graphs don't reason well with state changes. Facts inevitablely change over time as users provide new information or business data changes.

Users, Sessions, and Chat Messages are first-class abstractions in Zep. This allows simple and flexible management of chat memory, including the execution of Right To Be Forgetten requests and other privacy compliance-related tasks with single-API call.
Most graph-building tools don't reason well with state changes. Zep incorporates a temporal Knowledge Graph library, [Graphiti](https://github.com/getzep/graphiti), which we developed to address this challenge. What makes Graphiti unique is its ability to autonomously build a Knowledge Graph while handling changing relationships and maintaining historical context.

## Zep Language Support and Ecosystem
Graphiti also offers Zep the ability to ingest not just chat history, but also JSON business data and unstructured text.

### Does Zep have Python and TypeScript support?
## Is Zep tied to a framework such as LangChain?

Yes - Zep offers Python & TypeScript/JS SDKs for easy integration with your Assistant app. We also have examples of using Zep with popular frameworks - see below.
Zep is framework agnostic. You may use it with LangChain, LangGraph, Chainlit, Microsoft Autogen, and more.

## What is Zep Community Edition? ⭐️

### Can I use Zep with LangChain, LlamaIndex, Vercel AI, n8n, FlowWise, ...?
Zep Community Edition is an open source licensed distribution of Zep and is contained in this repo. Zep Community Edition is shares APIs with Zep Cloud, with [comprehensive documentation](https://help.getzep.com) available.

## What is Zep Cloud? ⚡️

[Zep Cloud](https://www.getzep.com/) is a managed service with Zep Community Edition at its core. In addition to Zep Community Edition's memory layer, Zep Cloud offers:

- **Low Latency, Scalability, High Availability:** Our cloud is designed to scale to the needs of customers with millions of DAUs and is SOC II Type 2 certified. Zep utilizes self-hosted LLMs and embedding models, offering customers very low-latency memory retrieval and graph-building.
- **Dialog Classification:** Instantly and accurately classify chat dialog. Understand user intent and emotion, segment users, and more. Route chains based on semantic context, and trigger events.
- **Structured Data Extraction:** Quickly extract business data from chat conversations using a schema you define. Understand what your Assistant should ask for next in order to complete its task.

Yes - the Zep team and community contributors have built integrations with Zep, making it simple to, for example, drop Zep's memory components into a LangChain app. Please see the [Zep Documentation](https://docs.getzep.com/) and your favorite framework's documentation for more.
## Why use Zep for long-term memory?

### Why not just include the entire chat history in the prompt?

With increased LLM context lengths, it may be tempting to include entire an chat history in a prompt, alongside RAG results, and other instructions. Unfortunately, we've seen poor temporal reasoning, poor recall, hallucinations, and slow and expensive inference as a result.

### Why not use Redis, Postgres, or ... to persist chat histories?

As discussed above, providing just the chat history to an LLM can often result in poor temporal reasoning.

### Zep is purpose-built for Agent and Assistant applications

Users, Sessions, and Chat Messages are first-class abstractions in Zep. This allows simple and flexible management of chat memory, including the execution of Right To Be Forgetten requests and other privacy compliance-related tasks with single-API call.

## Zep Open Source LLM Service Dependencies
## Zep Language Support and Ecosystem

### Does Zep have Python, TypeScript, and Go support?

Yes - Zep offers Python & TypeScript/JS SDKs for easy integration with your Assistant app. We also have examples of using Zep with popular frameworks - see below.

### Can I use Zep with LangChain, LlamaIndex, Vercel AI, n8n, FlowWise, ...?

Zep Open Source relies on an external LLM API service to function. OpenAI, Azure OpenAI, Anthropic, and OpenAI-compatible APIs are all supported.
Yes - the Zep team and community contributors have built integrations with Zep, making it simple to, for example, drop Zep's memory components into a LangChain app. Please see the [Zep Documentation](https://help.getzep.com/) and your favorite framework's documentation for more.

## Zep Community Edition LLM Service Dependencies

## Learn more
- 🏎️ **[Quick Start Guide](https://docs.getzep.com/deployment/quickstart/)**: Docker deployment, and coding, in < 5 minutes.
- 📚 **[Zep By Example](https://docs.getzep.com/sdk/examples/)**: Learn how to use Zep by example.
- 🦙 **[Building Apps with LlamaIndex](https://docs.getzep.com/sdk/llamaindex/)**
- 🦜⛓️ **[Building Apps with LangChain](https://docs.getzep.com/sdk/langchain/)**
- 🛠️ [**Getting Started with TypeScript/JS or Python**](https://docs.getzep.com/sdk/)
Zep Community Edition relies on an external LLM API service to function. Any OpenAI-compatible LLM API is supported. Providers such as Anthropic can be used via a proxy such as LiteLLM. Note that you will also need to configure LiteLLM with an embedding service.

## Examples

### Create Users, Chat Sessions, and Chat Messages (Zep Python SDK)

```python
user_request = CreateUserRequest(
user_id=user_id,
Expand All @@ -112,7 +131,7 @@ new_user = client.user.add(user_request)
# create a chat session
session_id = uuid.uuid4().hex # A new session identifier
session = Session(
session_id=session_id,
session_id=session_id,
user_id=user_id,
metadata={"foo" : "bar"}
)
Expand All @@ -131,71 +150,39 @@ sessions = client.user.getSessions(user_id)
```

### Persist Chat History with LangChain.js (Zep TypeScript SDK)

```typescript
const memory = new ZepMemory({
sessionId,
baseURL: zepApiURL,
apiKey: zepApiKey,
sessionId,
baseURL: zepApiURL,
apiKey: zepApiKey,
});
const chain = new ConversationChain({ llm: model, memory });
const response = await chain.run(
{
input="What is the book's relevance to the challenges facing contemporary society?"
},
);
const response = await chain.run({
input = "What is the book's relevance to the challenges facing contemporary society?",
});
```

### Hybrid similarity search over a document collection with text input and JSONPath filters (TypeScript)

```typescript
const query = "Who was Octavia Butler?";
const searchResults = await collection.search({ text: query }, 3);

// Search for documents using both text and metadata
const metadataQuery = {
where: { jsonpath: '$[*] ? (@.genre == "scifi")' },
where: { jsonpath: '$[*] ? (@.genre == "scifi")' },
};

const newSearchResults = await collection.search(
{
text: query,
metadata: metadataQuery,
},
3
{
text: query,
metadata: metadataQuery,
},
3
);
```

### Create a LlamaIndex Index using Zep as a VectorStore (Python)
```python
from llama_index import VectorStoreIndex, SimpleDirectoryReader
from llama_index.vector_stores import ZepVectorStore
from llama_index.storage.storage_context import StorageContext

vector_store = ZepVectorStore(
api_url=zep_api_url,
api_key=zep_api_key,
collection_name=collection_name
)

documents = SimpleDirectoryReader("documents/").load_data()
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(
documents,
storage_context=storage_context
)
```

### Search by embedding (Zep Python SDK)
```python
# Search by embedding vector, rather than text query
# embedding is a list of floats
results = collection.search(
embedding=embedding, limit=5
)
```




## Get Started

### Install Server
Expand All @@ -221,3 +208,23 @@ pip install zep-python
```bash
npm i @getzep/zep-js
```

## How does Zep Community Edition differ from Zep Open Source v0.x?

Zep Open Source is an older version of Zep that did not use a Knowledge Graph to persist and recall memory.

Some additional changes:

- The Zep OSS web UI has been deprecated in favor of significantly expanded SDK support.
- The Zep CE supports broad number of LLM services and local servers that offer OpenAI-compatible APIs. Other services may be used with an LLM proxy.
- Zep CE no longer ships with a local embedding service and named entity extractor.

### Is there a migration path from Zep Open Source to Zep Community Edition?

There have been significant changes to how Zep operates and unfortunately we have not been able to devise a migration path from Zep OSS to Zep CE.

Zep OSS will remain available in our container repo but will not see future enhancements or bug fixes. The code is available in the `legacy` branch in this repo.

## Contributing

We welcome contributions. See the [`CONTRIBUTING`](CONTRIBUTING.md) file in this repo for more.
Loading