This repo is created within the scope of the CROssBARv2 project to convert natural language questions into Cypher query language. We leverage LangChain to construct Large Language Model (LLM) chains for the generation of Cypher queries and the subsequent parsing of the resulting output. Streamlit is employed to create an interactive user interface for this process.
First, ensure that you have poetry installed on your system.
poetry --version
If it's not installed, install via pip:
pip install -U poetry
To install the package:
poetry install
To get into the poetry virtual env:
If poetry version <2 :
poetry shell
If poetry version 2>= :
poetry env activate
pip install -r requirements.txt
To use this package, ensure that you have .env file present in the root folder of it. You should use the template below:
# Environment: 'development' (default) or 'production'
# See ENVIRONMENT.md for more details
CROSSBAR_ENV=development
OPENAI_API_KEY="sk-************************************************"
GEMINI_API_KEY="AI*****************-**-******-*********"
ANTHROPIC_API_KEY="sk-ant-***-***********************-****"
NVIDIA_API_KEY="nvapi-************************************"
GROQ_API_KEY="gsk_****************************************"
REPLICATE_API_KEY="***************************************"
NEO4J_USERNAME="user"
MY_NEO4J_PASSWORD="password"
NEO4J_DATABASE_NAME="neo4j"
NEO4J_URI="neo4j://localhost:7687"The CROssBAR-LLM application consists of two main components:
- Backend: FastAPI server that handles natural language to Cypher query conversion
- Frontend: React application providing the user interface
Backend Setup:
-
Navigate to the backend directory:
cd crossbar_llm/backend -
Run the FastAPI server:
# If using poetry poetry run uvicorn main:app --reload --host 0.0.0.0 --port 8000 # If using pip uvicorn main:app --reload --host 0.0.0.0 --port 8000
The backend API will be available at
http://localhost:8000
Frontend Setup:
-
In a new terminal, navigate to the frontend directory:
cd crossbar_llm/frontend -
Install dependencies:
npm install # or if using pnpm pnpm install -
Start the development server:
npm start # or if using pnpm pnpm startThe frontend will be available at
http://localhost:3000
-
Build the Docker image:
docker build -t crossbar-llm . -
Run the container:
docker run -p 8000:8000 -p 8501:8501 --env-file .env crossbar-llm
- Backend API:
http://localhost:8000 - Frontend:
http://localhost:8501
- Backend API:
If you have all dependencies installed locally, you can use the provided startup script:
./startup.shThis will start both the backend (port 8000) and frontend (port 8501) services.
-
Open your web browser and navigate to:
- Development mode:
http://localhost:3000 - Production/Docker mode:
http://localhost:8501
- Development mode:
-
In the interface, you can:
- Enter natural language questions about the CROssBAR knowledge graph
- View the generated Cypher queries
- See query results and visualizations
- Explore the knowledge graph relationships
-
Example queries you can try:
- "Show me all proteins related to cancer"
- "What drugs target EGFR?"
- "Find pathways associated with diabetes"
When the backend is running, you can access:
- Interactive API documentation:
http://localhost:8000/docs - Alternative API documentation:
http://localhost:8000/redoc
- Ensure Neo4j database is running and accessible at the URI specified in
.env - Check that all required API keys are properly set in the
.envfile - For CORS issues in development, ensure
CROSSBAR_ENV=developmentis set - If ports 8000 or 8501 are already in use, modify the port numbers in the respective commands
The application supports both development and production environments with different security settings:
- Development mode (default): Disables CSRF protection and rate limiting for easier local development
- Production mode: Enables full security features
For details on configuring the environment, see ENVIRONMENT.md.