Ide di balik repositori ini adalah untuk membuat chatbot sadar konteks yang dapat membaca dan memperbarui database Neo4j. Cypher dihasilkan menggunakan titik akhir GPT-4, sedangkan jawabannya dihasilkan dengan model gpt-3.5-turbo berdasarkan informasi dari database.
Pelajari lebih lanjut: https://medium.com/neo4j/context-aware-knowledge-graph-chatbot-with-gpt-4-and-neo4j-d3a99e8ae21e
Proyek ini menggunakan proyek Rekomendasi yang tersedia sebagai bagian dari Neo4j Sandbox. Jika Anda menginginkan instance lokal Neo4j, Anda dapat memulihkan dump database yang tersedia di sini.
Pastikan untuk mengisi variabel lingkungan seperti yang ditunjukkan dalam file .env.example
Jalankan proyek menggunakan
docker-compose up
lalu buka alamat localhost:8501 di browser favorit Anda
Anda dapat menggunakan contoh berikut untuk mendapatkan gambaran tentang kemampuan chatbot ini
# 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