How jmponcebe/pharmagraphrag works
PharmaGraphRAG answers pharmaceutical safety questions by combining FAERS-derived relationships in Neo4j with semantic retrieval over DailyMed label text, then generating grounded responses. Users enter through the Streamlit chat or REST API; classic queries extract entities, retrieve graph and vector context, and invoke an LLM. Agent and multi-agent modes select specialized tools against the same knowledge layer. Data ingestion and evaluation are included as product capabilities. Some subsystem wiring is documented in the README but was not present in sampled source, so uncertain links are omitted.
Main entry points: main.py REST API · tools.py Agent Tools · store.py Vector Store · app.py Streamlit Chat
Components 23
User Interfaces
- Streamlit Chat
src/pharmagraphrag/ui/app.py - REST API
src/pharmagraphrag/api/main.py
Query and Retrieval
- Query Engine
src/pharmagraphrag/engine/query_engine.py - Entity Extraction
src/pharmagraphrag/engine/entity_extractor.py - Dual Retriever
src/pharmagraphrag/engine/retriever.py - LLM Client
src/pharmagraphrag/llm/client.py
Agent Modes
- ReAct Agent
src/pharmagraphrag/agent/graph.py - Agent Tools
src/pharmagraphrag/agent/tools.py - Multi-Agent Supervisor
src/pharmagraphrag/agent/multi.py
Knowledge Stores
- Graph Queries
src/pharmagraphrag/graph/queries.py - Neo4j Graph
- Vector Store
src/pharmagraphrag/vectorstore/store.py - ChromaDB
Data Ingestion
- FAERS Cleaning
src/pharmagraphrag/data/clean_faers.py - Label Ingestion
src/pharmagraphrag/data/ingest_dailymed.py - Graph Loader
src/pharmagraphrag/graph/loader.py - Text Chunking
src/pharmagraphrag/vectorstore/chunker.py - Embedding
src/pharmagraphrag/vectorstore/embedder.py
Other components
- Questioner
- FDA FAERS
- DailyMed / openFDA
- Gemini API
- Ollama
Connections 28
- Questioner → Streamlit Chat: asks
- Questioner → REST API: requests
- Streamlit Chat → REST API: HTTP query
- REST API → Query Engine: processes query
- Query Engine → Entity Extraction: extracts entities
- Query Engine → Dual Retriever: retrieves context
- Dual Retriever → Graph Queries: fetches graph context
- Graph Queries → Neo4j Graph: queries
- Dual Retriever → Vector Store: searches labels
- Vector Store → ChromaDB: queries
- REST API → LLM Client: generates answer
- LLM Client → Gemini API: generates
- LLM Client → Ollama: generates
- Streamlit Chat → ReAct Agent: local agent mode
- REST API → ReAct Agent: runs agent query
- REST API → Multi-Agent Supervisor: runs multi-agent
- ReAct Agent → Agent Tools: dispatches tools
- Multi-Agent Supervisor → Agent Tools: delegates tool work
- Agent Tools → Graph Queries: retrieves drug data
- Agent Tools → Vector Store: searches label text
- FDA FAERS → FAERS Cleaning: provides reports
- DailyMed / openFDA → Label Ingestion: provides labels
- FAERS Cleaning → Graph Loader: supplies processed data
- Label Ingestion → Graph Loader: supplies label data
- Graph Loader → Neo4j Graph: loads graph
- Label Ingestion → Text Chunking: supplies label text
- Text Chunking → Embedding: prepares chunks
- Embedding → Vector Store: adds embeddings