How entbappy/enterprise-hr-policy-employee-support-agentic-rag-copilot works
This is an internal HR policy and employee-support copilot. Employees submit questions through the web interface; the API delegates to a LangGraph workflow that routes simple chat directly, otherwise checks private HR evidence before using web search as a fallback, and returns a grounded answer with citations and a decision trace. HR staff can upload documents for indexing, and chat decisions are audited. The workflow, API, ingestion, vector-store, and audit code were excerpted; UI-to-page and some deployment relationships are documented in the README.
Main entry points: routes.py HTTP API · vectorstore.py Vector store access · workflow.py Question routing · app.js Chat interface
Components 23
User experience
- Chat interface
static/js/app.js - Web page
templates/index.html
API and operations
- HTTP API
app/api/routes.py - Application setup
app/main.py - Configuration
app/core/config.py - Logging setup
app/core/logging.py
Agent workflow
- RAG controller
app/rag/workflow.py - Workflow state
app/rag/state.py - Question routing
app/rag/workflow.py - Private retrieval
app/rag/workflow.py - Private evidence grade
app/rag/workflow.py - Web fallback search
app/rag/workflow.py - Web evidence grade
app/rag/workflow.py - Query rewrite
app/rag/workflow.py - Answer generation
app/rag/workflow.py
Knowledge and audit
- Document loading
app/services/ingestion.py - Vector store access
app/rag/vectorstore.py - Pinecone HR index
- Decision audit
app/services/audit.py - Audit database
data/audit.db
Other components
- Employee / HR
- OpenAI models
- Tavily search
Connections 34
- Employee / HR → Chat interface: asks question
README.md - Chat interface → HTTP API: posts chat
static/js/app.js - Web page → Chat interface: hosts interface
README.md - Application setup → HTTP API: registers routes
app/main.py - Application setup → Logging setup: configures
app/main.py - Application setup → Decision audit: initializes database
app/main.py - HTTP API → RAG controller: calls ask
app/api/routes.py - HTTP API → Decision audit: writes decision
app/api/routes.py - HTTP API → Document loading: loads and chunks
app/api/routes.py - HTTP API → Vector store access: indexes chunks
app/api/routes.py - RAG controller → Question routing: dispatches
app/rag/workflow.py - Question routing → Private retrieval: routes HR queries
app/rag/workflow.py - Question routing → Answer generation: answers simple chat
app/rag/workflow.py - Private retrieval → Vector store access: retrieves evidence
app/rag/workflow.py - Private retrieval → Private evidence grade: passes documents
app/rag/workflow.py - Private evidence grade → Answer generation: uses sufficient evidence
app/rag/workflow.py - Private evidence grade → Web fallback search: falls back if weak
app/rag/workflow.py - Web fallback search → Tavily search: searches web
app/rag/workflow.py - Web fallback search → Web evidence grade: passes results
app/rag/workflow.py - Web evidence grade → Answer generation: uses sufficient evidence
app/rag/workflow.py - Web evidence grade → Query rewrite: retries if weak
app/rag/workflow.py - Query rewrite → Private retrieval: retries retrieval
app/rag/workflow.py - Answer generation → OpenAI models: generates responses
app/rag/workflow.py - Question routing → OpenAI models: classifies question
app/rag/workflow.py - Private evidence grade → OpenAI models: grades evidence
app/rag/workflow.py - Web evidence grade → OpenAI models: grades evidence
app/rag/workflow.py - Query rewrite → OpenAI models: rewrites query
app/rag/workflow.py - Vector store access → Pinecone HR index: reads and writes vectors
app/rag/vectorstore.py - Vector store access → OpenAI models: embeds documents
app/rag/vectorstore.py - Decision audit → Audit database: stores traces
app/services/audit.py - RAG controller → Workflow state: uses typed state
app/rag/workflow.py - HTTP API → Chat interface: returns answer and trace
static/js/app.js - Configuration → HTTP API: configures service
app/api/routes.py - Configuration → Vector store access: configures index
app/rag/vectorstore.py