llama-index-packs-neo4j-query-engine


Namellama-index-packs-neo4j-query-engine JSON
Version 0.4.0 PyPI version JSON
download
home_pageNone
Summaryllama-index packs neo4j_query_engine integration
upload_time2024-11-18 01:30:43
maintainerwenqiglantz
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9
licenseMIT
keywords knowledge graph neo4j query engine
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Neo4j Query Engine Pack

This LlamaPack creates a Neo4j query engine, and executes its `query` function. This pack offers the option of creating multiple types of query engines, namely:

- Knowledge graph vector-based entity retrieval (default if no query engine type option is provided)
- Knowledge graph keyword-based entity retrieval
- Knowledge graph hybrid entity retrieval
- Raw vector index retrieval
- Custom combo query engine (vector similarity + KG entity retrieval)
- KnowledgeGraphQueryEngine
- KnowledgeGraphRAGRetriever

## CLI Usage

You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:

```bash
llamaindex-cli download-llamapack Neo4jQueryEnginePack --download-dir ./neo4j_pack
```

You can then inspect the files at `./neo4j_pack` and use them as a template for your own project!

## Code Usage

You can download the pack to a `./neo4j_pack` directory:

```python
from llama_index.core.llama_pack import download_llama_pack

# download and install dependencies
Neo4jQueryEnginePack = download_llama_pack(
    "Neo4jQueryEnginePack", "./neo4j_pack"
)
```

From here, you can use the pack, or inspect and modify the pack in `./neo4j_pack`.

Then, you can set up the pack like so:

```bash
pip install llama-index-readers-wikipedia
```

```python
# Load the docs (example of Paleo diet from Wikipedia)

from llama_index.readers.wikipedia import WikipediaReader

loader = WikipediaReader()
docs = loader.load_data(pages=["Paleolithic diet"], auto_suggest=False)
print(f"Loaded {len(docs)} documents")

# get Neo4j credentials (assume it's stored in credentials.json)
with open("credentials.json") as f:
    neo4j_connection_params = json.load(f)
    username = neo4j_connection_params["username"]
    password = neo4j_connection_params["password"]
    url = neo4j_connection_params["url"]
    database = neo4j_connection_params["database"]

# create the pack
neo4j_pack = Neo4jQueryEnginePack(
    username=username, password=password, url=url, database=database, docs=docs
)
```

Optionally, you can pass in the `query_engine_type` from `Neo4jQueryEngineType` to construct `Neo4jQueryEnginePack`. If `query_engine_type` is not defined, it defaults to Knowledge Graph vector based entity retrieval.

```python
from llama_index.core.packs.neo4j_query_engine.base import Neo4jQueryEngineType

# create the pack
neo4j_pack = Neo4jQueryEnginePack(
    username=username,
    password=password,
    url=url,
    database=database,
    docs=docs,
    query_engine_type=Neo4jQueryEngineType.KG_HYBRID,
)
```

`Neo4jQueryEnginePack` is a enum defined as follows:

```python
class Neo4jQueryEngineType(str, Enum):
    """Neo4j query engine type"""

    KG_KEYWORD = "keyword"
    KG_HYBRID = "hybrid"
    RAW_VECTOR = "vector"
    RAW_VECTOR_KG_COMBO = "vector_kg"
    KG_QE = "KnowledgeGraphQueryEngine"
    KG_RAG_RETRIEVER = "KnowledgeGraphRAGRetriever"
```

The `run()` function is a light wrapper around `query_engine.query()`, see a sample query below.

```python
response = neo4j_pack.run("Tell me about the benefits of paleo diet.")
```

You can also use modules individually.

