Refactor code structure for improved readability and maintainability
This commit is contained in:
52
README.md
52
README.md
@@ -14,38 +14,20 @@
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
Demo-glm/
|
||||
├── src/
|
||||
│ ├── api/ # FastAPI接口层
|
||||
│ │ ├── main.py # API入口
|
||||
│ │ ├── routes/
|
||||
│ │ │ ├── documents.py # 文档上传接口
|
||||
│ │ │ └── knowledge.py # 知识库检索接口
|
||||
│ │ └── models/
|
||||
│ │ └── document.py # Pydantic数据模型
|
||||
│ ├── services/
|
||||
│ │ ├── parser/ # 文档解析服务
|
||||
│ │ │ ├── pdf_parser.py # PDF解析(PyMuPDF)
|
||||
│ │ │ ├── docx_parser.py # Word解析
|
||||
│ │ │ └── mineru_parser.py # MinerU多模态解析
|
||||
│ │ ├── embedding/ # 嵌入服务
|
||||
│ │ │ ├── text_chunker.py # 智能分块器
|
||||
│ │ │ └── bge_m3_embedder.py # BGE-M3嵌入
|
||||
│ │ ├── storage/
|
||||
│ │ │ └── milvus_client.py # Milvus客户端
|
||||
│ │ └── document_processor.py # 文档处理主流程
|
||||
│ └── config/
|
||||
│ │ ├── settings.py # 配置管理
|
||||
│ │ └── logging.py # 日志配置
|
||||
├── tests/
|
||||
│ ├── test_parser.py # 解析测试
|
||||
│ ├── test_embedding.py # 嵌入测试
|
||||
│ ├── test_milvus.py # Milvus测试
|
||||
│ └── verify_mvp.py # MVP验证脚本
|
||||
```text
|
||||
AIRegulation-DocAnalysis-Demo/
|
||||
├── backend/
|
||||
│ ├── app/
|
||||
│ │ ├── api/ # FastAPI 接口层
|
||||
│ │ ├── config/ # 配置与日志
|
||||
│ │ ├── services/ # 解析、分块、嵌入、存储、Agent
|
||||
│ │ └── workers/
|
||||
│ ├── requirements.txt
|
||||
│ └── main.py
|
||||
├── frontend/ # Vite React 前端
|
||||
├── tests/ # 根级测试,导入 backend/app
|
||||
├── docker/
|
||||
│ └── docker-compose.yml # Milvus/MinIO部署
|
||||
├── requirements.txt
|
||||
│ └── docker-compose.yml
|
||||
├── pyproject.toml
|
||||
└── .env.example
|
||||
```
|
||||
@@ -55,7 +37,7 @@ Demo-glm/
|
||||
### 1. 安装依赖
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
pip install -r backend/requirements.txt
|
||||
```
|
||||
|
||||
### 2. 启动Milvus向量数据库
|
||||
@@ -76,10 +58,12 @@ docker-compose logs -f milvus
|
||||
python tests/verify_mvp.py
|
||||
```
|
||||
|
||||
根级测试脚本会自动把 `backend/` 加入导入路径,并从 `app.*` 加载当前后端代码。
|
||||
|
||||
### 4. 启动API服务
|
||||
|
||||
```bash
|
||||
uvicorn src.api.main:app --reload --port 8000
|
||||
PYTHONPATH=backend uvicorn app.main:app --reload --port 8000
|
||||
```
|
||||
|
||||
访问API文档:http://localhost:8000/docs
|
||||
@@ -140,4 +124,4 @@ CHUNK_SIZE=512
|
||||
|
||||
## 许可证
|
||||
|
||||
MIT License
|
||||
MIT License
|
||||
|
||||
Reference in New Issue
Block a user