F-08-call-orchestration.json
14.4 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
{
"id": "F-08",
"title": "LLM 调用编排服务",
"fileKey": "call-orchestration",
"note": "核心业务编排服务。接收调用请求→匹配模型账号配置→加载提示词模板→组装请求参数→调用 T-03 适配引擎→记录调用日志。支持同步(直接返回)和异步(提交 Celery 任务)两种模式。支持 6 种模板类型:通用文本(templateId=1)、质检(2)、图像输入(3)、带参文本(4)、录音总结(5)、员工复盘(6)。<br><br>复用自 Java 项目:AgiService.launchLLM() / launchTask() / runSyncTask() / runQualityInspectionJob() 完整编排逻辑。",
"op_count": 6,
"scenarios": [
{
"title": "同步调用:接收请求→匹配配置→调用模型→返回结果(全程阻塞等待)",
"required": true,
"precondition": "系统已配置至少 1 个有效的模型账号和策略",
"expect": "同步返回模型调用结果;call_records 表新增调用记录",
"tab": "admin",
"steps": [
{
"op": "OP-F-08.1.1",
"status": "done",
"tab": "admin",
"changelog": {"id": "CHG-021", "date": "2026-06-17", "reason": "prompt 渲染后新增敏感词替换步骤"},
"nav": [
"管理后台",
"LLM 调用编排服务",
"sync"
],
"actions": [
"登录管理后台",
"进入「LLM 调用编排服务」模块",
"执行操作"
],
"backend": [
{
"tag": "receive",
"text": "接收 POST /api/v1/calls/sync 请求"
},
{
"tag": "validate",
"text": "验证请求参数"
},
{
"tag": "query",
"text": "从数据库表按条件查询记录"
},
{
"tag": "write",
"text": "向数据库表插入新记录"
},
{
"tag": "write",
"text": "向数据库表插入新记录"
},
{
"tag": "receive",
"text": "Prompt 渲染后调用敏感词替换:查询所有已启用敏感词(enabled=True),对 system_prompt 和 user_prompt 做替换处理"
},
{
"tag": "return",
"text": "返回操作结果"
}
],
"expected": [
"同步返回模型调用结果",
"call_records 表新增调用记录"
]
}
]
},
{
"title": "异步调用:接收请求→创建任务记录→提交 Celery→返回 taskId",
"required": true,
"precondition": "系统已配置至少 1 个有效的模型账号和策略",
"expect": "返回 taskId;async_tasks 表新增任务记录",
"tab": "admin",
"steps": [
{
"op": "OP-F-08.2.1",
"status": "done",
"tab": "admin",
"changelog": {"id": "CHG-021", "date": "2026-06-17", "reason": "prompt 渲染后新增敏感词替换步骤"},
"nav": [
"管理后台",
"LLM 调用编排服务",
"async"
],
"actions": [
"登录管理后台",
"进入「LLM 调用编排服务」模块",
"执行操作"
],
"backend": [
{
"tag": "receive",
"text": "接收 POST /api/v1/calls/async 请求"
},
{
"tag": "validate",
"text": "验证必填字段和参数格式"
},
{
"tag": "write",
"text": "向数据库表插入新记录"
},
{
"tag": "write",
"text": "向数据库表插入新记录"
},
{
"tag": "receive",
"text": "Prompt 渲染后调用敏感词替换:查询所有已启用敏感词(enabled=True),对 system_prompt 和 user_prompt 做替换处理"
},
{
"tag": "return",
"text": "返回操作结果"
}
],
"expected": [
"返回 taskId",
"async_tasks 表新增任务记录"
]
}
]
},
{
"title": "查询异步调用结果(轮询模式,适配现有系统的 queryTaskResult)",
"required": true,
"precondition": "系统存在至少 1 条异步调用记录",
"expect": "返回异步任务的执行结果和状态",
"tab": "admin",
"steps": [
{
"op": "OP-F-08.3.1",
"status": "notimpl",
"tab": "admin",
"nav": [
"管理后台",
"LLM 调用编排服务",
"query"
],
"actions": [
"登录管理后台",
"进入「LLM 调用编排服务」模块",
"执行操作"
],
"backend": [
{
"tag": "receive",
"text": "接收 GET /api/v1/calls/async/:task_id 请求"
},
{
"tag": "validate",
"text": "验证请求参数"
},
{
"tag": "query",
"text": "从数据库表按条件查询记录"
},
{
"tag": "return",
"text": "返回操作结果"
}
],
"expected": [
"返回异步任务的执行结果和状态"
]
}
]
},
{
"title": "批量查询多个异步调用结果",
"required": true,
"precondition": "系统存在至少 3 条异步调用记录",
"expect": "返回多个异步任务的结果列表",
"tab": "admin",
"steps": [
{
"op": "OP-F-08.4.1",
"status": "notimpl",
"tab": "admin",
"nav": [
"管理后台",
"LLM 调用编排服务",
"batch"
],
"actions": [
"登录管理后台",
"进入「LLM 调用编排服务」模块",
"执行操作"
],
"backend": [
{
"tag": "receive",
"text": "接收 POST /api/v1/calls/async/batch 请求"
},
{
"tag": "validate",
"text": "验证请求参数"
},
{
"tag": "query",
"text": "从数据库表按条件查询记录"
},
{
"tag": "return",
"text": "返回操作结果"
}
],
"expected": [
"返回多个异步任务的结果列表"
]
}
]
},
{
"title": "质检融合:将 LLM 质检结果与规则配置按维度融合计算总分",
"required": true,
"precondition": "系统已配置质检规则",
"expect": "操作执行成功",
"tab": "api",
"steps": [
{
"op": "OP-F-08.5.1",
"status": "done",
"tab": "api",
"nav": [
"API 客户端",
"质检融合:将 LLM 质检结果与规则配置按维度融合计算总分"
],
"actions": [
"准备 API Token",
"构造请求",
"发送请求"
],
"backend": [
{
"tag": "receive",
"text": "接收 GET 内部调用 请求"
},
{
"tag": "validate",
"text": "验证请求参数"
},
{
"tag": "query",
"text": "从数据库表按条件查询记录"
},
{
"tag": "return",
"text": "返回操作结果"
}
],
"expected": [
"操作执行成功"
]
}
]
},
{
"title": "业务调用(by-template):提供 template_id(支持UUID/业务编码) + account_id(支持UUID/业务编码) + content + mode,系统自动完成编排",
"required": true,
"precondition": "系统存在至少 1 个已发布的提示词模板和 1 个有效账号",
"expect": "sync 模式直接返回 LLM 响应结果;async 模式返回 task_id",
"tab": "api",
"steps": [
{
"op": "OP-F-08.6.1",
"status": "done",
"changelog": {"id": "CHG-031", "date": "2026-06-29", "reason": "创建 CallRecord 时设置 biz_type = prompt_template.code"},
"tab": "api",
"nav": [
"API 客户端",
"业务调用(by-template)",
"sync"
],
"actions": [
"准备 API Token",
"构造请求体:template_id(传入 UUID 或业务编码如 TEMPLATE-GENERAL-002)+ account_id(传入 UUID 或业务编码如 LEGACY-xxx)+ content + mode=\"sync\"",
"发送 POST /api/v1/calls/by-template"
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/calls/by-template 请求"},
{"tag": "validate", "text": "验证 content/mode 必填字段,校验 template_id 和 account_id 至少提供"},
{"tag": "query", "text": "根据 template_id 查询:先尝试按 UUID 匹配 prompt_templates 表,未找到则按 code 匹配"},
{"tag": "query", "text": "根据 account_id 查询:先尝试按 UUID 匹配 model_account_config 表,未找到则按 code 匹配"},
{"tag": "write", "text": "构建消息:system_prompt 从模板加载,user message = content"},
{"tag": "receive", "text": "敏感词替换:调用 word_bank_service.list_active_words() 获取所有已启用敏感词,对 system_prompt 和 user_prompt 做替换处理"},
{"tag": "validate", "text": "mode=sync → 直接调用 adapter_invoke 同步调用模型。adapter_invoke 内部读取账号 extra_config.thinking_enabled,若开启则注入思考模式参数"},
{"tag": "write", "text": "创建 CallRecord 调用记录(status=success/failed),设置 biz_type = prompt_template.code"},
{"tag": "return", "text": "返回 {status, model_name, call_record_id, account_id, response_content(大模型原始返回内容字符串)}"}
],
"expected": [
"同步返回模型调用结果,response_content 为 LLM 原始内容字符串",
"如果账号开启了思考模式,模型响应中体现推理过程",
"call_records 表新增调用记录"
]
},
{
"op": "OP-F-08.6.2",
"status": "done",
"changelog": {"id": "CHG-031", "date": "2026-06-29", "reason": "创建 CallRecord 时设置 biz_type = prompt_template.code"},
"tab": "api",
"nav": [
"API 客户端",
"业务调用(by-template)",
"async"
],
"actions": [
"准备 API Token",
"构造请求体:template_id(传入 UUID 或业务编码)+ account_id(传入 UUID 或业务编码)+ content + mode=\"async\"",
"发送 POST /api/v1/calls/by-template"
],
"backend": [
{"tag": "receive", "text": "接收 POST /api/v1/calls/by-template 请求(mode=async)"},
{"tag": "validate", "text": "验证必填字段,校验 template_id 和 account_id 至少提供"},
{"tag": "query", "text": "根据 template_id 查询:先 UUID 匹配,未找到则按 code 匹配。account_id 同理"},
{"tag": "write", "text": "创建 AsyncTask 记录(status=pending),创建 CallRecord(设置 biz_type = prompt_template.code)"},
{"tag": "write", "text": "提交 Celery 任务 process_async_llm_call。Celery 任务内部执行:加载模板→渲染 prompt→敏感词替换→调用 LLM→更新 CallRecord"},
{"tag": "return", "text": "返回 {status: \"accepted\", task_id, call_record_id}"}
],
"expected": [
"返回 task_id",
"async_tasks 表新增任务记录(status=pending)"
]
}
]
}
],
"changelogs": [
{
"date": "2026-06-11",
"id": "IMPL-F-08",
"type": "implement",
"title": "F-08 LLM 调用编排服务首次实现",
"desc": "实现编排服务:prompt 渲染引擎、账号优先级匹配、同步/异步调用 API、批量查询 API。85 个测试全部通过。",
"done": true
},
{"date": "2026-06-16", "id": "CHG-011", "type": "add", "title": "新增业务侧直接调用接口", "desc": "新增 POST /api/v1/calls/by-template + 前端展示页面。OP-F-08.6.1 / OP-F-08.6.2。", "done": true},
{"date": "2026-06-16", "id": "CHG-012", "type": "modify", "title": "by-template 支持 code 查找", "desc": "POST /api/v1/calls/by-template 新增 template_code 和 account_code 参数。OP-F-08.6.1 / OP-F-08.6.2 → notimpl。", "done": true},
{"date": "2026-06-16", "id": "CHG-013", "type": "modify", "title": "template_id/account_id 统一接受 UUID 或业务编码", "desc": "template_id/account_id 同时支持 UUID 或业务编码,后端自动识别。移除 template_code/account_code 字段。OP-F-08.6.1 / OP-F-08.6.2 → notimpl。", "done": true},
{"date": "2026-06-16", "id": "CHG-014", "type": "modify", "title": "by-template 同步响应字段 response_body 改为 response_content", "desc": "sync 模式响应中 response_body 重命名为 response_content,值改为大模型原始字符串。OP-F-08.6.1 → notimpl。", "done": true},
{"date": "2026-06-16", "id": "CHG-015", "type": "modify", "title": "新增账号思考模式开关", "desc": "adapter_invoke 内部读取账号 extra_config.thinking_enabled 注入思考参数。OP-F-08.6.1 → notimpl。", "done": true},
{"date": "2026-06-17", "id": "CHG-021", "type": "modify", "title": "提示词组装集成敏感词替换", "desc": "四个编排步骤(OP-F-08.1.1/2.1/6.1/6.2)在 prompt 渲染后新增敏感词替换,调用 word_bank_service.list_active_words() 对 system_prompt 和 user_prompt 做替换处理。", "done": true},
{"date": "2026-06-29", "id": "CHG-031", "type": "modify", "title": "by-template 创建调用记录时 biz_type 自动设为模板业务编码", "desc": "OP-F-08.6.1 / OP-F-08.6.2 → notimpl。创建 CallRecord 时设置 biz_type = prompt_template.code。", "done": true}
]
}