This project builds a multi-level supply chain graph with product reviews for root cause analysis using LangChain and Neo4j.
- Python 3.11
- Conda (Miniconda or Anaconda)
- Neo4j database (can be run via Docker)
- Create and activate the conda environment:
conda create -n ai python=3.11 -y
conda activate ai- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
Copy the
.envfile and add your OpenAI API key:
# Edit .env file and add your OpenAI API key
OPENAI_API_KEY=your-actual-api-key-here- Start Neo4j (if using Docker):
docker-compose up -dconda activate ai
python main.py- User Intent Understanding: Understands knowledge graph requirements
- File Discovery: Automatically discovers and selects relevant files
- Schema Design: Designs schema for structured data (CSV)
- Entity Extraction: Extracts entities from unstructured data (Markdown)
- Graph Construction: Builds the knowledge graph in Neo4j
The main configuration options are in the .env file:
NEO4J_URI: Neo4j connection URINEO4J_USER: Neo4j usernameNEO4J_PASSWORD: Neo4j passwordOPENAI_API_KEY: OpenAI API keyOPENAI_BASE_URL: (Optional) Custom OpenAI-compatible endpointDATA_DIR: Directory containing data files
kg-experiment/
├── main.py # Main pipeline script
├── requirements.txt # Python dependencies
├── .env # Environment variables
├── docker-compose.yaml # Neo4j Docker setup
├── data/ # Data directory for CSV and Markdown files
└── notebooks/ # Jupyter notebooks for experiments