Prompt Chain

Query Neo4j Knowledge Graphs with LlamaIndex

Neo4j Query Engine Pack: Creates a Neo4j query engine and executes its query function.

Works with neo4jwikipedia

57
Spark score
out of 100
Updated 4 days ago
Version 0.14.22
Models

Add to Favorites

Why it matters

Leverage your Neo4j knowledge graph to answer complex questions by integrating with LlamaIndex. This pack provides flexible query engines for diverse data retrieval needs.

Outcomes

What it gets done

01

Connect to Neo4j databases with provided credentials.

02

Build various query engines: vector-based, keyword-based, hybrid, or raw vector retrieval.

03

Execute queries against your knowledge graph and retrieve relevant information.

04

Integrate with external data sources like Wikipedia for enriched context.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-pack-packs-neo4j-query-engine | bash

Steps

Steps in the chain

01
Download Neo4jQueryEnginePack

Download the Neo4jQueryEnginePack using llamaindex-cli with the command: llamaindex-cli download-llamapack Neo4jQueryEnginePack --download-dir ./neo4j_pack. Inspect the files at ./neo4j_pack and use them as a template for your own project.

02
Install dependencies

Install required dependencies using pip install llama-index-readers-wikipedia to enable loading documents from Wikipedia.

03
Load documents

Load documents using WikipediaReader. Example: loader = WikipediaReader(); docs = loader.load_data(pages=["Paleolithic diet"], auto_suggest=False). Print the number of loaded documents.

04
Get Neo4j credentials

Load Neo4j connection parameters from credentials.json file. Extract username, password, url, and database fields from the JSON file.

05
Create the pack

Instantiate Neo4jQueryEnginePack with Neo4j credentials and loaded documents: neo4j_pack = Neo4jQueryEnginePack(username=username, password=password, url=url, database=database, docs=docs). Optionally specify query_engine_type parameter.

06
Execute query

Run a query using the pack's run() function: response = neo4j_pack.run("Tell me about the benefits of paleo diet."). Alternatively, access query_engine directly and call query_engine.query("query_str").

Overview

Neo4j Query Engine Pack

What it does

This LlamaPack creates a Neo4j query engine and executes its `query` function. It supports multiple query engine types, including knowledge graph vector-based entity retrieval (default), 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`, and `KnowledgeGraphRAGRetriever`.

How it connects

Use this pack to create and execute a Neo4j query engine. It is suitable for scenarios requiring various knowledge graph querying strategies. Do not use this pack if you do not have a Neo4j database set up.

Source README

Description pending for li-pack-packs-neo4j-query-engine.

Step 1: Download Neo4jQueryEnginePack

Download the Neo4jQueryEnginePack using llamaindex-cli with the command: llamaindex-cli download-llamapack Neo4jQueryEnginePack --download-dir ./neo4j_pack. Inspect the files at ./neo4j_pack and use them as a template for your own project.

Step 2: Install dependencies

Install required dependencies using pip install llama-index-readers-wikipedia to enable loading documents from Wikipedia.

Step 3: Load documents

Load documents using WikipediaReader. Example: loader = WikipediaReader(); docs = loader.load_data(pages=["Paleolithic diet"], auto_suggest=False). Print the number of loaded documents.

Step 4: Get Neo4j credentials

Load Neo4j connection parameters from credentials.json file. Extract username, password, url, and database fields from the JSON file.

Step 5: Create the pack

Instantiate Neo4jQueryEnginePack with Neo4j credentials and loaded documents: neo4j_pack = Neo4jQueryEnginePack(username=username, password=password, url=url, database=database, docs=docs). Optionally specify query_engine_type parameter.

Step 6: Execute query

Run a query using the pack's run() function: response = neo4j_pack.run("Tell me about the benefits of paleo diet."). Alternatively, access query_engine directly and call query_engine.query("query_str").

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.