DS 246: Agentic & Generative AI Project
GraphIQ is an agentic AI system designed to extract knowledge from documents, represent it as a graph, and enable context-aware question answering using both vector search and structured graph reasoning.
At a high level, the project ingests PDFs or text documents, breaks them into meaningful chunks, summarizes them, extracts entities and relationships, stores everything in Neo4j, and exposes APIs for exploration and chat-based interaction.
Make a .env in root and put the following values in it.
NEO4J_URI=<Value>
NEO4J_USERNAME=<Value>
NEO4J_PASSWORD=<Value>
NEO4J_DATABASE=<Value>
AURA_INSTANCEID=<Value>
AURA_INSTANCENAME=<Value>
OPENROUTER_API_KEY=<Value>
GEMINI_API_KEY=<Value>- Go to https://openrouter.ai/models?max_price=0 and pick whichever model is required, copy it's 'model_id'.
- Check
openrouter.ipynbon how to run chat completetion. - For embedding code blocks, don't change
modelparameter. - You can check documentation for https://openrouter.ai/docs/quickstart#using-the-openai-sdk and [https://ai.google.dev/gemini-api/docs/embeddings](Gemini Embedding).
- You can use Gemini for generation as well, just make sure the code produces appropriate output.
- Check
neo4j.ipynbfor some examples - They are all taken from [https://neo4j.com/docs/python-manual/current/query-simple/](Neo4j Documentation)
- Use
with GraphDatabase.driver(URI, auth=AUTH) as driver:always before running any query.
It is recommended to make a virtual environment.
cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python main.pyMake sure backend is running as frontend takes some information from backend.
cd frontend
pnpm install
pnpm devGraphIQ/
├── backend/
│ │
│ ├── main.py # Fastapi endpoints and logic are defined here
│ ├── services.py # VectorDB, GraphDB classes and
│ │ clients for Openrouter and Gemini are initialized here
│ ├── db.py # VectorDB and GraphDB class definitions
│ ├── utils.py # Extra functions required for chunking, context formatting
│ ├── schema.py # Pydantic schemas for some agents
│ ├── prompts.py # All system prompts and user prompts are defined here
│ ├── agents.py # All core agentic workflows are defined here
│
├── frontend/
│ ├── client
│ │ ├── components
│ │ │ ├── ChatPane.tsx # Logic and structure of chatbot
│ │ │ ├── GraphPane.tsx # Logic and structure of how the graph is displayed
│
├── test/ # Some test files used to verify agent logic
├── .gitignore
├── neo4j.ipynb # Some sample code for neo4j graph SB
├── openrouter.ipynb # Some sample code for openrouter and gemini embedding model
├── README.md
├── requirements.txt # Python library requirements
├── start.bat # Can be used to run both frontend and backend directly,
│ given that node_modules are installed and venv is active
├── .env # Needs to be created. Will be used for all keys