feat(复习):标准思维导图生成与回忆对比
- 新增 review_standard_mind_maps / review_recall_records 数据表 - BuiltinMindMapGenerator:从报告/残片/应用场景规则生成标准导图 - MindMapAiClient 接口 + RemoteAiMindMapClient 预留 - StandardMindMapService:生成/编辑/重新生成/回忆对比 - 对比算法:标题归一化 + Bigram Jaccard 模糊匹配 - ReviewController 新增 6 个端点 - MindMapTreeTool / MindMapNode / CompareResult 工具类 - 完整单元测试(10 个,全部通过) - 更新 docs/review-module-design.md
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package com.guo.learningprogresstracker.service.impl;
|
||||
|
||||
import com.guo.learningprogresstracker.entity.StudyReportFragmentsEntity;
|
||||
import com.guo.learningprogresstracker.entity.StudyReportsEntity;
|
||||
import com.guo.learningprogresstracker.entity.TaskApplicationEntity;
|
||||
import com.guo.learningprogresstracker.entity.TaskEntity;
|
||||
import com.guo.learningprogresstracker.service.MindMapAiClient;
|
||||
import com.guo.learningprogresstracker.utils.MindMapNode;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 远程 AI 思维导图生成客户端(预留实现)。
|
||||
* <p>通过 {@code lpt.ai.endpoint} / {@code lpt.ai.api-key} 配置;未配置时不可用,
|
||||
* 上层服务会回退到 {@link BuiltinMindMapGenerator}。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "lpt.ai")
|
||||
@Setter
|
||||
public class RemoteAiMindMapClient implements MindMapAiClient {
|
||||
|
||||
/** AI 服务端点 */
|
||||
private String endpoint;
|
||||
/** API Key */
|
||||
private String apiKey;
|
||||
/** 模型名称 */
|
||||
private String model = "claude-fable-5";
|
||||
/** 超时秒数 */
|
||||
private int timeoutSeconds = 60;
|
||||
|
||||
private boolean enabled = false;
|
||||
|
||||
@PostConstruct
|
||||
void init() {
|
||||
enabled = apiKey != null && !apiKey.isBlank() && endpoint != null && !endpoint.isBlank();
|
||||
if (enabled) {
|
||||
log.info("RemoteAiMindMapClient 已启用: endpoint={}, model={}", endpoint, model);
|
||||
} else {
|
||||
log.info("RemoteAiMindMapClient 未配置,将使用内置生成器");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generatorName() {
|
||||
return "AI-" + model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<MindMapNode> generate(TaskEntity task,
|
||||
List<StudyReportsEntity> reports,
|
||||
List<StudyReportFragmentsEntity> fragments,
|
||||
List<TaskApplicationEntity> applications,
|
||||
String clientHint) {
|
||||
if (!enabled) {
|
||||
return Optional.empty();
|
||||
}
|
||||
// TODO: 调用远程 AI API,构造 prompt 发送 reports/fragments
|
||||
// RestClient.create().post().uri(endpoint).body(prompt).retrieve()
|
||||
log.warn("RemoteAiMindMapClient: 远程 AI 调用尚未实现,请配置 API Key 并实现请求逻辑");
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user