llama-index-readers-zep


Namellama-index-readers-zep JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
Summaryllama-index readers zep integration
upload_time2024-08-22 10:44:46
maintainerzep
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9.0
licenseMIT
keywords memory retriever storage zep
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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/c3/96/835d99a70f34aff614d982a6e8ad2810aa48c924e6d21e4c37b6343582ae/llama_index_readers_zep-0.2.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.2.0",
    "project_urls": null,
    "split_keywords": [
        "memory",
        " retriever",
        " storage",
        " zep"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "65fb4bf998de8a374513428c5afe3db7b29c32cb6275f3662517412629732515",
                "md5": "cb970d7cdc0882b104524f375aa312eb",
                "sha256": "5886650bfa0f6511f9c5645fc1f2eac38c9c5a85cadb88de3a5306633c967c65"
            },
            "downloads": -1,
            "filename": "llama_index_readers_zep-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cb970d7cdc0882b104524f375aa312eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9.0",
            "size": 3714,
            "upload_time": "2024-08-22T10:44:45",
            "upload_time_iso_8601": "2024-08-22T10:44:45.431217Z",
            "url": "https://files.pythonhosted.org/packages/65/fb/4bf998de8a374513428c5afe3db7b29c32cb6275f3662517412629732515/llama_index_readers_zep-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c396835d99a70f34aff614d982a6e8ad2810aa48c924e6d21e4c37b6343582ae",
                "md5": "c05e77375c6cd4a7b12734749f4f6f19",
                "sha256": "a77d2b87b4efa7563c7644a1ea9880c3edbd0e1e4ab97945f92aed2b533520fa"
            },
            "downloads": -1,
            "filename": "llama_index_readers_zep-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c05e77375c6cd4a7b12734749f4f6f19",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9.0",
            "size": 3478,
            "upload_time": "2024-08-22T10:44:46",
            "upload_time_iso_8601": "2024-08-22T10:44:46.797597Z",
            "url": "https://files.pythonhosted.org/packages/c3/96/835d99a70f34aff614d982a6e8ad2810aa48c924e6d21e4c37b6343582ae/llama_index_readers_zep-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-22 10:44:46",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-zep"
}
        
Elapsed time: 0.37541s