Jelajahi Sumber

增加文档

zhangqian 1 bulan lalu
induk
melakukan
46454becc3
2 mengubah file dengan 116 tambahan dan 0 penghapusan
  1. 6 0
      .idea/vcs.xml
  2. 110 0
      doc/README.md

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 110 - 0
doc/README.md

@@ -0,0 +1,110 @@
+根据您提供的表结构和流程描述,我为您生成以下技术文档:
+
+# Metric Process Config 配置表文档
+
+## 表结构说明
+
+**表名**: `metric_process_config`  
+**引擎**: InnoDB  
+**字符集**: utf8mb4  
+**排序规则**: utf8mb4_bin  
+**描述**: 指标处理配置表,用于定义意图识别后的处理流程
+
+## 字段详情
+
+| 字段名 | 类型 | 默认值 | 可空 | 注释 |
+|--------|------|--------|------|------|
+| id | int | - | NO | 主键,自增 |
+| type | tinyint | 0 | NO | **处理类型**: 0-HTTP请求, 1-直接回复 |
+| name | varchar(30) | '' | NO | 分支名称,用于标识配置项 |
+| intent | int | 0 | NO | 意图标识 |
+| metric_type | int | 0 | NO | 意图识别输出的类型编号 |
+| url_template | varchar(1000) | '' | NO | **URL模板**,支持变量替换 |
+| query_template | varchar(1000) | '' | NO | **请求参数模板**,GET/POST请求参数 |
+| http_method | tinyint | 0 | NO | **HTTP方法**: 0-GET, 1-POST |
+| response_extract | varchar(1000) | '' | NO | **响应提取配置**,JSON路径配置用于提取响应值 |
+| context_template | varchar(2000) | '' | NO | **中文输出模板**,最终展示的提示词模板 |
+| eng_context_template | varchar(2000) | '' | NO | **英文输出模板**,英文环境提示词模板 |
+| created_at | datetime | CURRENT_TIMESTAMP | NO | 创建时间 |
+| updated_at | datetime | CURRENT_TIMESTAMP | NO | 更新时间,自动更新 |
+| deleted_at | datetime | NULL | YES | 软删除时间戳 |
+
+## 业务流程说明
+
+### 整体处理流程
+```
+1. 接收水萝卜环境参数 → 2. 构造HTTP请求 → 3. 解析响应JSON → 4. 构造展示模板
+```
+
+### 详细步骤分解
+
+#### 步骤1: 接收环境参数
+- 系统接收来自水萝卜环境的输入参数
+- 根据参数匹配对应的意图(`intent`)和指标类型(`metric_type`)
+
+#### 步骤2: 构造HTTP请求
+- 根据配置的 `http_method` 选择请求方法:
+    - `0`: GET请求
+    - `1`: POST请求
+- 使用 `url_template` 构建完整URL
+- 使用 `query_template` 构建请求参数
+- **变量替换**: 模板中的占位符会被实际参数替换
+
+#### 步骤3: 解析响应JSON
+- 使用 `response_extract` 配置的JSON路径提取所需数据
+- 示例配置格式:
+```json
+{
+  "name": {"first": "Janet", "last": "Prichard"},
+  "age": 47
+}
+```
+- 支持嵌套JSON字段的提取
+
+#### 步骤4: 构造展示模板
+- 根据语言环境选择模板:
+    - 中文: `context_template`
+    - 英文: `eng_context_template`
+- 将提取的响应数据替换到模板变量中
+- 生成最终的用户展示内容
+
+## 配置示例
+
+### HTTP请求类型配置 (type=0)
+```sql
+INSERT INTO metric_process_config 
+(type, name, intent, metric_type, url_template, query_template, http_method, response_extract, context_template, eng_context_template) 
+VALUES 
+(0, '天气查询', 1001, 1, 'https://api.weather.com/forecast?city={city}', '{"api_key": "your_key"}', 1, 
+'{"temperature": "data.temp", "condition": "data.weather"}',
+'当前{city}温度:{temperature}℃,天气状况:{condition}', 
+'Current temperature in {city}: {temperature}°C, Condition: {condition}');
+```
+
+### 直接回复类型配置 (type=1)
+```sql
+INSERT INTO metric_process_config 
+(type, name, intent, metric_type, context_template, eng_context_template) 
+VALUES 
+(1, '欢迎语', 1002, 2, 
+'您好!欢迎使用我们的服务,请问有什么可以帮您?',
+'Hello! Welcome to our service, how can I help you?');
+```
+
+## 使用注意事项
+
+1. **URL模板**: 支持 `{variable}` 格式的变量替换
+2. **JSON提取**: 使用点号分隔的路径语法访问嵌套字段
+3. **模板变量**: 确保响应提取字段与模板变量名匹配
+4. **字符长度**: 注意各文本字段的长度限制
+5. **软删除**: 使用 `deleted_at` 进行逻辑删除,NULL表示有效记录
+
+## 相关接口建议
+
+基于此表结构,建议实现以下核心接口:
+- 配置查询接口(根据intent/metric_type查询)
+- 模板变量替换服务
+- HTTP请求构造器
+- JSON响应解析器
+
+这份文档涵盖了表结构说明、业务流程、配置示例和使用建议,可以作为开发和维护的参考文档。