How ai4finance-foundation/finrag works
FinRAG serves open-domain and knowledge-base chat through a FastAPI endpoint. For knowledge-base updates, the server delegates document processing and vector insertion to the Milvus client; for RAG queries, that client embeds the query, retrieves relevant chunks, optionally reranks results, and asks the chat model to answer. The API also returns suggested questions and can notify a backend when an update completes. Evidence is limited to the README and indexed excerpts; unsampled modules are included only where their role is supported by the tree or documentation.
Main entry points: customer_milvus_client.py Milvus client · finrag_server.py FastAPI endpoints · file_processor.py File processor · download_file.py File downloader
Components 17
API and orchestration
- FastAPI endpoints
app/finrag_server.py - API status responses
app/models/status.py
Document ingestion
- File processor
app/core/preprocessor/file_processor.py - Chinese text splitter
app/core/splitter/chinese_text_splitter.py - Title enhancement
app/core/splitter/zh_title_enhance.py - File downloader
app/oss/download_file.py
Retrieval and generation
- Milvus client
app/core/vectorstore/customer_milvus_client.py - Embedding client
app/core/bce/embedding_client.py - Rerank client
app/core/bce/rerank_client.py - Open chat client
app/core/chat/open_chat.py - RAG chat module
app/core/chat/rag_chat.py
External services and settings
- Milvus database
- File storage
- DashScope Qwen API
- Completion callback service
- Runtime configuration
conf/config.py
Other components
- Chat or update caller
Connections 18
- Chat or update caller → FastAPI endpoints: calls endpoint
app/finrag_server.py - FastAPI endpoints → Milvus client: delegates RAG and updates
app/finrag_server.py - FastAPI endpoints → Open chat client: requests chat
app/finrag_server.py - FastAPI endpoints → API status responses: returns update status
app/finrag_server.py - FastAPI endpoints → Completion callback service: posts completion
app/finrag_server.py - Milvus client → File processor: processes downloaded files
app/core/vectorstore/customer_milvus_client.py - File processor → Chinese text splitter: splits documents
app/core/preprocessor/file_processor.py - Milvus client → File downloader: downloads source files
app/core/vectorstore/customer_milvus_client.py - File downloader → File storage: copies or fetches files
app/oss/download_file.py - Milvus client → Embedding client: embeds chunks and queries
app/core/vectorstore/customer_milvus_client.py - Milvus client → Milvus database: inserts and searches
app/core/vectorstore/customer_milvus_client.py - Milvus client → Rerank client: reranks candidates
app/core/vectorstore/customer_milvus_client.py - Milvus client → Open chat client: generates RAG answer
app/core/vectorstore/customer_milvus_client.py - Open chat client → DashScope Qwen API: calls chat API
app/core/chat/open_chat.py - FastAPI endpoints → Runtime configuration: reads settings
app/finrag_server.py - Milvus client → Runtime configuration: reads vector settings
app/core/vectorstore/customer_milvus_client.py - File downloader → Runtime configuration: reads storage settings
app/oss/download_file.py - File processor → Title enhancement
app/core/preprocessor/file_processor.py