# Zep Reader
```bash
pip install llama-index-readers-zep
```
The Zep Reader returns a set of texts corresponding to a text query or embeddings retrieved from a Zep Collection.
The Reader is initialized with a Zep API URL and optionally an API key. The Reader can then be used to load data
from a Zep Document Collection.
## About Zep
Zep is a long-term memory store for LLM applications. Zep makes it simple to add relevant documents, chat history memory
and rich user data to your LLM app's prompts.
For more information about Zep and the Zep Quick Start Guide, see the [Zep documentation](https://docs.getzep.com/).
## Usage
Here's an end-to-end example usage of the ZepReader. First, we create a Zep Collection, chunk a document,
and add it to the collection.
We then wait for Zep's async embedder to embed the document chunks. Finally, we query the collection and print the
results.
```python
import time
from uuid import uuid4
from llama_index.core.node_parser import SimpleNodeParser
from llama_index.core import Document
from zep_python import ZepClient
from zep_python.document import Document as ZepDocument
from llama_index.readers.zep import ZepReader
# Create a Zep collection
zep_api_url = "http://localhost:8000" # replace with your Zep API URL
collection_name = f"babbage{uuid4().hex}"
file = "babbages_calculating_engine.txt"
print(f"Creating collection {collection_name}")
client = ZepClient(base_url=zep_api_url, api_key="optional_api_key")
collection = client.document.add_collection(
name=collection_name, # required
description="Babbage's Calculating Engine", # optional
metadata={"foo": "bar"}, # optional metadata
embedding_dimensions=1536, # this must match the model you've configured in Zep
is_auto_embedded=True, # use Zep's built-in embedder. Defaults to True
)
node_parser = SimpleNodeParser.from_defaults(chunk_size=250, chunk_overlap=20)
with open(file) as f:
raw_text = f.read()
print("Splitting text into chunks and adding them to the Zep vector store.")
docs = node_parser.get_nodes_from_documents(
[Document(text=raw_text)], show_progress=True
)
# Convert nodes to ZepDocument
zep_docs = [ZepDocument(content=d.get_content()) for d in docs]
uuids = collection.add_documents(zep_docs)
print(f"Added {len(uuids)} documents to collection {collection_name}")
print("Waiting for documents to be embedded")
while True:
c = client.document.get_collection(collection_name)
print(
"Embedding status: "
f"{c.document_embedded_count}/{c.document_count} documents embedded"
)
time.sleep(1)
if c.status == "ready":
break
query = "Was Babbage awarded a medal?"
# Using the ZepReader to load data from Zep
reader = ZepReader(api_url=zep_api_url, api_key="optional_api_key")
results = reader.load_data(
collection_name=collection_name, query=query, top_k=3
)
print("\n\n".join([r.text for r in results]))
```
Raw data
{
"_id": null,
"home_page": null,
"name": "llama-index-readers-zep",
"maintainer": "zep",
"docs_url": null,
"requires_python": "<4.0,>=3.9.0",
"maintainer_email": null,
"keywords": "memory, retriever, storage, zep",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/e0/c6/8ce9556dee7ec43e932643b40ce0cdfbaf13d21863b7b89ec5589734a8b1/llama_index_readers_zep-0.3.0.tar.gz",
"platform": null,
"description": "# Zep Reader\n\n```bash\npip install llama-index-readers-zep\n```\n\nThe Zep Reader returns a set of texts corresponding to a text query or embeddings retrieved from a Zep Collection.\nThe Reader is initialized with a Zep API URL and optionally an API key. The Reader can then be used to load data\nfrom a Zep Document Collection.\n\n## About Zep\n\nZep is a long-term memory store for LLM applications. Zep makes it simple to add relevant documents, chat history memory\nand rich user data to your LLM app's prompts.\n\nFor more information about Zep and the Zep Quick Start Guide, see the [Zep documentation](https://docs.getzep.com/).\n\n## Usage\n\nHere's an end-to-end example usage of the ZepReader. First, we create a Zep Collection, chunk a document,\nand add it to the collection.\n\nWe then wait for Zep's async embedder to embed the document chunks. Finally, we query the collection and print the\nresults.\n\n```python\nimport time\nfrom uuid import uuid4\n\nfrom llama_index.core.node_parser import SimpleNodeParser\nfrom llama_index.core import Document\nfrom zep_python import ZepClient\nfrom zep_python.document import Document as ZepDocument\n\n\nfrom llama_index.readers.zep import ZepReader\n\n# Create a Zep collection\nzep_api_url = \"http://localhost:8000\" # replace with your Zep API URL\ncollection_name = f\"babbage{uuid4().hex}\"\nfile = \"babbages_calculating_engine.txt\"\n\nprint(f\"Creating collection {collection_name}\")\n\nclient = ZepClient(base_url=zep_api_url, api_key=\"optional_api_key\")\ncollection = client.document.add_collection(\n name=collection_name, # required\n description=\"Babbage's Calculating Engine\", # optional\n metadata={\"foo\": \"bar\"}, # optional metadata\n embedding_dimensions=1536, # this must match the model you've configured in Zep\n is_auto_embedded=True, # use Zep's built-in embedder. Defaults to True\n)\n\nnode_parser = SimpleNodeParser.from_defaults(chunk_size=250, chunk_overlap=20)\n\nwith open(file) as f:\n raw_text = f.read()\n\nprint(\"Splitting text into chunks and adding them to the Zep vector store.\")\ndocs = node_parser.get_nodes_from_documents(\n [Document(text=raw_text)], show_progress=True\n)\n\n# Convert nodes to ZepDocument\nzep_docs = [ZepDocument(content=d.get_content()) for d in docs]\nuuids = collection.add_documents(zep_docs)\nprint(f\"Added {len(uuids)} documents to collection {collection_name}\")\n\nprint(\"Waiting for documents to be embedded\")\nwhile True:\n c = client.document.get_collection(collection_name)\n print(\n \"Embedding status: \"\n f\"{c.document_embedded_count}/{c.document_count} documents embedded\"\n )\n time.sleep(1)\n if c.status == \"ready\":\n break\n\nquery = \"Was Babbage awarded a medal?\"\n\n# Using the ZepReader to load data from Zep\nreader = ZepReader(api_url=zep_api_url, api_key=\"optional_api_key\")\nresults = reader.load_data(\n collection_name=collection_name, query=query, top_k=3\n)\n\nprint(\"\\n\\n\".join([r.text for r in results]))\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "llama-index readers zep integration",
"version": "0.3.0",
"project_urls": null,
"split_keywords": [
"memory",
" retriever",
" storage",
" zep"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "779855bd284469f5f70e7c7860211af5a525d6eb82f27bb4faaaa0845bdee8a1",
"md5": "a58847d618c0a36a51cae24f6683c6ab",
"sha256": "8de71eb2261583a3bf0e90fd4ff171e449a7f1bbc34b350527f1fe35c799f987"
},
"downloads": -1,
"filename": "llama_index_readers_zep-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a58847d618c0a36a51cae24f6683c6ab",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9.0",
"size": 3713,
"upload_time": "2024-11-18T00:19:20",
"upload_time_iso_8601": "2024-11-18T00:19:20.206915Z",
"url": "https://files.pythonhosted.org/packages/77/98/55bd284469f5f70e7c7860211af5a525d6eb82f27bb4faaaa0845bdee8a1/llama_index_readers_zep-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e0c68ce9556dee7ec43e932643b40ce0cdfbaf13d21863b7b89ec5589734a8b1",
"md5": "cf943814574e1adf210657afcc489b2b",
"sha256": "4cd5b35b66fffe8c355dc558bf5f8dfc6d5f88a23158bcd9e9e744c188d40137"
},
"downloads": -1,
"filename": "llama_index_readers_zep-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "cf943814574e1adf210657afcc489b2b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9.0",
"size": 3451,
"upload_time": "2024-11-18T00:19:21",
"upload_time_iso_8601": "2024-11-18T00:19:21.846142Z",
"url": "https://files.pythonhosted.org/packages/e0/c6/8ce9556dee7ec43e932643b40ce0cdfbaf13d21863b7b89ec5589734a8b1/llama_index_readers_zep-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 00:19:21",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llama-index-readers-zep"
}