版本: v3.0 更新日期: 2026-04-09 项目状态: 核心功能已实现,生产环境运行中 v2.0→v3.0 变更: 新增施工方案编写模块、脱敏模块、简化管道、标准匹配、LLM分类器v2、LLM链式客户端框架
┌─────────────────────────────────────────────────────────────────────────────────────┐
│ LQAgentPlatform - 实际架构实现 (v2.0) │
├─────────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ Server Layer (服务器层) │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ FastAPI Application (server/app.py) │ │ │
│ │ │ • RouteManager - 路由管理 │ │ │
│ │ │ • CeleryWorkerManager - 异步任务管理 │ │ │
│ │ │ • ApplicationFactory - 应用工厂 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ HTTP Request │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ Views Layer (视图层) │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ construction_review/ - 施工方案审查API ✅ (已实现) │ │ │
│ │ │ • file_upload.py - 文档上传接口 │ │ │
│ │ │ • launch_review.py - 启动审查接口 │ │ │
│ │ │ • review_results.py - 审查结果接口 │ │ │
│ │ │ • task_control.py - 任务控制接口 │ │ │
│ │ │ • desensitize_api.py - 脱敏API接口 🆕 │ │ │
│ │ │ • schemas/error_schemas.py - 错误模式定义 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ construction_write/ - 施工方案编写API ✅ (已实现) 🆕 │ │ │
│ │ │ • outline_views.py - 大纲生成接口 │ │ │
│ │ │ • content_completion.py - 内容补全接口 │ │ │
│ │ │ • regenerate_views.py - 重新生成接口 │ │ │
│ │ │ • task_cancel_views.py - 任务取消接口 │ │ │
│ │ │ • similar_plan_recommend.py - 相似方案推荐接口 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ test_views.py - 测试接口 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ 调用业务逻辑 │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ Core Layer (核心业务层) │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ construction_review/ - 施工方案审查模块 ✅ (已实现) │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ workflows/ - 工作流层 │ │ │ │
│ │ │ │ • ai_review_workflow.py - AI审查工作流 (54KB, 核心) │ │ │ │
│ │ │ │ • document_workflow.py - 文档处理工作流 │ │ │ │
│ │ │ │ • report_workflow.py - 报告生成工作流 │ │ │ │
│ │ │ │ • core_functions/ - 核心业务函数 🆕 │ │ │ │
│ │ │ │ • types/ - 状态类型定义 (AIReviewState, TaskChainState) 🆕 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ component/ - 组件层 │ │ │ │
│ │ │ │ • ai_review_engine.py - AI审查引擎 (核心引擎) │ │ │ │
│ │ │ │ • document_processor.py - 文档处理器 │ │ │ │
│ │ │ │ • report_generator.py - 报告生成器 │ │ │ │
│ │ │ │ • outline_catalogue_matcher.py - 大纲目录匹配器 🆕 │ │ │ │
│ │ │ │ • constants.py - 常量定义 🆕 │ │ │ │
│ │ │ │ • check_completeness/ - 完整性检查组件 │ │ │ │
│ │ │ │ • desensitize/ - 数据脱敏模块 🆕 │ │ │ │
│ │ │ │ - engine.py, validator.py, dict_manager.py │ │ │ │
│ │ │ │ - model_client.py, remapper.py │ │ │ │
│ │ │ │ - processors/ (pii, geo, biz, financial) │ │ │ │
│ │ │ │ • doc_worker/ - 文档处理工作器 │ │ │ │
│ │ │ │ - classification/ (chunk, hierarchy, smart_local) 🆕 │ │ │ │
│ │ │ │ - pdf_worker/ (html_to_markdown) 🆕 │ │ │ │
│ │ │ │ - config/ (StandardCategoryTable.csv, prompt.yaml) │ │ │ │
│ │ │ │ • minimal_pipeline/ - 简化处理管道 🆕 │ │ │ │
│ │ │ │ - ocr_processor.py, pdf_extractor.py │ │ │ │
│ │ │ │ - toc_builder.py, toc_detector.py │ │ │ │
│ │ │ │ - simple_processor.py, chunk_assembler.py │ │ │ │
│ │ │ │ • standard_matching/ - 标准匹配模块 🆕 │ │ │ │
│ │ │ │ - standard_dao.py, standard_service.py │ │ │ │
│ │ │ │ • infrastructure/ - 基础设施组件 │ │ │ │
│ │ │ │ • reviewers/ - 审查器集合 │ │ │ │
│ │ │ │ - base_reviewer.py - 基础审查器 │ │ │ │
│ │ │ │ - completeness_reviewer.py - 完整性审查器 │ │ │ │
│ │ │ │ - reference_basis_reviewer.py - 参考依据审查器 │ │ │ │
│ │ │ │ - standard_timeliness_reviewer.py - 标准时效性审查器 🆕 │ │ │ │
│ │ │ │ - timeliness_basis_reviewer.py - 时效性审查器 │ │ │ │
│ │ │ │ - timeliness_content_reviewer.py - 时效性内容审查器 🆕 │ │ │ │
│ │ │ │ - semantic_logic.py - 语义逻辑审查器 │ │ │ │
│ │ │ │ - sensitive_word_check.py - 敏感词检查 🆕 │ │ │ │
│ │ │ │ - utils/llm_content_classifier_v2/ - LLM分类器v2 🆕 │ │ │ │
│ │ │ │ - utils/llm_chain_client/ - LLM链式客户端框架 🆕 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ construction_write/ - 施工方案编写模块 ✅ (已实现) 🆕 │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ component/ │ │ │ │
│ │ │ │ • outline_generator.py - 大纲生成器 │ │ │ │
│ │ │ │ • state_models.py - 状态模型 │ │ │ │
│ │ │ │ • prompt/ - 提示词配置 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ workflows/ │ │ │ │
│ │ │ │ • agent.py - 编写智能体 │ │ │ │
│ │ │ │ • outline_workflow.py - 大纲工作流 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ base/ - 基础组件 ✅ (已实现) │ │ │
│ │ │ • progress_manager.py - 进度管理器 │ │ │
│ │ │ • workflow_manager.py - 工作流管理器 │ │ │
│ │ │ • sse_manager.py - SSE服务器推送事件管理器 │ │ │
│ │ │ • redis_duplicate_checker.py - Redis去重检查器 │ │ │
│ │ │ • task_models.py - 任务模型定义 │ │ │
│ │ │ • words_detect/ - 敏感词检测模块 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ 调用基础设施 │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ Foundation Layer (基础设施层) │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ ai/ - AI模块 ✅ (已实现) │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ agent/ - AI智能体 │ │ │ │
│ │ │ │ • base_agent.py - 智能体基类 │ │ │ │
│ │ │ │ • test_agent.py - 测试智能体 │ │ │ │
│ │ │ │ • generate/ - 生成模块 │ │ │ │
│ │ │ │ • workflow/ - 工作流模块 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ models/ - 模型管理 │ │ │ │
│ │ │ │ • model_handler.py - 多模型管理器 │ │ │ │
│ │ │ │ • rerank_model.py - 重排序模型 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ rag/ - RAG检索增强生成 │ │ │ │
│ │ │ │ • retrieval/ - 检索模块 │ │ │ │
│ │ │ │ • query_rewrite.py - 查询重写 │ │ │ │
│ │ │ │ • entities_enhance.py - 实体增强检索 │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ database/ - 数据库模块 ✅ (已实现) │ │ │
│ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ base/ - 数据库基础层 │ │ │ │
│ │ │ │ • kg/ - 知识图谱 (Neo4j) │ │ │ │
│ │ │ │ • sql/ - SQL数据库 (MySQL/PostgreSQL) │ │ │ │
│ │ │ │ • vector/ - 向量数据库 (Milvus/PG Vector) │ │ │ │
│ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │
│ │ │ • models/ - 数据模型定义 │ │ │
│ │ │ • repositories/ - 数据访问层 │ │ │
│ │ │ • migrations/ - 数据库迁移 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ infrastructure/ - 基础设施 ✅ (已实现) │ │ │
│ │ │ • cache/ - 缓存管理 (Redis) │ │ │
│ │ │ • config/ - 配置管理 (config_handler) │ │ │
│ │ │ • messaging/ - 消息队列 (Celery) │ │ │
│ │ │ • mysql/ - MySQL连接池 │ │ │
│ │ │ • tracing/ - 链路追踪 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ observability/ - 可观测性 ✅ (已实现) │ │ │
│ │ │ • logger/ - 日志管理 │ │ │
│ │ │ • metrics/ - 指标收集 │ │ │
│ │ │ • monitoring/ - 监控 (ai_trace_monitor.py, time_statistics.py) │ │ │
│ │ │ • monitoring/rag/ - RAG监控 🆕 │ │ │
│ │ │ • cachefiles/ - 缓存文件管理 🆕 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ schemas/ - 数据模式 ✅ (已实现) │ │ │
│ │ │ utils/ - 工具函数 ✅ (已实现) │ │ │
│ │ │ • common.py, redis_utils.py, yaml_utils.py, tool_utils.py │ │ │
│ │ │ • md5.py - MD5工具 🆕 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ 数据处理 │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ Data Pipeline Layer (数据管道层) │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ document/ - 文档处理 ✅ (部分实现) │ │ │
│ │ │ • parsers/ - 文档解析器 (PDF, DOCX, OCR) │ │ │
│ │ │ • processors/ - 数据处理器 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ RAG_recall/ - RAG检索 ✅ (已实现) │ │ │
│ │ │ • rag_miluvs/ - Milvus RAG实现 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ milvus_inbound_script/ - Milvus入库脚本 │ │ │
│ │ │ training_data/ - 训练数据处理 │ │ │
│ │ └─────────────────────────────────────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ 数据存储 │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
│ │ External Services (外部服务) │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ MySQL │ │ Milvus │ │ Redis │ │ Neo4j │ │ │
│ │ │ 关系数据库 │ │ 向量数据库 │ │ 缓存 │ │ 知识图谱 │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ AI Models │ │ MinerU │ │ Langfuse │ │ │
│ │ │ 本地/云端 │ │ OCR服务 │ │ 监控系统 │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ └───────────────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────────┘
LQAgentPlatform/
├── server/ # 服务器层 ✅
│ └── app.py # FastAPI应用入口
│
├── views/ # 视图层 (API接口) ✅
│ ├── __init__.py # Lifespan管理(敏感词初始化、DB连接池)
│ ├── construction_review/ # 施工方案审查API ✅
│ │ ├── file_upload.py # 文档上传接口
│ │ ├── launch_review.py # 启动审查接口
│ │ ├── review_results.py # 审查结果接口
│ │ ├── task_control.py # 任务控制接口
│ │ ├── desensitize_api.py # 脱敏API接口 🆕
│ │ └── schemas/
│ │ └── error_schemas.py # 错误模式定义
│ ├── construction_write/ # 施工方案编写API ✅ 🆕
│ │ ├── outline_views.py # 大纲生成接口
│ │ ├── content_completion.py # 内容补全接口
│ │ ├── regenerate_views.py # 重新生成接口
│ │ ├── task_cancel_views.py # 任务取消接口
│ │ └── similar_plan_recommend.py # 相似方案推荐接口
│ └── test_views.py # 测试接口
│
├── core/ # 核心业务层 ✅
│ ├── base/ # 基础组件 ✅
│ │ ├── progress_manager.py # 进度管理器
│ │ ├── workflow_manager.py # 工作流管理器
│ │ ├── sse_manager.py # SSE推送管理
│ │ ├── redis_duplicate_checker.py # Redis去重
│ │ ├── task_models.py # 任务模型
│ │ └── words_detect/ # 敏感词检测
│ │
│ ├── construction_review/ # 施工方案审查模块 ✅
│ │ ├── workflows/ # 工作流层 ✅
│ │ │ ├── ai_review_workflow.py # AI审查工作流 (核心)
│ │ │ ├── document_workflow.py # 文档工作流
│ │ │ ├── report_workflow.py # 报告工作流
│ │ │ ├── core_functions/ # 核心业务函数 🆕
│ │ │ │ └── ai_review_core_fun.py # AI审查核心逻辑
│ │ │ └── types/ # 状态类型 🆕
│ │ │ └── __init__.py # AIReviewState, TaskChainState
│ │ │
│ │ └── component/ # 组件层 ✅
│ │ ├── ai_review_engine.py # AI审查引擎 (核心)
│ │ ├── document_processor.py # 文档处理器
│ │ ├── report_generator.py # 报告生成器
│ │ ├── outline_catalogue_matcher.py # 大纲目录匹配器 🆕
│ │ ├── constants.py # 常量定义 🆕
│ │ │
│ │ ├── desensitize/ # 数据脱敏模块 🆕
│ │ │ ├── engine.py # 脱敏引擎核心
│ │ │ ├── validator.py # 黑白名单校验
│ │ │ ├── dict_manager.py # 脱敏词典管理
│ │ │ ├── model_client.py # 本地LLM脱敏客户端
│ │ │ ├── remapper.py # 审查结果反向映射
│ │ │ └── processors/ # 四维度处理器
│ │ │ ├── base_processor.py # 基础处理器
│ │ │ ├── pii_processor.py # 个人信息 (姓名/电话/身份证)
│ │ │ ├── geo_processor.py # 地理位置 (桩号/位置/高程)
│ │ │ ├── biz_processor.py # 业务信息 (公司/项目名称)
│ │ │ └── financial_processor.py # 财务信息 (金额/价格)
│ │ │
│ │ ├── doc_worker/ # 文档处理工作器
│ │ │ ├── interfaces.py # 数据接口/契约
│ │ │ ├── classification/ # 内容分类 🆕
│ │ │ │ ├── chunk_classifier.py # 分块分类器
│ │ │ │ ├── hierarchy_classifier.py # 层级分类器
│ │ │ │ └── smart_local_classifier.py # 智能本地分类
│ │ │ ├── pdf_worker/ # PDF处理 🆕
│ │ │ │ └── html_to_markdown.py # HTML转Markdown
│ │ │ ├── config/ # 配置
│ │ │ │ ├── StandardCategoryTable.csv # 分类标准表
│ │ │ │ ├── prompt.yaml # LLM提示词
│ │ │ │ └── config.yaml
│ │ │ ├── models/ # 数据模型
│ │ │ │ ├── document_structure.py # 文档结构模型
│ │ │ │ └── converters.py # 模型转换器
│ │ │ └── utils/
│ │ │ ├── text_split_support.py # 文本切分支持
│ │ │ └── prompt_loader.py # 提示词加载
│ │ │
│ │ ├── minimal_pipeline/ # 简化处理管道 🆕
│ │ │ ├── simple_processor.py # 简化处理器
│ │ │ ├── ocr_processor.py # OCR处理(解耦模块)
│ │ │ ├── pdf_extractor.py # PDF提取
│ │ │ ├── chunk_assembler.py # 分块组装器
│ │ │ ├── catalog_reviewer.py # 目录审查
│ │ │ ├── toc_builder.py # 目录构建器
│ │ │ └── toc_detector.py # 目录检测器
│ │ │
│ │ ├── standard_matching/ # 标准匹配模块 🆕
│ │ │ ├── standard_dao.py # 标准数据访问
│ │ │ └── standard_service.py # 标准匹配服务
│ │ │
│ │ ├── infrastructure/ # 基础设施组件
│ │ │ ├── milvus.py # Milvus向量库客户端
│ │ │ ├── parent_tool.py # 父块工具
│ │ │ └── relevance.py # 相关性评分
│ │ │
│ │ ├── check_completeness/ # 完整性检查
│ │ │ └── components/
│ │ │ └── result_analyzer.py # 结果分析器
│ │ │
│ │ ├── report/ # 报告生成
│ │ │ └── prompt/
│ │ │ └── report_reviewers.yaml
│ │ │
│ │ └── reviewers/ # 审查器集合 ✅
│ │ ├── base_reviewer.py # 基础审查器
│ │ ├── completeness_reviewer.py # 完整性审查器
│ │ ├── reference_basis_reviewer.py # 参考依据审查
│ │ ├── standard_timeliness_reviewer.py # 标准时效性审查 🆕
│ │ ├── timeliness_basis_reviewer.py # 时效性审查
│ │ ├── timeliness_content_reviewer.py # 时效性内容审查 🆕
│ │ ├── semantic_logic.py # 语义逻辑审查
│ │ ├── sensitive_word_check.py # 敏感词检查 🆕
│ │ ├── check_completeness/
│ │ │ └── components/
│ │ │ └── result_analyzer.py
│ │ ├── prompt/ # 审查器提示词
│ │ │ ├── ai_suggestion.yaml
│ │ │ ├── basic_reviewers.yaml
│ │ │ ├── outline_reviewers.yaml
│ │ │ ├── query_extract.yaml
│ │ │ ├── rag_reviewers.yaml
│ │ │ ├── reference_basis_reviewer.yaml
│ │ │ ├── technical_reviewers.yaml
│ │ │ └── timeliness_basis_reviewer.yaml
│ │ ├── sensitive_words/ # 敏感词词典
│ │ └── utils/ # 审查工具函数
│ │ ├── ac_automaton.py # AC自动机
│ │ ├── directory_extraction.py
│ │ ├── llm_content_classifier_v2/ # LLM分类器v2 🆕
│ │ │ ├── main_classifier.py # 主入口
│ │ │ ├── content_classifier.py # 核心分类逻辑
│ │ │ ├── category_loaders.py # 分类加载器
│ │ │ ├── chunks_converter.py # 分块转换
│ │ │ ├── models.py # 数据模型
│ │ │ ├── prompt.py # 分类提示词
│ │ │ └── embedding_client.py # Embedding客户端
│ │ └── llm_chain_client/ # LLM链式客户端框架 🆕
│ │ ├── bootstrap.py # 客户端工厂
│ │ ├── interfaces/ # 接口定义
│ │ │ ├── chain_executor.py
│ │ │ ├── llm_client.py
│ │ │ └── prompt_loader.py
│ │ ├── implementations/ # 实现
│ │ │ ├── chains/async_chain_executor.py
│ │ │ ├── clients/ (base, deepseek, doubao, gemini, qwen)
│ │ │ └── loaders/yaml_prompt_loader.py
│ │ └── orchestration/prompt_chain_processor.py
│ │
│ └── construction_write/ # 施工方案编写模块 ✅ 🆕
│ ├── component/
│ │ ├── outline_generator.py # 大纲生成器
│ │ ├── state_models.py # 状态模型
│ │ └── prompt/
│ │ └── keyword_rules_3.json # 关键字规则
│ └── workflows/
│ ├── agent.py # 编写智能体
│ └── outline_workflow.py # 大纲工作流
│
├── foundation/ # 基础设施层 ✅
│ ├── ai/ # AI模块 ✅
│ │ ├── agent/ # AI智能体
│ │ │ └── generate/ # 生成模块
│ │ │ └── model_generate.py
│ │ ├── models/ # 模型管理 ✅
│ │ │ ├── model_handler.py # 多模型管理器
│ │ │ ├── model_config_loader.py # 模型配置加载器 🆕
│ │ │ └── rerank_model.py # 重排序模型
│ │ └── rag/ # RAG检索增强 ✅
│ │ └── retrieval/ # 检索模块
│ │ ├── query_rewrite.py # 查询重写
│ │ ├── retrieval.py # 检索管理器
│ │ └── entities_enhance.py # 实体增强检索
│ │
│ ├── database/ # 数据库模块 ✅
│ │ ├── base/ # 数据库基础层
│ │ │ ├── kg/ # 知识图谱 (Neo4j)
│ │ │ ├── sql/ # SQL数据库 (MySQL/PostgreSQL)
│ │ │ └── vector/ # 向量数据库
│ │ ├── models/ # 数据模型定义 ✅
│ │ ├── repositories/ # 数据访问层 ✅
│ │ └── migrations/ # 数据库迁移
│ │
│ ├── infrastructure/ # 基础设施 ✅
│ │ ├── cache/ # 缓存管理 (Redis)
│ │ ├── config/ # 配置管理 ✅
│ │ │ └── config.py # config_handler
│ │ ├── messaging/ # 消息队列 (Celery) ✅
│ │ ├── mysql/ # MySQL连接池 ✅
│ │ └── tracing/ # 链路追踪 ✅
│ │
│ ├── observability/ # 可观测性 ✅
│ │ ├── logger/ # 日志管理
│ │ ├── metrics/ # 指标收集
│ │ ├── monitoring/ # 监控 ✅
│ │ │ ├── ai_trace_monitor.py # AI追踪监控
│ │ │ ├── time_statistics.py # 时间统计
│ │ │ └── rag/ # RAG监控 🆕
│ │ └── cachefiles/ # 缓存文件管理 🆕
│ │
│ ├── schemas/ # 数据模式 ✅
│ └── utils/ # 工具函数 ✅
│ ├── common.py
│ ├── redis_utils.py
│ ├── yaml_utils.py
│ ├── tool_utils.py
│ └── md5.py # MD5工具 🆕
│
├── data_pipeline/ # 数据管道层 ✅
│ ├── document/ # 文档处理
│ │ ├── parsers/ # 文档解析器
│ │ └── processors/ # 数据处理器
│ ├── RAG_recall/ # RAG检索 ✅
│ │ └── rag_miluvs/ # Milvus RAG实现
│ ├── milvus_inbound_script/ # Milvus入库脚本
│ └── training_data/ # 训练数据处理
│
├── config/ # 配置文件 ✅
│ ├── config.ini # 主配置文件 (模型/数据库/Redis)
│ ├── config.ini.template # 配置模板
│ ├── model_setting.yaml # 模型设置 🆕
│ ├── prompt/ # 提示词配置 ✅
│ │ ├── system_prompt.yaml
│ │ └── intent_prompt.yaml
│ ├── sql/ # SQL脚本
│ └── yolo/ # YOLO模型 🆕
│ └── best.pt
│
├── utils_test/ # 测试工具集
│ ├── AI_Review_Test/ # AI审查测试
│ ├── API_key/ # API密钥生成 🆕
│ ├── Check_Item/ # 审查项测试 🆕
│ ├── Chunk_Split_Test/ # 分块切分测试 🆕
│ ├── Completeness_Enhanced_Test/ # 增强完整性测试 🆕
│ ├── Completeness_Test/ # 完整性测试 🆕
│ ├── Integration_Test/ # 集成测试
│ ├── Milvus_Test/ # Milvus测试
│ ├── MinerU_Test/ # MinerU测试
│ ├── Model_Test/ # 模型测试
│ ├── Other_Test/ # 其他测试 🆕
│ ├── Prompt_Test/ # 提示词测试 🆕
│ ├── RAG_Test/ # RAG测试 🆕
│ ├── RE_Rrank_Test/ # 重排序测试 🆕
│ ├── Redis/ # Redis哨兵测试 🆕
│ ├── Redis_Test/ # Redis测试
│ ├── Result_Visual_Observation_Tools/ # 结果可视化 🆕
│ ├── Semantic_Logic_Test/ # 语义逻辑测试
│ ├── Sensitive_Test/ # 敏感词测试
│ ├── standard_new_Test/ # 新标准测试 🆕
│ └── Sync_Funcation_Test/ # 同步函数测试
│
├── docker/ # Docker配置
├── .design/ # 设计文档
│ ├── 施工方案编写应用/ # 编写应用设计 🆕
│ └── 施工方案审查应用/ # 审查应用设计
│ ├── base_stage/ # 基础阶段设计
│ ├── Iterative_stage/ # 迭代阶段设计
│ ├── technical_rehearsal/ # 技术预演
│ ├── 基础架构设计/ # 架构设计
│ ├── 施工方案审查API架构设计/ # API架构设计
│ ├── 完整性审查模块/ # 完整性审查设计
│ └── 文档处理模块/ # 文档处理设计
│
├── .RaD/ # 研发文档 🆕
│
├── logs/ # 日志目录
├── README.md # 项目说明
├── README_deploy.md # 部署说明 🆕
├── README_test.md # 测试说明 🆕
├── requirements.txt # 依赖清单
├── gunicorn_config.py # Gunicorn配置
├── run.sh # 启动脚本
└── Dockerfile # Docker镜像
POST /construction/upload - 上传待审查文档POST /sgsc/sse/launch_review - 启动审查任务(SSE流式)GET /construction/review/results - 查询审查结果POST /construction/task/terminate - 终止审查任务┌──────────────┐
│ 用户上传文档 │
└──────┬───────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ Views Layer (file_upload.py) │
│ • 接收文件 │
│ • 文件验证 │
│ • 创建任务 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ Core Layer - Document Workflow │
│ • 文档解析 (PDF/DOCX) │
│ • 结构提取 │
│ • 分块处理 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ Database Layer │
│ • Redis - 存储文档元数据 │
│ • Milvus - 向量存储 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ Core Layer - AI Review Workflow │
│ • AI审查引擎 (construction_review/ai_review_engine.py) │
│ • 多种审查器并行执行 │
│ • RAG检索增强 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ Foundation Layer - AI模块 │
│ • 模型调用 (model_handler.py) │
│ • RAG检索 (retrieval/) │
│ • 查询重写 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ External Services │
│ • AI模型 (本地/云端) │
│ • Milvus向量检索 │
│ • Redis缓存 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────────────────────────────────────────────────┐
│ 结果处理 │
│ • 报告生成 (report_generator.py) │
│ • SSE推送进度 │
│ • 结果存储 │
└──────┬───────────────────────────────────────────────────────┘
▼
┌──────────────────┐
│ 返回审查结果 │
└──────────────────┘
职责: FastAPI应用管理、路由配置、Celery任务管理 实现:
RouteManager - 路由配置和中间件CeleryWorkerManager - Celery Worker生命周期管理ApplicationFactory - 应用工厂模式职责: HTTP API接口、请求处理、响应格式化 实现:
职责: 业务逻辑编排、应用状态管理、工作流协调 实现:
职责: 基础设施、通用组件、外部服务集成 实现:
职责: 数据处理、格式转换、内容解析 实现: 文档解析器、数据处理器、向量入库
见源代码中的config/config.ini
---
## 系统启动流程详解
### 1. 应用启动入口 (server/app.py)
#### 启动类架构
ApplicationFactory (应用工厂) ├── create_app() # 创建FastAPI应用实例 ├── create_server_config() # 创建服务器配置 └── celery_manager # CeleryWorkerManager实例
RouteManager (路由管理器) ├── _setup_cors() # 配置CORS中间件 ├── _setup_routes() # 配置所有路由 ├── _setup_exception_handlers() # 全局异常处理 ├── _setup_health_checks() # 健康检查接口 └── _setup_api_docs() # Swagger API文档
CeleryWorkerManager (Celery Worker管理器) ├── start_worker() # 启动Celery Worker(后台线程) ├── stop_worker() # 优雅停止Worker ├── stop_worker_immediately() # 立即停止Worker └── _cleanup_redis_tasks() # 清理Redis任务
ServerRunner (服务器运行器) └── run_server() # 运行Uvicorn服务器
#### 启动流程
收到停止信号时
关闭事件循环
#### 关键配置项
ini
[launch] HOST = 0.0.0.0 # 监听地址 LAUNCH_PORT = 8002 # 监听端口
[redis] REDIS_HOST=127.0.0.1 # Redis主机 REDIS_PORT=6379 # Redis端口 REDIS_DB=0 # Redis数据库 REDIS_PASSWORD=123456 # Redis密码
---
## 任务提交流程详解
### 1. 完整任务流程架构
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 任务提交与执行完整流程 │ └─────────────────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 步骤1: 文件上传 (views/construction_review/file_upload.py) │ │ POST /construction/upload │ │ • 接收PDF文件上传 │ │ • 生成file_id和callback_task_id │ │ • 保存文件内容到Redis │ │ • 返回callback_task_id给前端 │ └─────────────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 步骤2: 启动审查 (views/construction_review/launch_review.py) │ │ POST /sgsc/sse/launch_review │ │ • 验证用户权限和参数 │ │ • 建立SSE连接 │ │ • 调用WorkflowManager.submit_task_processing() │ └─────────────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 步骤3: 提交到Celery (core/base/workflow_manager.py) │ │ WorkflowManager.submit_task_processing() │ │ • 使用CeleryTraceManager提交任务 │ │ • 自动传递trace_id用于链路追踪 │ │ • 任务进入Redis队列 │ └─────────────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 步骤4: Celery Worker执行 (foundation/infrastructure/messaging/tasks.py) │ │ submit_task_processing_task() │ │ • 从队列获取任务 │ │ • 恢复trace_id上下文 │ │ • 调用WorkflowManager.submit_task_processing_sync() │ └─────────────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────────────┐ │ 步骤5: LangGraph任务链执行 (core/base/workflow_manager.py) │ │ submit_task_processing_sync() │ │ • 创建TaskFileInfo对象 │ │ • 创建TaskChainState初始状态 │ │ • 构建LangGraph任务链工作流图 │ │ • 执行ainvoke()运行工作流 │ └─────────────────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────────────────┐ │ LangGraph任务链工作流(方案D) │ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │ │ start → document_processing → ai_review_subgraph → report_generation → │ │ │ │ complete │ │ │ └─────────────────────────────────────────────────────────────────────────┘ │ │ 每个阶段后检查终止信号: │ │ - terminate: 进入终止节点 │ │ - error: 进入错误处理节点 │ │ - continue: 继续下一阶段 │ └─────────────────────────────────────────────────────────────────────────────────┘
### 2. LangGraph任务链节点详解
#### 节点1: start (任务链开始)
python async def _start_chain_node(state: TaskChainState) -> TaskChainState:
"""
初始化任务链状态
- current_stage: "start"
- overall_task_status: "processing"
- stage_status: 所有阶段初始化为"pending"
"""
#### 节点2: document_processing (文档处理)
python async def _document_processing_node(state: TaskChainState) -> TaskChainState:
"""
执行文档处理工作流
- 检查终止信号
- 创建DocumentWorkflow实例
- 调用document_workflow.execute()
- 返回结构化内容
- stage_status["document"]: "completed"/"terminated"/"failed"
"""
#### 节点3: ai_review_subgraph (AI审查)
python async def _ai_review_subgraph_node(state: TaskChainState) -> TaskChainState:
"""
执行AI审查工作流(嵌套子图)
- 检查终止信号
- 获取文档处理结果中的structured_content
- 创建AIReviewWorkflow实例
- 调用ai_workflow.execute()
- 返回审查结果
- stage_status["ai_review"]: "completed"/"terminated"/"failed"
"""
#### 节点4: report_generation (报告生成)
python async def _report_generation_node(state: TaskChainState) -> TaskChainState:
"""
生成审查报告
- 检查终止信号
- 获取AI审查结果
- 创建ReportWorkflow实例
- 调用report_workflow.execute()
- 保存完整结果到文件
- stage_status["report"]: "completed"/"terminated"/"failed"
"""
#### 节点5: complete (任务完成)
python async def _complete_chain_node(state: TaskChainState) -> TaskChainState:
"""
标记整体任务完成
- overall_task_status: "completed" ⚠️ 只有到这里才标记完成
- 清理Redis文件缓存
- 通知SSE连接
"""
#### 节点6: error_handler (错误处理)
python async def _error_handler_chain_node(state: TaskChainState) -> TaskChainState:
"""
处理任务链错误
- overall_task_status: "failed"
- 清理Redis文件缓存
- 通知SSE连接失败状态
"""
#### 节点7: terminate (任务终止)
python async def _terminate_chain_node(state: TaskChainState) -> TaskChainState:
"""
处理任务终止
- overall_task_status: "terminated"
- 清理Redis终止信号
- 清理Redis文件缓存
- 通知SSE连接终止状态
"""
### 3. 条件边判断逻辑
python def _should_terminate_or_error_chain(state: TaskChainState) -> str:
"""
决定工作流下一步走向
优先级:terminate > error > continue
"""
# 1. 优先检查终止信号
if state.get("overall_task_status") == "terminated":
return "terminate"
# 2. 检查错误状态
if state.get("overall_task_status") == "failed" or state.get("error_message"):
return "error"
# 3. 默认继续执行
return "continue"
---
## 审查逻辑详解
### 1. AI审查引擎架构 (core/construction_review/component/construction_review/ai_review_engine.py)
AIReviewEngine (审查引擎核心) ├── 基础合规性检查 │ ├── check_grammar() # 词句语法检查 │ ├── check_semantic_logic() # 语义逻辑检查 │ ├── check_completeness() # 完整性检查 │ ├── check_timeliness() # 时效性检查 │ └── check_reference() # 规范性检查 │ ├── 技术性合规检查 │ ├── check_non_parameter_compliance() # 非参数合规性检查 │ └── check_parameter_compliance() # 参数合规性检查 │ ├── RAG增强审查 │ ├── vector_search() # 向量检索 │ ├── hybrid_search() # 混合检索 │ ├── rerank_results() # 重排序结果 │ └── generate_enhanced_suggestions() # 生成增强建议 │ └── 专业性审查
├── prep_basis_review() # 编制依据审查
├── outline_review_results_df() # 目录审查
└── catalogues_check() # 章节审查
### 2. 审查配置与模式
#### 审查配置参数
python
review_config = [
'sensitive_word_check', # 词句语法检查
'semantic_logic_check', # 语义逻辑审查
'completeness_check', # 条文完整性审查
'timeliness_check', # 时效性审查
'reference_check', # 规范性审查
'sensitive_check', # 敏感词审查
'non_parameter_compliance_check', # 非参数合规性检查
'parameter_compliance_check', # 参数合规性检查
]
review_item_config = [
'basis_sensitive_word_check', # 编制依据章节-词句语法检查
'plan_semantic_logic_check', # 施工计划章节-语义逻辑审查
'catalogue_completeness_check', # 目录章节-完整性检查(特殊规则)
]
#### 审查模式配置
ini [ai_review] MAX_REVIEW_UNITS=5 # 最大审查单元数量(0=全部审查) REVIEW_MODE=all # 审查模式: all/random/first
#### 工程方案类型
python supported_types = {
'01_pf_Found_Rotary_Drill', # 旋挖钻机、冲击钻机成孔桩
'02_pf_Dig_Manual_Pile', # 人工挖孔桩
'03_bd_Sub_Cyl_Pier', # 圆柱墩、系梁、盖梁
# ... 共13种工程方案类型
}
### 3. AI审查工作流 (core/construction_review/component/workflows/ai_review_workflow.py)
AIReviewWorkflow (基于LangGraph的审查工作流) ├── 构建审查子图 │ ├── 添加审查节点(每种审查类型一个节点) │ ├── 设置节点间转换关系 │ └── 编译为可执行图 │ ├── 审查节点类型 │ ├── 单元级审查节点 │ │ ├── 文档分块 │ │ ├── 并发执行各类审查器 │ │ ├── 汇总审查结果 │ │ └── 计算风险等级 │ │ │ └── 章节级审查节点 │ ├── 提取章节内容 │ ├── 执行章节特定审查 │ └── 生成章节审查结果 │ └── 审查器集合 (reviewers/)
├── base_reviewer.py # 基础审查器
├── check_completeness/ # 完整性检查组件
├── catalogues_check/ # 目录审查组件
└── utils/ # 审查工具函数
### 4. RAG检索增强流程
RAG检索增强 │ ├── 1. 查询重写 (query_rewrite_manager) │ └── 优化原始查询以提高检索质量 │ ├── 2. 实体增强 (entity_enhance) │ └── 识别文档实体并增强查询 │ ├── 3. 向量检索 (MilvusManager) │ ├── vector_search() # 纯向量检索 │ └── hybrid_search() # 混合检索(向量+关键词) │ ├── 4. 父块召回 (enhance_with_parent_docs_grouped) │ └── 返回父块上下文信息 │ └── 5. 重排序 (rerank_results)
└── 使用Rerank模型优化结果排序
### 5. 审查结果数据结构
python {
"callback_task_id": "file_id-timestamp",
"file_id": "original_file_id",
"file_name": "document.pdf",
"user_id": "user-001",
"overall_task_status": "completed", # processing/completed/failed/terminated
"stage_status": {
"document": "completed",
"ai_review": "completed",
"report": "completed"
},
"document_result": {
"structured_content": {...},
"parsed_sections": [...]
},
"ai_review_result": {
"review_results": [
{
"unit_index": 0,
"unit_content": {...},
"review_items": [
{
"check_type": "semantic_logic_check",
"risk_level": "high",
"issues": [...],
"suggestions": [...]
}
]
}
],
"summary": {...}
},
"report_result": {
"report_path": "/path/to/report.json",
"summary": "审查报告摘要"
},
"timestamp": "2026-02-03T12:00:00"
}
---
## SSE实时推送机制
### SSE连接管理 (core/base/sse_manager.py)
unified_sse_manager (统一SSE管理器) ├── establish_connection() # 建立SSE连接并注册回调 ├── send_progress() # 发送进度更新 ├── close_connection() # 关闭SSE连接 └── connection_registry # 连接注册表 {callback_task_id: queue}
### SSE事件类型
python
"connected" # SSE连接已建立 "connection_closed" # SSE连接已关闭
"processing" # 处理中(通用进度更新) "unit_review_update" # 单元审查更新 "processing_flag" # 处理标志
"submitted" # 任务已提交 "completed" # 任务已完成
"error" # 发生错误
### 进度推送流程
关闭SSE连接 unified_sse_manager.close_connection(callback_task_id)
---
## 任务终止机制
### 终止信号设置
python
async def set_terminate_signal(callback_task_id: str, operator: str) -> Dict:
"""
设置任务终止信号
- 写入Redis: ai_review:terminate_signal:{callback_task_id}
- 存储操作人和终止时间
- 设置2小时过期时间
"""
### 终止信号检测
python async def check_terminate_signal(callback_task_id: str) -> bool:
"""
检查是否有终止信号
- 从Redis读取终止信号
- 每个工作流节点执行前调用
- 检测到信号后进入终止流程
"""
### 终止流程
返回终止状态 overall_task_status: "terminated"
---
## 部署架构
### 开发环境
启动命令: python server/app.py
启动流程:
依赖服务:
本地AI模型服务 (192.168.91.253:9002)
### 生产环境
部署方式: Docker + Docker Compose
启动命令: docker-compose up -d
服务组件:
milvus: Milvus向量数据库
### 容器化部署
docker-compose up -d ```
| 模块 | 路径 | 说明 |
|---|---|---|
| 施工方案编写 | core/construction_write/ |
大纲生成、内容编写工作流 |
| 编写API | views/construction_write/ |
大纲/补全/重生成/取消/推荐接口 |
| 数据脱敏 | component/desensitize/ |
四维度脱敏(PII/地理/业务/财务)+ 反向映射 |
| 简化管道 | component/minimal_pipeline/ |
PDF提取、OCR(解耦)、目录构建/检测 |
| 标准匹配 | component/standard_matching/ |
标准规范DAO与服务层 |
| 智能分类 | doc_worker/classification/ |
分块/层级/本地三种分类策略 |
| LLM分类器v2 | reviewers/utils/llm_content_classifier_v2/ |
LLM驱动的内容分类,含补充验证机制 |
| LLM链式客户端 | reviewers/utils/llm_chain_client/ |
多厂商(DeepSeek/豆包/Gemini/Qwen)链式调用框架 |
| 核心函数 | workflows/core_functions/ |
AI审查核心业务逻辑抽离 |
| 状态类型 | workflows/types/ |
AIReviewState、TaskChainState 定义 |
| 审查器 | 说明 |
|---|---|
standard_timeliness_reviewer.py |
标准时效性审查 |
timeliness_content_reviewer.py |
时效性内容审查 |
sensitive_word_check.py |
敏感词检查 |
| 组件 | 说明 |
|---|---|
foundation/observability/cachefiles/ |
缓存文件管理 |
foundation/observability/monitoring/rag/ |
RAG管道监控 |
foundation/ai/models/model_config_loader.py |
模型配置加载器 |
foundation/utils/md5.py |
MD5工具 |
config/model_setting.yaml |
模型设置配置 |
config/yolo/ |
YOLO模型权重 |
ai_review_engine.py 核心逻辑部分抽离至 core_functions/ai_review_core_fun.pyminimal_pipeline/ocr_processor.py 从PDF提取中解耦为独立模块llm_content_classifier_v2,支持 keywords 关键字扫描 + LLM补充验证llm_chain_client 框架统一 DeepSeek/豆包/Gemini/Qwen 多厂商调用desensitize/ 模块提供正向脱敏 + remapper.py 反向映射,保证审查结果可还原