diff --git a/README.md b/README.md index 7dbf7eb..f1ae178 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,140 @@ -# React + TypeScript + Vite +# Regulation RAG - 法规合规智能分析系统 -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. +一个基于 RAG (Retrieval-Augmented Generation) 技术的法规合规智能分析与问答系统原型。支持文档上传、语义分段分析、法规匹配标注、风险评估及交互式合规问答。 -Currently, two official plugins are available: +## 功能特性 -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) +### 📋 合规分析 (Compliance) +- **文档上传与解析** - 支持 PDF、DOCX、TXT 格式文档上传 +- **AI 语义分段** - 自动识别文档语义段落与设计意图 +- **法规匹配标注** - 根据段落内容匹配相关法规条款,计算相关性得分 +- **风险仪表盘** - 可折叠的风险评估面板,展示合规评分、高风险项、待修改段落 +- **优先行动建议** - 基于风险等级生成修改建议列表 -## React Compiler +### 💬 RAG 对话 (Rag Chat) +- **法规问答** - 基于向量检索的法规问答系统 +- **快捷问题** - 预设常用问题快速提问 +- **检索片段展示** - 右侧面板实时显示引用的法规片段及相似度得分 +- **答案重生成** - 支持重新生成上一个回答 -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). +### 📚 文档管理 (Docs) +- **文档上传** - 支持多种格式文档导入 +- **索引状态** - 显示已索引文档列表及分块数量 +- **处理流水线** - 展示 Load → Parse → Chunk → Embed → Store 全流程状态 -## Expanding the ESLint configuration +### 📊 系统状态 (Status) +- **系统统计** - 文档数、分块数、向量维度、条款数 +- **配置展示** - LLM 模型、Embedding 模型、向量数据库、检索策略等参数 -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: +## 技术栈 -```js -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... +- **前端框架**: React 19 + TypeScript +- **构建工具**: Vite 8 +- **样式方案**: TailwindCSS 4 +- **状态管理**: React Context API - // Remove tseslint.configs.recommended and replace with this - tseslint.configs.recommendedTypeChecked, - // Alternatively, use this for stricter rules - tseslint.configs.strictTypeChecked, - // Optionally, add this for stylistic rules - tseslint.configs.stylisticTypeChecked, +## 快速开始 - // Other configs... - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) +### 安装依赖 + +```bash +npm install ``` -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: +### 开发模式 -```js -// eslint.config.js -import reactX from 'eslint-plugin-react-x' -import reactDom from 'eslint-plugin-react-dom' - -export default defineConfig([ - globalIgnores(['dist']), - { - files: ['**/*.{ts,tsx}'], - extends: [ - // Other configs... - // Enable lint rules for React - reactX.configs['recommended-typescript'], - // Enable lint rules for React DOM - reactDom.configs.recommended, - ], - languageOptions: { - parserOptions: { - project: ['./tsconfig.node.json', './tsconfig.app.json'], - tsconfigRootDir: import.meta.dirname, - }, - // other options... - }, - }, -]) +```bash +npm run dev ``` + +启动本地开发服务器,默认访问 `http://localhost:5173` + +### 构建生产版本 + +```bash +npm run build +``` + +### 预览生产版本 + +```bash +npm run preview +``` + +## 项目结构 + +``` +src/ +├── components/ +│ ├── common/ # 通用组件 (Logo, Pattern, ThemeToggle) +│ ├── layout/ # 布局组件 (Header, Tabs, Content) +│ └── ui/ # UI 基础组件 (Badge, Button, Card, Input...) +├── contexts/ # React Context (AppContext, ThemeContext) +├── data/ # Mock 数据 +├── pages/ +│ ├── Compliance/ # 合规分析页面 +│ ├── Docs/ # 文档管理页面 +│ ├── RagChat/ # RAG 对话页面 +│ └── Status/ # 系统状态页面 +├── styles/ # 全局样式 +├── types/ # TypeScript 类型定义 +└── App.tsx # 应用入口 +``` + +## 核心类型定义 + +```typescript +// 法规信息 +interface Regulation { + id: number; + name: string; // 法规名称 + clause: string; // 条款编号 + score: number; // 相关性得分 (0-1) + matchKeyword: string; // 匹配关键词 + category: 'high' | 'medium' | 'low'; // 相关性等级 + fullContent: string; // 法规完整内容 +} + +// 语义段落 +interface ComplianceChunk { + id: number; + index: number; // 段落序号 + intent: string; // 段落意图 + startPos: number; // 文档起始位置 + endPos: number; // 文档结束位置 + content: string; // 段落内容 + regulations: Regulation[]; +} + +// 风险仪表盘数据 +interface RiskDashboardData { + score: number; // 合规评分 + highRiskCount: number; // 高风险项数量 + mediumRiskCount: number; + lowRiskCount: number; + needFixSegments: number;// 待修改段落数 + status: 'pass' | 'warning' | 'fail'; + statusLabel: string; // 状态标签 + segmentRisks: SegmentRisk[]; +} +``` + +## 界面设计 + +- **主题**: 支持深色/浅色主题切换 +- **配色**: T-Mobile 品牌色系 (E20074 主色调) +- **布局**: 响应式设计,固定 Header + Tab 导航 +- **交互**: 卡片式布局,悬浮效果,进度条动画 + +## 注意事项 + +本项目为原型演示系统,使用 Mock 数据模拟后端服务。生产环境需接入: + +- 文档解析服务 +- 向量数据库 (如 ChromaDB、Milvus) +- Embedding 模型 API +- LLM 服务 API + +## License + +MIT