This guide was tested with Neo4j 5.x and the SambaNova GraphRAG codebase v1.x. If you’re using different versions, some steps may vary.
Overview
This guide walks you through building a GraphRAG application using agents powered by SambaNova LLMs and Neo4j. GraphRAG is a structured, hierarchical approach to Retrieval Augmented Generation (RAG) that leverages graph relationships rather than plain text snippets. The sample application retrieves electronic health records for patients in the Synthea dataset. The agents use Neo4j’s graph query language (Cypher) to access records through two methods:- Static queries: Pre-defined Cypher queries for common operations.
- Dynamic queries: LLM-generated Cypher queries based on natural language input (text-to-Cypher).
Prerequisites
- A SambaCloud account and API key, or SambaStack deployment.
- Python 3.11 or later.
- UV package manager for Python dependency management.
- Neo4j database instance (local or cloud-hosted).
Setup
Install dependencies
-
Install the UV package manager.
-
Clone the integrations repository and navigate to the project directory.
-
Create a virtual environment and install dependencies.
Load the Synthea dataset
- Download the Synthea dataset dump file.
-
Load the dump file into your Neo4j instance. For Neo4j Desktop:
- Stop the database.
- Open the terminal for your database.
-
Run the following command, replacing the path with your download location:
- Start the database.
Configure environment variables
-
Copy the example environment file.
-
Edit
.envand set the following variables:
Run the application
Start the backend
Launch the HTTP server that connects to the Neo4j database using SambaNova LLMs.Open the frontend
Open your browser to the application landing page:Verify the connection
- In the chatbot interface, enter a test query such as “List all patients.”
- Confirm that the application returns patient records from the Neo4j database.
Capabilities
Once configured, the GraphRAG application enables:- Natural language queries: Ask questions about patient data in plain English.
- Graph traversal: Explore relationships between patients, conditions, medications, and encounters.
- Text-to-Cypher: Automatically generate Cypher queries from natural language input.
- Healthcare analytics: Analyze patterns across the Synthea dataset using graph-based insights.
Video demonstration
The following video demonstrates the GraphRAG application leveraging SambaNova LLMs to access healthcare data from a Neo4j database.Troubleshooting
| Issue | Solution |
|---|---|
Connection refused when starting backend | Verify Neo4j is running and the NEO4J_URI in .env is correct. |
| Authentication errors | Check that NEO4J_USERNAME and NEO4J_PASSWORD match your Neo4j credentials. |
SAMBANOVA_API_KEY not set error | Ensure your .env file exists and contains a valid API key from SambaCloud. |
| Empty query results | Confirm the Synthea dataset was loaded correctly. Run MATCH (n) RETURN count(n) in Neo4j Browser to verify data exists. |
ModuleNotFoundError | Ensure you activated the virtual environment: source .venv/bin/activate |
