M-03-prompt-templates.json
7.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
"id": "M-03",
"name": "提示词模板管理",
"fileKey": "prompt-templates",
"desc": "管理 System/User Prompt 模板,支持模板分类、变量占位符、版本号管理",
"apis": [
{
"method": "POST",
"path": "/api/v1/prompts",
"name": "新增模板",
"description": "新增提示词模板(类型/标题/System Prompt/User Prompt/变量定义)",
"params": [
{"name": "template_type", "in": "body", "type": "string", "required": true, "desc": "模板类型:general/quality_inspection/image/param_text/audio_summary/employee_review"},
{"name": "title", "in": "body", "type": "string", "required": true, "desc": "模板标题"},
{"name": "code", "in": "body", "type": "string", "required": true, "desc": "业务编码,手动配置的唯一标识(如 \"TEMPLATE-GENERAL-001\"),创建后不可修改"},
{"name": "system_prompt", "in": "body", "type": "string", "required": true, "desc": "System Prompt 内容"},
{"name": "user_prompt", "in": "body", "type": "string", "required": false, "desc": "User Prompt 内容"},
{"name": "variables", "in": "body", "type": "array", "required": false, "desc": "变量占位符定义,如 [{\"name\":\"content\", \"type\":\"string\"}]"}
],
"responses": [
{"code": 201, "desc": "创建成功", "schema": "Prompt"},
{"code": 400, "desc": "参数错误", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/prompts 请求"},
{"tag": "validate", "text": "验证必填字段和参数格式"},
{"tag": "write", "text": "向数据库表插入新记录"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "PUT",
"path": "/api/v1/prompts/:id",
"name": "编辑模板",
"description": "编辑模板内容,生成新版本号,保留历史版本",
"params": [
{"name": "id", "in": "path", "type": "string", "required": true, "desc": "模板 ID"},
{"name": "template_type", "in": "body", "type": "string", "required": false, "desc": "模板类型"},
{"name": "title", "in": "body", "type": "string", "required": false, "desc": "模板标题"},
{"name": "code", "in": "body", "type": "string", "required": false, "desc": "业务编码(仅创建时可设置,编辑时不生效)"},
{"name": "system_prompt", "in": "body", "type": "string", "required": false, "desc": "System Prompt 内容"},
{"name": "user_prompt", "in": "body", "type": "string", "required": false, "desc": "User Prompt 内容"},
{"name": "variables", "in": "body", "type": "array", "required": false, "desc": "变量占位符定义"},
{"name": "status", "in": "body", "type": "string", "required": false, "desc": "状态:draft/published/archived"}
],
"responses": [
{"code": 200, "desc": "更新成功", "schema": "Prompt"},
{"code": 400, "desc": "参数错误", "schema": ""},
{"code": 404, "desc": "模板不存在", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 PUT /api/v1/prompts/:id 请求"},
{"tag": "validate", "text": "验证记录存在和修改后的字段"},
{"tag": "write", "text": "将当前记录快照(system_prompt/user_prompt/variables/version)写入 ai_llmbase_prompt_template_versions 表"},
{"tag": "write", "text": "更新主表记录,version += 1"},
{"tag": "return", "text": "返回操作结果(含当前版本信息和版本总数)"}
]
},
{
"method": "DELETE",
"path": "/api/v1/prompts/:id",
"name": "删除模板",
"description": "软删除模板,将 status 改为 deleted,数据保留可恢复",
"params": [
{"name": "id", "in": "path", "type": "string", "required": true, "desc": "模板 ID"}
],
"responses": [
{"code": 200, "desc": "删除成功", "schema": ""},
{"code": 404, "desc": "模板不存在", "schema": ""},
{"code": 400, "desc": "模板已删除", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 DELETE /api/v1/prompts/:id 请求"},
{"tag": "validate", "text": "验证记录存在且当前 status 不是 deleted"},
{"tag": "write", "text": "更新主表 status=deleted"},
{"tag": "return", "text": "返回操作结果"}
]
},
{
"method": "GET",
"path": "/api/v1/prompts/:id",
"name": "模板详情",
"description": "查询模板详情及历史版本列表",
"params": [
{"name": "id", "in": "path", "type": "string", "required": true, "desc": "模板 ID"}
],
"responses": [
{"code": 200, "desc": "成功", "schema": "Prompt(含 versions 数组)"},
{"code": 404, "desc": "模板不存在", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 GET /api/v1/prompts/:id 请求"},
{"tag": "query", "text": "从主表查询单条记录"},
{"tag": "query", "text": "从 ai_llmbase_prompt_template_versions 表查询该模板的所有历史版本(按版本号倒序)"},
{"tag": "return", "text": "返回详情 + versions 数组(含每版的 system_prompt/user_prompt/variables/version/created_at)"}
]
},
{
"method": "GET",
"path": "/api/v1/prompts",
"name": "模板列表",
"description": "按类型/标题分页查询模板列表",
"params": [
{"name": "page", "in": "query", "type": "integer", "required": false, "desc": "页码"},
{"name": "page_size", "in": "query", "type": "integer", "required": false, "desc": "每页条数"},
{"name": "template_type", "in": "query", "type": "string", "required": false, "desc": "按模板类型筛选"},
{"name": "title", "in": "query", "type": "string", "required": false, "desc": "按标题模糊搜索"},
{"name": "status", "in": "query", "type": "string", "required": false, "desc": "按状态筛选:draft/published/archived"}
],
"responses": [
{"code": 200, "desc": "成功", "schema": "Prompt[]"},
{"code": 400, "desc": "参数错误", "schema": ""}
],
"backend": [
{"tag": "receive", "text": "接收 GET /api/v1/prompts 请求"},
{"tag": "validate", "text": "验证分页和筛选参数"},
{"tag": "query", "text": "从数据库表按条件查询记录"},
{"tag": "return", "text": "返回分页结果"}
]
}
],
"changelogs": [
{"date": "2026-06-16", "id": "CHG-012", "type": "add", "title": "新增 code 业务编码", "desc": "POST /api/v1/prompts 新增 code 必填参数;PUT /api/v1/prompts/:id 新增 code 可选参数(编辑时不生效);模板列表/详情接口返回 code 字段", "done": true},
{"date": "2026-06-17", "id": "CHG-017", "type": "modify", "title": "新增删除和版本历史 API", "desc": "新增 DELETE /api/v1/prompts/:id 软删除接口。PUT /api/v1/prompts/:id 编辑时保存版本快照。GET /api/v1/prompts/:id 返回时带 versions 数组。", "done": true},
{"date": "2026-06-17", "id": "CHG-018", "type": "modify", "title": "前端新增删除按钮", "desc": "前端 PromptList 操作列新增「删除」按钮,调用已存在的 DELETE /api/v1/prompts/:id 接口。API 无需变更。", "done": true}
]
}