This kit provides a simple FastAPI backend service connected to OpenAI and Neo4j for powering GenAI projects. The Neo4j interface leverages both Vector Indexes and Text2Cypher chains to provide more accurate results.
- Poetry for virtual enviroment management
- LangChain
- An OpenAI API Key
- A running local or cloud Neo4j database
NEO4J_URI=neo4j+ssc://9fcf58c6.databases.neo4j.io \
NEO4J_DATABASE=neo4j \
NEO4J_USERNAME=public \
NEO4J_PASSWORD=read_only \
OPENAI_API_KEY=<add_your_openai_key_here> \
poetry run uvicorn app.server:app --reload --port=8000 --log-config=log_conf.yaml
NOTE the above Neo4j credentials are for read-only access to a hosted sample dataset. Your own OpenAI api key will be needed to run this server.
NOTE the NEO4J_URI
value can use either the neo4j or bolt uri scheme. For more details on which to use, see this example
A FastAPI server should now be running on your local port 8000/api/chat.
If you would like to load your own instance with a subset of this information. Add your own OpenAI key to the Cypher code in the edgar_import.cypher file and run it in your instance's Neo4j browser.
For more information on how this load script works, see this notebook.
FastAPI will make endpoint information and the ability to test from a browser at http://localhost:8000/docs
Alternatively, after the server is running, a curl command can be triggered to test the endpoint:
curl --location 'http://127.0.0.1:8000/api/chat' \
--header 'Content-Type: application/json' \
--data '{
"message":"How many forms are there?"}'
Please provide feedback and report bugs as GitHub issues
Want to improve this kit? See the contributing guide
At Neo4j GraphAcademy, we offer a wide range of courses completely free of charge, including Neo4j & LLM Fundamentals and Build a Neo4j-backed Chatbot using Python.