Enterprise Knowledge Agent
Tiered enterprise knowledge & analytics platform ยท FastAPI + React ยท PostgreSQL + pgvector ยท AWS EC2
About the Project
A tiered enterprise knowledge and analytics agent platform, co-architected at Clenergy. Rather than sending every question through one retrieval pipeline, it routes each one to the path that can actually answer it: curated exact Q&A, cited document RAG, or constrained Text2SQL.
The routing layer is a self-built orchestrator rather than LangChain, and knowledge only becomes retrievable after human review โ the corpus is curated, not whatever was last uploaded.
The analytics path is deliberately narrow: the model never emits SQL, it only adjusts filters and columns inside human-reviewed templates. That constraint is what makes 100% (20/20) end-to-end accuracy reachable, and it is packaged as a reusable cross-department pattern.
Answer Path
routeClassify the question and pick an answering path
exact_qaServe a curated, human-approved question/answer pair when one matches
document_ragMinerU parse โ heading-aware chunking โ hybrid vector + full-text retrieval
rrf_fusionReciprocal rank fusion merges the two retrieval result sets
cross_encoder_rerankRerank and cap context at top-5 โ +14pp over fusion alone
text2sqlFill filters and columns into a human-reviewed SQL template โ the model never writes raw SQL
answerSynthesise the response with citations back to the reviewed source
Key Features
Tiered Answer Routing
Every question is routed to one of three answering paths โ curated exact Q&A first, cited document RAG second, constrained Text2SQL for anything numeric โ so each query is served by the cheapest path that can answer it correctly.
Self-Built Orchestrator
The routing and execution layer is written in-house rather than on LangChain, keeping control flow, state, and failure handling explicit and debuggable instead of hidden behind framework abstractions.
MinerU Document Pipeline
Source documents are parsed with MinerU and split by heading-aware chunking, preserving section structure so retrieved passages carry the context a reader needs to trust the citation.
Hybrid Retrieval + RRF + Rerank
Vector and full-text retrieval run side by side, fuse through reciprocal rank fusion, then pass a cross-encoder reranker with the context capped at top-5 โ worth +14pp over fusion alone.
Governed Text2SQL
The model never emits SQL. It may only adjust filters and columns inside SQL templates that a human has already reviewed โ which is what gets the analytics path to 100% (20/20) end-to-end accuracy.
Human-Reviewed Knowledge
Knowledge becomes retrievable only after human review, so the answer surface is a curated corpus rather than whatever happens to have been uploaded.
Reusable Cross-Department Pattern
Precise QA and Text2SQL as primary paths with RAG as backup, plus function-calling workflow agents closing an "ask โ query โ execute" loop โ packaged as a "digital employee" pattern other departments can adopt.
Postgres + pgvector Storage
PostgreSQL with pgvector holds embeddings alongside relational data, with MySQL as an additional analytics source for the Text2SQL path.
Full Tech Stack
Try it Live
Ask a policy question and read the citation, or ask for a number and watch it come back through a reviewed SQL template
Open the Agentยฉ 2026 Tony Ye. All rights reserved.