auto(11bf28807ce8): session end @ 2026-07-03T13:41:56 (+3f)
This commit is contained in:
1 parent
708373aee7
commit
b096e0a10d
3 files changed
+68
-1
No files matched your search
@@ -63,4 +63,18 @@ public interface AIRepairService {
|
||||
* @return VisualAiModel 兼容结构: {enCode, fullName, aiModelList}
|
||||
*/
|
||||
Map<String, Object> inferFields(String tableName, String fieldDesc);
|
||||
|
||||
/**
|
||||
* v0.15+ (2026-07-03): 推理表单业务分类 (dacli form --ai / --table 通用)
|
||||
*
|
||||
* 根据应用名+表单名, 从可选分类列表中选最合适的.
|
||||
* 不需要 LLM — 简单的 JSON 解析+匹配, 纯规则即可 (AI 过度).
|
||||
* 但未来 AI 能区分更 subtle 的分类 (e.g. "采购审批" → 项目管理 vs 费用相关).
|
||||
*
|
||||
* @param formName 表单中文名 (如 "用户管理")
|
||||
* @param appCode 应用编码 (如 "testspace")
|
||||
* @param categories 可选分类列表 JSON 字符串 (如 '[{"id":"x","fullName":"车辆管理"},...]')
|
||||
* @return {id, fullName} 最佳分类 (LLM 返回)
|
||||
*/
|
||||
Map<String, Object> inferCategory(String formName, String appCode, String categories);
|
||||
}
|
||||
+24
-1
@@ -444,4 +444,27 @@ public class AIRepairServiceImpl implements AIRepairService {
|
||||
"- 跳过: signature/editor/uploadImg/uploadFile (只适合表单, 不适合列表展示)\n" +
|
||||
"- 跳过: switch/checkbox (列表搜索不合适)\n" +
|
||||
"\n" +
|
||||
"请只返回 JSON, 不要 markdown 包裹.";}
|
||||
"请只返回 JSON, 不要 markdown 包裹.";
|
||||
|
||||
@Override
|
||||
public Map<String, Object> inferCategory(String formName, String appCode, String categories) {
|
||||
log.info("[AIRepair-inferCategory] form={}, app={}", formName, appCode);
|
||||
String userPrompt = String.format("表单" + formName + "(应用:" + appCode + "), 可选分类: " + categories);
|
||||
String raw = llmClient.chat("", userPrompt);
|
||||
if (raw == null || raw.isEmpty()) {
|
||||
log.warn("[AIRepair-inferCategory] LLM 返回空");
|
||||
return new HashMap<>();
|
||||
}
|
||||
try {
|
||||
Map<String, Object> result = JSON.parseObject(raw.trim(),
|
||||
new TypeReference<Map<String, Object>>() {});
|
||||
if (result != null && result.containsKey("fullName")) {
|
||||
log.info("[AIRepair-inferCategory] AI 选择: {}", result.get("fullName"));
|
||||
return result;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("[AIRepair-inferCategory] JSON 解析失败: {}", e.getMessage());
|
||||
}
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
+30
@@ -118,4 +118,34 @@ public class SswAIRepairController {
|
||||
return ActionResult.fail("字段推理异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.15+ (2026-07-03): 业务分类推理 (dacli form --ai / --table 通用)
|
||||
*
|
||||
* 根据表单名+应用名, 从可选分类列表中选择最合适的业务分类.
|
||||
*
|
||||
* 请求: {formName: "用户管理", appCode: "testspace", categories: "[{\"id\":\"x\",\"fullName\":\"车辆管理\"},...]"}
|
||||
* 响应: {id: "xxx", fullName: "车辆管理"}
|
||||
*/
|
||||
@PostMapping("/infer-category")
|
||||
@Operation(summary = "业务分类推理", description = "根据表单+应用名从可选分类中选最合适的")
|
||||
public ActionResult<Map<String, Object>> inferCategory(@RequestBody Map<String, Object> body) {
|
||||
String formName = (String) body.get("formName");
|
||||
String appCode = (String) body.get("appCode");
|
||||
String categories = (String) body.get("categories");
|
||||
if (formName == null || categories == null) {
|
||||
return ActionResult.fail("formName 和 categories 必填");
|
||||
}
|
||||
try {
|
||||
Map<String, Object> result = aiRepairService.inferCategory(
|
||||
formName, appCode != null ? appCode : "", categories);
|
||||
if (result.isEmpty() || !result.containsKey("fullName")) {
|
||||
return ActionResult.fail("分类推理失败, 返回空结果");
|
||||
}
|
||||
return ActionResult.success(result);
|
||||
} catch (Exception e) {
|
||||
log.error("SswAIRepairController.inferCategory 异常", e);
|
||||
return ActionResult.fail("分类推理异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user