PetroMind is an enterprise-grade, autonomous multi-agent AI system designed specifically for the Oil and Natural Gas Corporation (ONGC) and upstream/downstream energy sectors. By combining specialized domain agents with local Parent-Child Retrieval-Augmented Generation (RAG), secure quantitative execution sandboxes, and Model Context Protocol (MCP) tool integrations, PetroMind delivers rigorous technical research, regulatory compliance audits, HSE risk matrices, and production/economic forecasting.
All inference is executed securely through ONGC ModelHub (google/gemma-4-26B-A4B-it) ensuring complete data sovereignty, high accuracy, and zero external data leakage.
StateGraph):
Uses stateful graph routing where a Supervisor Agent intelligently classifies user intent (research, regulation, risk, data, or mixed) and assigns tailored tasks to domain specialists in canonical or parallel execution order.LLM_MAX_ATTEMPTS).human_approval_node), allowing engineers and regulatory experts to inspect confidence scores, compliance findings, and risk matrices on the web dashboard.Qwen/Qwen3-Embedding-8B / jina-reranker-v3) in Qdrant (localhost:6444) for hyper-accurate semantic retrieval.vectordb_search.py): Searches over Indian petroleum codes (PNGRB, OISD, DGMS, MoPNG), US BSEE standards, SPE technical literature, and Volve field datasets.tavily_search.py): Retrieves up-to-the-minute global market intelligence and academic literature.eia_api.py, worldbank_api.py): Queries official U.S. Energy Information Administration datasets and World Bank indicators with local filesystem caching (.eia_cache).python_repl.py): Executes complex petroleum engineering formulas, PVT calculations, and financial modeling in a sandboxed environment._throttle) and controlled backoff schedules (LLM_BACKOFF_SCHEDULE) to handle high-concurrency multi-agent bursts without triggering ModelHub HTTP 429 rate limits.graph TD
User([User / Web UI]) -->|Query & Parameters| API[FastAPI Async Backend]
API -->|Initialize State| START((START))
subgraph LangGraph Multi-Agent Orchestration
START --> Supervisor[Supervisor Agent<br/>Intent Classification & Routing]
Supervisor -->|Research Task| Research[Research Agent<br/>SPE & Literature RAG]
Supervisor -->|Regulation Task| Regulation[Regulation Agent<br/>PNGRB / OISD / DGMS Compliance]
Supervisor -->|Risk Task| Risk[Risk Agent<br/>5x5 Risk Matrix & HSE Hazards]
Supervisor -->|Data Task| Data[Data Agent<br/>REPL Sandbox / EIA / Statistics]
Research --> Critic[Critic Agent<br/>Hallucination & Citation Audit]
Regulation --> Critic
Risk --> Critic
Data --> Critic
Critic -->|NEEDS_REVISION<br/>(Up to 3x)| Supervisor
Critic -->|PASS| HITL{Human-in-the-Loop<br/>Approval Checkpoint}
end
HITL -->|Operator Approved| Report[Report Agent<br/>Executive Markdown / JSON / PDF]
Report -->|Final Deliverable| END((END))
subgraph Local MCP & Data Layer
Research -.->|Query| VectorDB[(Qdrant Vector DB<br/>Parent-Child Chunks)]
Regulation -.->|Check Standards| VectorDB
Risk -.->|Accident History| VectorDB
Data -.->|Execute Code| REPL[Python REPL Sandbox]
Data -.->|Fetch Data| APIs[EIA / World Bank Caches]
end
| Agent Name | Script | Responsibility & Specialization |
|---|---|---|
| π Supervisor | agents/supervisor.py | Deconstructs user queries, identifies required domains (research, regulation, risk, data), assigns specific sub-prompts, and orchestrates execution flow. |
| π Research | agents/research_agent.py | Queries vectordb_search and tavily_search to synthesize petroleum geology, reservoir engineering (EOR/IOR), drilling dynamics, and SPE paper insights. |
| βοΈ Regulation | agents/regulation_agent.py | Audits projects against Indian PNGRB (Petroleum & Natural Gas Regulatory Board), OISD (Oil Industry Safety Directorate), DGMS (Directorate General of Mines Safety), and MoPNG guidelines. Generates structured [COMPLIANT], [NON_COMPLIANT], and [REQUIRES_REVIEW] checklists. |
| β οΈ Risk | agents/risk_agent.py | Identifies process safety hazards, offshore/onshore historical failure modes (BSEE, DGMS accident databases), and outputs standardized 5x5 quantitative Risk Matrices (Severity Γ Likelihood). |
| π Data | agents/data_agent.py | Performs quantitative analysis using local Python REPL calculations, oil/gas unit conversions (TBPD, MMscfd, BOE), and live queries to EIA and World Bank statistical endpoints. |
| π Critic | agents/critic_agent.py | Acts as the quality gatekeeper. Scores responses for citation rigor, numerical accuracy, and regulatory completeness before allowing report generation. |
| π Report | agents/report_agent.py | Aggregates all verified agent findings into polished executive briefings, interactive web dashboards, and downloadable PDF documents. |
step1 to step5)The project includes an automated 5-step data preparation and embedding pipeline located in the root directory:
# 1. Initialize Qdrant collections with optimized vector dimensions and HNSW indices
python step1_setup_collections.py
# 2. Extract raw text from complex PDFs, Word documents, and reports inside source_data/
python step2_extract_text.py
# 3. Run Parent-Child quality-filtered chunking (~3,200 char parents / ~800 char children)
python step3_chunk.py
# 4. Generate embeddings via Qwen3-Embedding-8B / Jina and ingest into local Qdrant
python step4_embed_and_store.py
# 5. Execute RAG validation benchmarks and quality checks (Ragas metrics)
python step5_validate.py
3.10 or higher (3.11 recommended)18.x or higher (with npm or pnpm)localhost:6444 (or Docker: docker run -p 6444:6333 qdrant/qdrant)Clone the repository and copy the example environment file:
cp .env.example .env
Edit .env and configure your credentials:
ONGC_API_BASE_URL=https://modelhub.ongc.co.in/v1
ONGC_API_KEY=your_ongc_modelhub_api_key
EMBEDDING_MODEL=Qwen/Qwen3-Embedding-8B
QDRANT_HOST=localhost
QDRANT_PORT=6444
TAVILY_API_KEY=your_tavily_key
EIA_API_KEY=your_eia_key
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=PetroMind
Activate your virtual environment and install dependencies:
# Create and activate virtual environment (if not already created)
python -m venv petromind_env
# On Windows:
petromind_env\Scripts\activate
# On Linux/Mac:
source petromind_env/bin/activate
# Install Python requirements
pip install -r backend/requirements.txt
Install dependencies for the Vite web interface:
cd frontend
npm install
# or: pnpm install
cd ..
Run the backend server from the project root directory:
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload
http://localhost:8000/docshttp://localhost:8000/api/reportsIn a separate terminal window, launch the interactive web studio:
cd frontend
npm run dev
http://localhost:5173ongc/
βββ agents/ # π€ Core LangGraph Multi-Agent Implementation
β βββ config.py # Centralized ModelHub & LLM configuration
β βββ graph.py # LangGraph StateGraph, routing & HITL interrupt
β βββ state.py # PetroMindState schema & logging events
β βββ supervisor.py # Supervisor routing agent
β βββ research_agent.py # Technical literature & SPE RAG agent
β βββ regulation_agent.py # Indian (PNGRB/OISD/DGMS) & global compliance agent
β βββ risk_agent.py # HSE hazard identification & 5x5 Risk Matrix agent
β βββ data_agent.py # Quantitative analyst, REPL & EIA statistics agent
β βββ critic_agent.py # Quality audit & hallucination verification agent
β βββ report_agent.py # Executive markdown, JSON & PDF report generator
βββ backend/ # βοΈ FastAPI Async Server & Job Orchestration
β βββ main.py # API routes (/api/reports, PDF downloads)
β βββ runner.py # JobManager, asynchronous runners & SSE updates
β βββ schemas.py # Pydantic request/response models
βββ frontend/ # π¨ Modern Vite Studio Web Interface
β βββ index.html # Main application layout
β βββ app.js # State synchronization, graphs & UI rendering
β βββ styles.css # Rich dark-mode design system & animations
β βββ package.json # Frontend dependencies & scripts
βββ mcp_servers/ # π Model Context Protocol Tools
β βββ vectordb_search.py # Local Qdrant semantic search engine
β βββ tavily_search.py # Live web technical intelligence search
β βββ eia_api.py # U.S. EIA energy statistics client + cache
β βββ worldbank_api.py # World Bank global economic data client
β βββ pdf_reader.py # PDF text & layout extractor
β βββ python_repl.py # Sandboxed Python mathematical calculation engine
βββ utils/ # π οΈ Shared Utilities & Logging
β βββ logger.py # Token consumption & execution latency logger
β βββ reranker.py # Jina Reranker v3 late-interaction integration
βββ step1_setup_collections.py # RAG Step 1: Qdrant schema setup
βββ step2_extract_text.py # RAG Step 2: Multi-format text extraction
βββ step3_chunk.py # RAG Step 3: Parent-Child hierarchical chunking
βββ step4_embed_and_store.py # RAG Step 4: Batch embedding & vector storage
βββ step5_validate.py # RAG Step 5: Automated benchmark validation
βββ try.py # Standalone pipeline/chunking experiment script
βββ .env.example # Example environment variables template
βββ .gitignore # Comprehensive rules ignoring large data & secrets
βββ README.md # Project documentation
ONGC_API_KEY, etc.) are strictly isolated via .env / Kubernetes secrets and excluded from version control.python_repl) operates inside a controlled, read-only calculation scope preventing arbitrary system calls or unauthorized filesystem writes.Internal Proprietary Software developed for Oil and Natural Gas Corporation (ONGC) & PetroMind Initiatives. All rights reserved.
2 commits
Python
82.4%
JavaScript
8.2%
HTML
7.4%
CSS
2.1%
PetroMind is an enterprise-grade, autonomous multi-agent AI system designed specifically for the Oil and Natural Gas Corporation (ONGC) and upstream/downstream energy sectors. By combining specialized domain agents with local Parent-Child Retrieval-Augmented Generation (RAG), secure quantitative execution sandboxes, and Model Context Protocol (MCP) tool integrations, PetroMind delivers rigorous technical research, regulatory compliance audits, HSE risk matrices, and production/economic forecasting.
All inference is executed securely through ONGC ModelHub (google/gemma-4-26B-A4B-it) ensuring complete data sovereignty, high accuracy, and zero external data leakage.
StateGraph):
Uses stateful graph routing where a Supervisor Agent intelligently classifies user intent (research, regulation, risk, data, or mixed) and assigns tailored tasks to domain specialists in canonical or parallel execution order.LLM_MAX_ATTEMPTS).human_approval_node), allowing engineers and regulatory experts to inspect confidence scores, compliance findings, and risk matrices on the web dashboard.Qwen/Qwen3-Embedding-8B / jina-reranker-v3) in Qdrant (localhost:6444) for hyper-accurate semantic retrieval.vectordb_search.py): Searches over Indian petroleum codes (PNGRB, OISD, DGMS, MoPNG), US BSEE standards, SPE technical literature, and Volve field datasets.tavily_search.py): Retrieves up-to-the-minute global market intelligence and academic literature.eia_api.py, worldbank_api.py): Queries official U.S. Energy Information Administration datasets and World Bank indicators with local filesystem caching (.eia_cache).python_repl.py): Executes complex petroleum engineering formulas, PVT calculations, and financial modeling in a sandboxed environment._throttle) and controlled backoff schedules (LLM_BACKOFF_SCHEDULE) to handle high-concurrency multi-agent bursts without triggering ModelHub HTTP 429 rate limits.graph TD
User([User / Web UI]) -->|Query & Parameters| API[FastAPI Async Backend]
API -->|Initialize State| START((START))
subgraph LangGraph Multi-Agent Orchestration
START --> Supervisor[Supervisor Agent<br/>Intent Classification & Routing]
Supervisor -->|Research Task| Research[Research Agent<br/>SPE & Literature RAG]
Supervisor -->|Regulation Task| Regulation[Regulation Agent<br/>PNGRB / OISD / DGMS Compliance]
Supervisor -->|Risk Task| Risk[Risk Agent<br/>5x5 Risk Matrix & HSE Hazards]
Supervisor -->|Data Task| Data[Data Agent<br/>REPL Sandbox / EIA / Statistics]
Research --> Critic[Critic Agent<br/>Hallucination & Citation Audit]
Regulation --> Critic
Risk --> Critic
Data --> Critic
Critic -->|NEEDS_REVISION<br/>(Up to 3x)| Supervisor
Critic -->|PASS| HITL{Human-in-the-Loop<br/>Approval Checkpoint}
end
HITL -->|Operator Approved| Report[Report Agent<br/>Executive Markdown / JSON / PDF]
Report -->|Final Deliverable| END((END))
subgraph Local MCP & Data Layer
Research -.->|Query| VectorDB[(Qdrant Vector DB<br/>Parent-Child Chunks)]
Regulation -.->|Check Standards| VectorDB
Risk -.->|Accident History| VectorDB
Data -.->|Execute Code| REPL[Python REPL Sandbox]
Data -.->|Fetch Data| APIs[EIA / World Bank Caches]
end
| Agent Name | Script | Responsibility & Specialization |
|---|---|---|
| π Supervisor | agents/supervisor.py | Deconstructs user queries, identifies required domains (research, regulation, risk, data), assigns specific sub-prompts, and orchestrates execution flow. |
| π Research | agents/research_agent.py | Queries vectordb_search and tavily_search to synthesize petroleum geology, reservoir engineering (EOR/IOR), drilling dynamics, and SPE paper insights. |
| βοΈ Regulation | agents/regulation_agent.py | Audits projects against Indian PNGRB (Petroleum & Natural Gas Regulatory Board), OISD (Oil Industry Safety Directorate), DGMS (Directorate General of Mines Safety), and MoPNG guidelines. Generates structured [COMPLIANT], [NON_COMPLIANT], and [REQUIRES_REVIEW] checklists. |
| β οΈ Risk | agents/risk_agent.py | Identifies process safety hazards, offshore/onshore historical failure modes (BSEE, DGMS accident databases), and outputs standardized 5x5 quantitative Risk Matrices (Severity Γ Likelihood). |
| π Data | agents/data_agent.py | Performs quantitative analysis using local Python REPL calculations, oil/gas unit conversions (TBPD, MMscfd, BOE), and live queries to EIA and World Bank statistical endpoints. |
| π Critic | agents/critic_agent.py | Acts as the quality gatekeeper. Scores responses for citation rigor, numerical accuracy, and regulatory completeness before allowing report generation. |
| π Report | agents/report_agent.py | Aggregates all verified agent findings into polished executive briefings, interactive web dashboards, and downloadable PDF documents. |
step1 to step5)The project includes an automated 5-step data preparation and embedding pipeline located in the root directory:
# 1. Initialize Qdrant collections with optimized vector dimensions and HNSW indices
python step1_setup_collections.py
# 2. Extract raw text from complex PDFs, Word documents, and reports inside source_data/
python step2_extract_text.py
# 3. Run Parent-Child quality-filtered chunking (~3,200 char parents / ~800 char children)
python step3_chunk.py
# 4. Generate embeddings via Qwen3-Embedding-8B / Jina and ingest into local Qdrant
python step4_embed_and_store.py
# 5. Execute RAG validation benchmarks and quality checks (Ragas metrics)
python step5_validate.py
3.10 or higher (3.11 recommended)18.x or higher (with npm or pnpm)localhost:6444 (or Docker: docker run -p 6444:6333 qdrant/qdrant)Clone the repository and copy the example environment file:
cp .env.example .env
Edit .env and configure your credentials:
ONGC_API_BASE_URL=https://modelhub.ongc.co.in/v1
ONGC_API_KEY=your_ongc_modelhub_api_key
EMBEDDING_MODEL=Qwen/Qwen3-Embedding-8B
QDRANT_HOST=localhost
QDRANT_PORT=6444
TAVILY_API_KEY=your_tavily_key
EIA_API_KEY=your_eia_key
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=PetroMind
Activate your virtual environment and install dependencies:
# Create and activate virtual environment (if not already created)
python -m venv petromind_env
# On Windows:
petromind_env\Scripts\activate
# On Linux/Mac:
source petromind_env/bin/activate
# Install Python requirements
pip install -r backend/requirements.txt
Install dependencies for the Vite web interface:
cd frontend
npm install
# or: pnpm install
cd ..
Run the backend server from the project root directory:
python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload
http://localhost:8000/docshttp://localhost:8000/api/reportsIn a separate terminal window, launch the interactive web studio:
cd frontend
npm run dev
http://localhost:5173ongc/
βββ agents/ # π€ Core LangGraph Multi-Agent Implementation
β βββ config.py # Centralized ModelHub & LLM configuration
β βββ graph.py # LangGraph StateGraph, routing & HITL interrupt
β βββ state.py # PetroMindState schema & logging events
β βββ supervisor.py # Supervisor routing agent
β βββ research_agent.py # Technical literature & SPE RAG agent
β βββ regulation_agent.py # Indian (PNGRB/OISD/DGMS) & global compliance agent
β βββ risk_agent.py # HSE hazard identification & 5x5 Risk Matrix agent
β βββ data_agent.py # Quantitative analyst, REPL & EIA statistics agent
β βββ critic_agent.py # Quality audit & hallucination verification agent
β βββ report_agent.py # Executive markdown, JSON & PDF report generator
βββ backend/ # βοΈ FastAPI Async Server & Job Orchestration
β βββ main.py # API routes (/api/reports, PDF downloads)
β βββ runner.py # JobManager, asynchronous runners & SSE updates
β βββ schemas.py # Pydantic request/response models
βββ frontend/ # π¨ Modern Vite Studio Web Interface
β βββ index.html # Main application layout
β βββ app.js # State synchronization, graphs & UI rendering
β βββ styles.css # Rich dark-mode design system & animations
β βββ package.json # Frontend dependencies & scripts
βββ mcp_servers/ # π Model Context Protocol Tools
β βββ vectordb_search.py # Local Qdrant semantic search engine
β βββ tavily_search.py # Live web technical intelligence search
β βββ eia_api.py # U.S. EIA energy statistics client + cache
β βββ worldbank_api.py # World Bank global economic data client
β βββ pdf_reader.py # PDF text & layout extractor
β βββ python_repl.py # Sandboxed Python mathematical calculation engine
βββ utils/ # π οΈ Shared Utilities & Logging
β βββ logger.py # Token consumption & execution latency logger
β βββ reranker.py # Jina Reranker v3 late-interaction integration
βββ step1_setup_collections.py # RAG Step 1: Qdrant schema setup
βββ step2_extract_text.py # RAG Step 2: Multi-format text extraction
βββ step3_chunk.py # RAG Step 3: Parent-Child hierarchical chunking
βββ step4_embed_and_store.py # RAG Step 4: Batch embedding & vector storage
βββ step5_validate.py # RAG Step 5: Automated benchmark validation
βββ try.py # Standalone pipeline/chunking experiment script
βββ .env.example # Example environment variables template
βββ .gitignore # Comprehensive rules ignoring large data & secrets
βββ README.md # Project documentation
ONGC_API_KEY, etc.) are strictly isolated via .env / Kubernetes secrets and excluded from version control.python_repl) operates inside a controlled, read-only calculation scope preventing arbitrary system calls or unauthorized filesystem writes.Internal Proprietary Software developed for Oil and Natural Gas Corporation (ONGC) & PetroMind Initiatives. All rights reserved.
2 commits
Python
82.4%
JavaScript
8.2%
HTML
7.4%
CSS
2.1%