Intelligent Q&A and customer-service agent for Douyin shop buyers, combining crm_agent (unified API) and RAG_mode (Streamlit console + knowledge-base retrieval). Target reply latency: about 15 seconds.
cd crm_agent/crm_agent
venv\Scripts\activate
python main.py- IM console (recommended): http://localhost:7120/console/
- Interactive docs: http://localhost:7120/docs
- API reference: API.md
cd RAG_mode/mode
python -m streamlit run app.py --server.port 7121 --server.headless trueAll capabilities go through the unified agent endpoint POST /api/v1/chat:
curl -X POST http://localhost:7120/api/v1/chat \
-H "Content-Type: application/json" \
-d '{
"message": "How soon will this ship? Is there shipping insurance?",
"user_id": "buyer_001",
"session_key": "dy_session_001",
"buyer_name": "Buyer Li"
}'Flow: intent detection → routing → (consultative) RAG retrieval → read chat history → build context → LLM generation (reply_mode: rag / no_hit, etc.; mode / user_tag are deprecated).
Legacy field aliases: talent_id ↔ buyer_name, contact_username ↔ session_key.
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/chat |
Primary entry — unified chat |
| GET | /api/v1/health |
Health check |
| GET | /api/v1/meta |
Service metadata |
| GET | /console/ |
IM console (Douyin-style customer-service UI) |
| GET | /docs |
Swagger interactive docs |
| GET | /redoc |
ReDoc documentation |
{
"data": {
"mode": "agent",
"route": "unified_agent",
"answer": "...",
"reply_mode": "rag",
"rag_hit": true,
"sources": [],
"history_count": 0,
"tag_upgrade": null
},
"state": {"code": 0, "message": "ok"}
}Full field reference: API.md (v2.1.0).
RAG_Agent/
├── API.md # API documentation
├── services/ # [shared] RAG retrieval, intent routing, core business logic
├── rag/ # [shared] Knowledge-base ingest pipeline (chunk / load / embed)
├── data/ # [shared] Knowledge-base documents
├── scripts/ # [shared] Ingest / test / simulation scripts
├── embedding.py # [shared] BGE-M3 embedding
├── vectorstore.py # [shared] Milvus hybrid vector search
├── reranker.py # [shared] BGE-Reranker re-ranking
├── shared_config/ # [shared] Redis/MySQL session config
├── web/ # IM console frontend (mounted at /console/)
├── crm_agent/crm_agent/
│ ├── main.py # API entry :7120
│ ├── settings.py # System settings
│ ├── app/ # FastAPI app layer (routes / agent orchestration)
│ ├── config.yaml # LLM config
│ └── agents.yaml # Agent definitions
├── RAG_mode/mode/
│ ├── app.py # Streamlit console (port 7121)
│ └── settings.py # System settings
└── start_api.bat
After starting the API, open http://localhost:7120/console/ for local integration. When opening the static page alone, pass ?api=http://localhost:7120 to point at the backend.
cd RAG_mode/mode
streamlit run app.pyD:\Milvus— Milvus Lite vector store (rag_collection, dense + sparse hybrid search)D:\BGE-M3— Local BGE-M3 embedding modelD:\BGE-Reranker-v2-m3— BGE-Reranker (GPU re-ranking)- Redis + MySQL — session state (shared by RAG_mode and crm_agent)
- Copy repo-root
.env.session.example→.env.sessionand edit that one file - Code entry:
shared_config/session_store.py
- Copy repo-root
- API key: set env var
DEEPSEEK_KEY(see each subproject’s.env.example)
# Run from the repository root
python scripts/ingest_bd_docx.py --file "path/to/your_kb.docx"
# Or rebuild the index
python scripts/ingest_documents.py --rebuild