# LDK_QA **Repository Path**: cris721/LDK_QA ## Basic Information - **Project Name**: LDK_QA - **Description**: 基于大模型的垂域知识库问答系统平台 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2026-04-08 - **Last Updated**: 2026-04-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Alfred A domain-specific knowledge base QA system powered by LLM + RAG + multi-session web chat. --- ## 1. Project Overview Alfred is a vertical-domain QA platform that combines general LLM capabilities with domain knowledge retrieval to deliver practical, production-oriented intelligent Q&A experiences. The project currently focuses on local development and uses a frontend-backend separated architecture: - Backend uses Django + Django Ninja to provide REST APIs and streaming endpoints. - Frontend uses Vue 3 + Vite for a chat-style user interface. - SQLite stores user/account/session/config/file metadata. - ChromaDB is used for vector retrieval in expert-mode RAG. --- ## 2. Core Features ### 2.1 Account and Authentication - User registration, login, and bearer-token authentication. - User profile retrieval and password update. - Token lifecycle management with expiry. ### 2.2 Chat and Session Management - Supports standard chat (`/api/chat`) and streaming chat (`/api/chat/stream`). - Supports creating, listing, and deleting multiple sessions. - Automatically persists conversation history and supports per-session history clearing. ### 2.3 Dual Answering Modes (daily / expert) - `daily`: general conversation mode for regular Q&A. - `expert`: RAG-enabled mode prioritizing knowledge evidence. - Automatically falls back to direct model answer with a no-hit notice when expert retrieval misses. ### 2.4 User File Knowledge Base - Supports uploading `txt/csv/md/log/json/pdf` files. - Automatically extracts text and vectorizes uploaded content. - Supports per-session file listing/deletion with strict user/file retrieval isolation. ### 2.5 Model and Provider Configuration - Supports local `Ollama`. - Supports online providers (OpenAI-compatible APIs and Anthropic). - Supports dynamic model list fetching and user-level saved config. ### 2.6 Frontend Experience - ChatGPT-style chat page and session sidebar. - Complete flow for login/register/settings. - Supports light/dark themes, multi-language UI, and account management. --- ## 3. Tech Stack ### 3.1 Backend - Python 3.x - Django 4.2+ - Django Ninja - django-cors-headers - requests ### 3.2 RAG and Data Processing - ChromaDB (vector storage) - rank-bm25 (lexical reranking) - pypdf (PDF text extraction) ### 3.3 Frontend - Vue 3 - Vite - Pinia - Vue Router - Axios ### 3.4 Storage and Deployment Shape - SQLite (structured business data) - Chroma persistent path: `django_backend/data/rag_chroma` - Currently optimized for local development deployment --- ## 4. Installation Guide > Steps below target Linux/macOS. For Windows, WSL is recommended. ### 4.1 Clone the Repository ```bash git clone cd LDK_QA ``` ### 4.2 Start Backend (Django) ```bash cd django_backend python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python manage.py migrate python manage.py runserver 0.0.0.0:8081 ``` ### 4.3 Start Frontend (Vue) Open another terminal: ```bash cd vue_frontend npm install npm run dev ``` Default frontend URL: `http://localhost:8082` Vite proxies `/api` requests to `http://localhost:8081`. ### 4.4 Prepare Model Runtime (Recommended) If you use local models, install and run Ollama first, then pull models (example): ```bash ollama pull qwen2.5:0.5b ollama pull nomic-embed-text:latest ``` --- ## 5. Usage Guide ### 5.1 First-Time Flow 1. Open the frontend page and register an account. 2. Log in and enter the chat page. 3. Select mode (`daily`/`expert`) and model in settings. 4. In expert mode, upload files to improve evidence quality. 5. Send questions and review standard or streaming responses. ### 5.2 Recommended Paths - Daily Q&A: use `daily` mode directly. - Business/domain Q&A: switch to `expert`, upload domain material, then ask. - Follow-up discussions: stay in the same session to keep context. - Context reset: clear history for one session or create a new session. ### 5.3 Optional Ops Command (Domain KB Ingestion) Run in `django_backend`: ```bash python manage.py bootstrap_rag --domain_id default ``` Force rebuild for a domain: ```bash python manage.py bootstrap_rag --domain_id default --force ``` --- ## 6. Suggested Team Split (Based on Current Features) To keep iteration efficient, organize work by business flow rather than isolated technologies: ### 6.1 Product and Requirements (1 person) - Prioritize scenarios and boundaries for daily vs expert mode. - Maintain feature backlog, acceptance criteria, and release rhythm. - Define answer quality standards and prompt expectations. ### 6.2 Frontend Module (1-2 people) - Chat page (sessions, message flow, streaming rendering). - Settings page (model config, theme, language, account profile). - Upload/file UX (progress, status hints, error handling). ### 6.3 Backend API and Business Logic (1-2 people) - APIs for auth, sessions, history, files, and model config. - Auth enforcement, parameter validation, status codes, stability. - Streaming endpoint consistency and performance tuning. ### 6.4 RAG and Model Capability (1-2 people) - Vector ingestion/retrieval/reranking and hit-quality optimization. - Expert-mode prompt and evidence citation quality. - No-hit fallback strategy and retrieval observability. ### 6.5 QA and Operations (1 person) - Regression testing (login/chat/upload/streaming). - DB migrations, startup scripts, env var conventions. - Pre-release checks (integration, performance, logs/monitoring). --- ## Project Structure (Simplified) ```text LDK_QA/ ├── django_backend/ # Django backend + RAG logic │ ├── ai_api/ # Core APIs, models, services │ └── manage.py ├── vue_frontend/ # Vue frontend └── README.md ```