How maitamdev/labor-law-chatbot works
VietLabor AI is a Vietnamese labor-law assistant. Its main workflow runs from a user question in the Streamlit interface through the chat adapter and legal reasoning pipeline, then returns a validated, evidence-backed answer with citations. The README documents the retrieval, decomposition, clarification, citation safeguards, and account privacy features. Several pipeline modules are unsampled, so their placement reflects documented capabilities; optional graph retrieval is distinguished from the lexical/vector fusion path.
Main entry points: chain.py RAG answer chain · hybrid_retriever.py Hybrid retrieval · chat_service.py Chat service · streamlit_app.py Streamlit interface
Components 25
Chat experience
- Streamlit interface
ui/streamlit_app.py - Chat and citations
ui/components/approved_layout.py - Chat service
app/chat_service.py
Legal reasoning
- Query router
rag/query_router.py - Issue decomposition
rag/issue_decomposer.py - Legal issue parser
rag/legal_issue_parser.py - RAG answer chain
rag/chain.py - Evidence selector
rag/evidence_selector.py - Output validator
rag/output_validator.py - Local Ollama LLM
models/local_llm.py
Evidence retrieval
- Hybrid retrieval
rag/hybrid_retriever.py - BM25 search
rag/bm25_retriever.py - Dense search
rag/dense_retriever.py - Cross-encoder reranker
rag/reranker.py - Graph retrieval
graph/retriever.py
Legal knowledge
- Vector index
rag/vectorstore.py - Neo4j graph
graph/connector.py - Legal corpus
ingestion/parser.py - Law crawler
law_crawler/vbpl_crawler.py
Accounts and administration
- Account portal
ui/components/account_portal.py - Account controller
ui/account_controller.py - Account services
app/accounts.py - Admin operations
app/admin_service.py - Supabase storage
config/supabase.py
Other components
- User
Connections 25
- User → Streamlit interface: asks
- Streamlit interface → Chat service: submits query
- Chat service → RAG answer chain: runs pipeline
app/chat_service.py - RAG answer chain → Query router: routes query
- RAG answer chain → Issue decomposition: decomposes issues
- Issue decomposition → Legal issue parser: parses issues
- RAG answer chain → Hybrid retrieval: retrieves candidates
- Hybrid retrieval → BM25 search: searches lexical
rag/hybrid_retriever.py - Hybrid retrieval → Dense search: searches semantic
rag/hybrid_retriever.py - Hybrid retrieval → Cross-encoder reranker: reranks results
rag/hybrid_retriever.py - Hybrid retrieval → Graph retrieval: expands by graph
- Dense search → Vector index: queries index
- Graph retrieval → Neo4j graph: queries graph
graph/retriever.py - RAG answer chain → Evidence selector: selects evidence
- RAG answer chain → Local Ollama LLM: generates answer
- RAG answer chain → Output validator: validates output
app/chat_service.py - Output validator → Chat service: returns answer
app/chat_service.py - Chat service → Chat and citations: formats citations
- Chat and citations → Streamlit interface: renders response
- Law crawler → Legal corpus: collects legal texts
- Account portal → Account controller: dispatches actions
ui/account_controller.py - Account controller → Account services: authenticates
app/accounts.py - Account portal → Admin operations: shows admin data
app/admin_service.py - Admin operations → Account services: reads account data
app/admin_service.py - Account services → Supabase storage: uses backend
app/accounts.py