feat(思维导图):AI 生成接入 lpt-ai 服务
RemoteAiMindMapClient 原为 TODO 空桩,依赖 lpt.ai.endpoint/api-key 配置,从未生效。现改为依赖 AiServiceClient(lpt.ai-service.url), 调用 lpt-ai 的 /ai/generate-mind-map 接口获取 AI 大纲。 变更: - AiServiceClient 新增 generateMindMap():调用 POST /ai/generate-mind-map - RemoteAiMindMapClient 重写:注入 AiServiceClient,isAvailable() 改为检查 AiServiceClient.isConfigured(),generate() 用 lpt-ai 返回的大纲文本解析为 MindMapNode 树 - StandardMindMapServiceImpl.doGenerate():优先选 AI 客户端 (非 BUILTIN),AI 失败时自动降级到内置规则引擎 - application.yml:移除不再使用的 lpt.ai.endpoint/api-key 配置
This commit is contained in:
+12
-2
@@ -251,10 +251,10 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
throw new OperationFailedException("任务[" + taskNum + "]没有学习报告或残片,无法生成思维导图");
|
||||
}
|
||||
|
||||
// 找可用的 AI 客户端
|
||||
// 优先选 AI 客户端(非 BUILTIN),其次内置生成器
|
||||
MindMapAiClient client = aiClients.stream()
|
||||
.filter(MindMapAiClient::isAvailable)
|
||||
.findFirst()
|
||||
.min(Comparator.comparing(c -> "BUILTIN".equals(c.generatorName()) ? 1 : 0))
|
||||
.orElse(null);
|
||||
|
||||
if (client == null) {
|
||||
@@ -262,6 +262,16 @@ public class StandardMindMapServiceImpl implements StandardMindMapService {
|
||||
}
|
||||
|
||||
Optional<MindMapNode> optRoot = client.generate(task, reports, fragments, applications, null);
|
||||
// AI 生成失败时尝试降级到内置生成器
|
||||
if (optRoot.isEmpty() && !"BUILTIN".equals(client.generatorName())) {
|
||||
log.info("AI 思维导图生成失败,降级到内置生成器");
|
||||
MindMapAiClient fallback = aiClients.stream()
|
||||
.filter(c -> "BUILTIN".equals(c.generatorName()) && c.isAvailable())
|
||||
.findFirst().orElse(null);
|
||||
if (fallback != null) {
|
||||
optRoot = fallback.generate(task, reports, fragments, applications, null);
|
||||
}
|
||||
}
|
||||
if (optRoot.isEmpty()) {
|
||||
throw new OperationFailedException("思维导图生成失败");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user