langchain/templates/neo4j-cypher-ft
David Duong d39b4b61b6
Batch apply poetry lock --no-update for all templates (#12531)
Ran the following bash script for all templates

```bash
#!/bin/bash

set -e
current_dir="$(pwd)"
for directory in */; do
    if [ -d "$directory" ]; then
        (cd "$directory" && poetry lock --no-update)
    fi
done

cd "$current_dir"
```

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-30 15:18:53 -07:00
..
neo4j_cypher_ft Format Templates (#12396) 2023-10-26 19:44:30 -07:00
tests Templates (#12294) 2023-10-25 18:47:42 -07:00
ingest.py notebook fmt (#12498) 2023-10-29 15:50:09 -07:00
main.py Templates (#12294) 2023-10-25 18:47:42 -07:00
poetry.lock Batch apply poetry lock --no-update for all templates (#12531) 2023-10-30 15:18:53 -07:00
pyproject.toml various templates improvements (#12500) 2023-10-28 22:13:22 -07:00
README.md Update neo4j template readmes (#12540) 2023-10-30 07:57:53 -07:00

Neo4j Knowledge Graph: Enhanced mapping from text to database using a full-text index

This template allows you to chat with Neo4j graph database in natural language, using an OpenAI LLM. Its primary purpose is to convert a natural language question into a Cypher query (which is used to query Neo4j databases), execute the query, and then provide a natural language response based on the query's results. The addition of the full-text index ensures efficient mapping of values from text to database for more precise Cypher statement generation. In this example, full-text index is used to map names of people and movies from the user's query with corresponding database entries.

Neo4j database

There are a number of ways to set up a Neo4j database.

Neo4j Aura

Neo4j AuraDB is a fully managed cloud graph database service. Create a free instance on Neo4j Aura. When you initiate a free database instance, you'll receive credentials to access the database.

Environment variables

You need to define the following environment variables

OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
NEO4J_URI=<YOUR_NEO4J_URI>
NEO4J_USERNAME=<YOUR_NEO4J_USERNAME>
NEO4J_PASSWORD=<YOUR_NEO4J_PASSWORD>

Populating with data

If you want to populate the DB with some example data, you can run python ingest.py. This script will populate the database with sample movie data. Additionally, it will create an full-text index named entity, which is used to map person and movies from user input to database values for precise Cypher statement generation.

Installation

# from inside your LangServe instance
poe add neo4j-cypher-ft