• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Context-aware knowledge-graph based chatbot using GPT4 and Neo4j

NeoGPT-Recommender

Idea behind this repository is to create a context-aware chatbot that can read from and update a Neo4j database. The Cypher is generated using GPT-4 endpoint, while the answers are generated with gpt-3.5-turbo model based on the information from the database.

Learn more: https://medium.com/neo4j/context-aware-knowledge-graph-chatbot-with-gpt-4-and-neo4j-d3a99e8ae21e

Neo4j database

The project uses the Recommendation project that is available as part of the Neo4j Sandbox. If you want a local instance of Neo4j, you can restore a database dump that is available here.

Environment variables

Make sure to populate the environment variables as shown in the .env.example file

Start the project

Run the project using

docker-compose up

and then open the localhost:8501 address in your favourite browser

Chatbot

Training examples for the english2cypher part

You can use the following example to get an idea what this chatbot is capable of

# I don't like comedy
MATCH (u:User {id: $userId}), (g:Genre {name:"Comedy"})
MERGE (u)-[:DISLIKE_GENRE]->(g)
RETURN distinct {answer: 'noted'} AS result
# I like comedy
MATCH (u:User {id: $userId}), (g:Genre {name:"Comedy"})
MERGE (u)-[:LIKE_GENRE]->(g)
RETURN distinct {answer: 'noted'} AS result
# I have already watched Top Gun
MATCH (u:User {id: $userId}), (m:Movie {title:"Top Gun"})
MERGE (u)-[:WATCHED]->(m)
RETURN distinct {answer: 'noted'} AS result
# I like Top Gun
MATCH (u:User {id: $userId}), (m:Movie {title:"Top Gun"})
MERGE (u)-[:LIKE_MOVIE]->(m)
RETURN distinct {answer: 'noted'} AS result
# What is a good comedy?
MATCH (u:User {id:$userId}), (m:Movie)-[:IN_GENRE]->(:Genre {name:"Comedy"})
WHERE NOT EXISTS {(u)-[:WATCHED]->(m)}
RETURN {movie: m.title} AS result
ORDER BY m.imdbRating DESC LIMIT 1
# Who played in Top Gun?
MATCH (m:Movie)<-[:ACTED_IN]-(a)
RETURN {actor: a.name} AS result
# What is the plot of the Copycat movie?
MATCH (m:Movie {title: "Copycat"})
RETURN {plot: m.plot} AS result
# Did Luis Guzmán appear in any other movies?
MATCH (p:Person {name:"Luis Guzmán"})-[:ACTED_IN]->(movie)
RETURN {movie: movie.title} AS result
# Do you know of any matrix movies?
MATCH (m:Movie)
WHERE toLower(m.title) CONTAINS toLower("matrix")
RETURN {movie:m.title} AS result
# Which movies do I like?
MATCH (u:User {id: $userId})-[:LIKE_MOVIE]->(m:Movie)
RETURN {movie:m.title} AS result
# Recommend a movie
MATCH (u:User {id: $userId})-[:LIKE_MOVIE]->(m:Movie)
MATCH (m)<-[r1:RATED]-()-[r2:RATED]->(otherMovie)
WHERE r1.rating > 3 AND r2.rating > 3 AND NOT EXISTS {(u)-[:WATCHED|LIKE_MOVIE|DISLIKE_MOVIE]->(otherMovie)}
WITH otherMovie, count(*) AS count
ORDER BY count DESC
LIMIT 1
RETURN {recommended_movie:otherMovie.title} AS result

More Repositories

1

blogs

Jupyter notebooks that support my graph data science blog posts at https://bratanic-tomaz.medium.com/
Jupyter Notebook
1,319
star
2

llm-movieagent

Semantic layer on top of a graph database to provide an LLM with a set of robust tools to interact with the database
Python
196
star
3

NeoGPT-Explorer

Knowledge-graph based chatbot using GPT3 and Neo4j
Jupyter Notebook
184
star
4

diffbot-kg-chatbot

Knowledge graph construction and RAG demo using Diffbot and Neo4j
Jupyter Notebook
148
star
5

trinity-ie

Information extraction pipeline containing coreference resolution, named entity linking, and relationship extraction
Python
80
star
6

graphs-network-science

Accompanying repository for my book about Graph Data Science
Jupyter Notebook
64
star
7

streamlit-neo4j-hackathon

Python
39
star
8

cypher-direction-competition

Repository that hold the information about the competition about validating and fixing relationship direction in Cypher statements based on the given schema
26
star
9

bitcoin-to-neo4jdash

Project that listens to bitcoin websocket API for new transactions and stores them to Neo4j to be analyzed
Python
24
star
10

blog-datasets

23
star
11

neo4j-hp-viz

Demo App that uses GRANDstack to visualize Harry Potter network
JavaScript
18
star
12

clinical-agent

This project is designed for a simple LLM agent with tools on a clinical knowledge graph in Neo4j.
Python
16
star
13

neo4j-game-of-thrones

HTML
9
star
14

grand-sigmaJS

Network visualizations with SigmaJS and GrandStack (GraphQL + React + Apollo + Neo4j)
JavaScript
8
star
15

SpaCIE

Python
7
star
16

hospitals-neo4j

HTML
5
star
17

neo4j-multimodal-rag

4
star
18

kg-rag

Supporting repository for the Knowledge Graph Enhanced RAG book published by Manning
Jupyter Notebook
2
star