Giter Club home page Giter Club logo

neogpt-recommender's Introduction

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

neogpt-recommender's People

Contributors

tomasonjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neogpt-recommender's Issues

"Cannot resolve address {}".format(address)) chatbot | ValueError: Cannot resolve address URL:7687

Hi @tomasonjo

Cloned the project:

git clone https://github.com/tomasonjo/NeoGPT-Recommender.git

and do have:
.env
OPENAI_KEY=<MY_OPENAI_API_KEY>
NEO4J_URL=bolt://URL:7687
NEO4J_USER="neo4j"
NEO4J_PASS=<MY_PASSWORD>

neo start

Running locally in a Mac OSX host machine

But after docker-compose up

raise ValueError("Cannot resolve address {}".format(address))
chatbot | ValueError: Cannot resolve address URL:7687

  1. Are you manually creating the database up front via Cypher commands and then using GPT4 to translate user queries into Cypher commands?

or:

  1. Using user queries for both the database creation as well as the queries?

Also don't see anywhere entities are actually created with for example:

CREATE (pfiz: Company {name: 'Pfizer'})

as I would like to create my own dataset

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.