```python
# call the query_engine.query()
query_engine = neo4j_pack.query_engine
response = query_engine.query("query_str")
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-packs-neo4j-query-engine",
    "maintainer": "wenqiglantz",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "knowledge graph, neo4j, query engine",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/ee/a6/30323bc17e0233d38393d9828c6e050bda04ba055dd11f8bd2d30c533233/llama_index_packs_neo4j_query_engine-0.4.0.tar.gz",
    "platform": null,
    "description": "# Neo4j Query Engine Pack\n\nThis LlamaPack creates a Neo4j query engine, and executes its `query` function. This pack offers the option of creating multiple types of query engines, namely:\n\n- Knowledge graph vector-based entity retrieval (default if no query engine type option is provided)\n- Knowledge graph keyword-based entity retrieval\n- Knowledge graph hybrid entity retrieval\n- Raw vector index retrieval\n- Custom combo query engine (vector similarity + KG entity retrieval)\n- KnowledgeGraphQueryEngine\n- KnowledgeGraphRAGRetriever\n\n## CLI Usage\n\nYou can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package:\n\n```bash\nllamaindex-cli download-llamapack Neo4jQueryEnginePack --download-dir ./neo4j_pack\n```\n\nYou can then inspect the files at `./neo4j_pack` and use them as a template for your own project!\n\n## Code Usage\n\nYou can download the pack to a `./neo4j_pack` directory:\n\n```python\nfrom llama_index.core.llama_pack import download_llama_pack\n\n# download and install dependencies\nNeo4jQueryEnginePack = download_llama_pack(\n    \"Neo4jQueryEnginePack\", \"./neo4j_pack\"\n)\n```\n\nFrom here, you can use the pack, or inspect and modify the pack in `./neo4j_pack`.\n\nThen, you can set up the pack like so:\n\n```bash\npip install llama-index-readers-wikipedia\n```\n\n```python\n# Load the docs (example of Paleo diet from Wikipedia)\n\nfrom llama_index.readers.wikipedia import WikipediaReader\n\nloader = WikipediaReader()\ndocs = loader.load_data(pages=[\"Paleolithic diet\"], auto_suggest=False)\nprint(f\"Loaded {len(docs)} documents\")\n\n# get Neo4j credentials (assume it's stored in credentials.json)\nwith open(\"credentials.json\") as f:\n    neo4j_connection_params = json.load(f)\n    username = neo4j_connection_params[\"username\"]\n    password = neo4j_connection_params[\"password\"]\n    url = neo4j_connection_params[\"url\"]\n    database = neo4j_connection_params[\"database\"]\n\n# create the pack\nneo4j_pack = Neo4jQueryEnginePack(\n    username=username, password=password, url=url, database=database, docs=docs\n)\n```\n\nOptionally, you can pass in the `query_engine_type` from `Neo4jQueryEngineType` to construct `Neo4jQueryEnginePack`. If `query_engine_type` is not defined, it defaults to Knowledge Graph vector based entity retrieval.\n\n```python\nfrom llama_index.core.packs.neo4j_query_engine.base import Neo4jQueryEngineType\n\n# create the pack\nneo4j_pack = Neo4jQueryEnginePack(\n    username=username,\n    password=password,\n    url=url,\n    database=database,\n    docs=docs,\n    query_engine_type=Neo4jQueryEngineType.KG_HYBRID,\n)\n```\n\n`Neo4jQueryEnginePack` is a enum defined as follows:\n\n```python\nclass Neo4jQueryEngineType(str, Enum):\n    \"\"\"Neo4j query engine type\"\"\"\n\n    KG_KEYWORD = \"keyword\"\n    KG_HYBRID = \"hybrid\"\n    RAW_VECTOR = \"vector\"\n    RAW_VECTOR_KG_COMBO = \"vector_kg\"\n    KG_QE = \"KnowledgeGraphQueryEngine\"\n    KG_RAG_RETRIEVER = \"KnowledgeGraphRAGRetriever\"\n```\n\nThe `run()` function is a light wrapper around `query_engine.query()`, see a sample query below.\n\n```python\nresponse = neo4j_pack.run(\"Tell me about the benefits of paleo diet.\")\n```\n\nYou can also use modules individually.\n\n```python\n# call the query_engine.query()\nquery_engine = neo4j_pack.query_engine\nresponse = query_engine.query(\"query_str\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index packs neo4j_query_engine integration",
    "version": "0.4.0",
    "project_urls": null,
    "split_keywords": [
        "knowledge graph",
        " neo4j",
        " query engine"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a41185c1f0721da05e61cb62543438ceddee13be8ea67015835343a2d1e40076",
                "md5": "b06a9551e352e8de1f9ff6b1464cb61c",
                "sha256": "8d8f702bdc1545ba53879ce753108394695d26b5a61b12d5cd99be7b52090830"
            },
            "downloads": -1,
            "filename": "llama_index_packs_neo4j_query_engine-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b06a9551e352e8de1f9ff6b1464cb61c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 4805,
            "upload_time": "2024-11-18T01:30:43",
            "upload_time_iso_8601": "2024-11-18T01:30:43.066246Z",
            "url": "https://files.pythonhosted.org/packages/a4/11/85c1f0721da05e61cb62543438ceddee13be8ea67015835343a2d1e40076/llama_index_packs_neo4j_query_engine-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eea630323bc17e0233d38393d9828c6e050bda04ba055dd11f8bd2d30c533233",
                "md5": "259da37b1d45c11a3fd5716b827d25c6",
                "sha256": "00db7f86c073952696683d64acb85c28109279b931271618097feacd35ea8b47"
            },
            "downloads": -1,
            "filename": "llama_index_packs_neo4j_query_engine-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "259da37b1d45c11a3fd5716b827d25c6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 4375,
            "upload_time": "2024-11-18T01:30:43",
            "upload_time_iso_8601": "2024-11-18T01:30:43.944374Z",
            "url": "https://files.pythonhosted.org/packages/ee/a6/30323bc17e0233d38393d9828c6e050bda04ba055dd11f8bd2d30c533233/llama_index_packs_neo4j_query_engine-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-18 01:30:43",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-packs-neo4j-query-engine"
}
        
Elapsed time: 0.56954s