添加工作索引文件真实约束

This commit is contained in:
2026-02-03 15:31:14 +08:00
parent b0d32c05d6
commit ddc1fa2dbd

View File

@@ -259,6 +259,13 @@ public abstract class AbstractAuditContentService {
*/ */
private List<String> processNodesToResults(List<RetrieveResponseBodyDataNodes> nodes, Map<String, String> fileUrlMap) { private List<String> processNodesToResults(List<RetrieveResponseBodyDataNodes> nodes, Map<String, String> fileUrlMap) {
Set<String> results = new LinkedHashSet<>(); Set<String> results = new LinkedHashSet<>();
// 构建可用文件列表
StringBuilder fileListBuilder = new StringBuilder();
fileListBuilder.append("\n\n**可用真实文件列表(仅限以下文件,不得虚构其他文件名):**\n");
Set<String> processedFiles = new HashSet<>(); // 避免重复
for (RetrieveResponseBodyDataNodes node : nodes) { for (RetrieveResponseBodyDataNodes node : nodes) {
try { try {
// 检查文本有效性 // 检查文本有效性
@@ -278,20 +285,37 @@ public abstract class AbstractAuditContentService {
fileUrl = "无链接"; fileUrl = "无链接";
} }
// 处理文件URL为空的情况 // 添加文件名到列表(去重)
// String url = StrUtil.isNotBlank(fileUrl) ? fileUrl : "无"; if (StrUtil.isNotBlank(docName) && !processedFiles.contains(docName)) {
// 格式化结果 processedFiles.add(docName);
// String formattedText = String.format("《%s》【FileUrl:%s】%s", docName, url, text); fileListBuilder.append("- 《").append(docName).append("");
if (!"无链接".equals(fileUrl)) {
fileListBuilder.append(" || ").append(fileUrl);
}
fileListBuilder.append("\n");
}
// 格式化为知识库内容
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("document_name", docName); json.put("document_name", docName);
json.put("file_url", fileUrl); json.put("file_url", fileUrl);
json.put("content", text); json.put("content", text);
String formattedText = json.toJSONString(); String formattedText = json.toJSONString();
results.add(formattedText); results.add(formattedText);
} catch (Exception e) { } catch (Exception e) {
log.warn("处理知识库节点失败", e); log.warn("处理知识库节点失败", e);
} }
} }
// 添加文件列表到结果
fileListBuilder.append("\n**重要约束:**\n");
fileListBuilder.append("1. 只能使用上述列表中的文件,不得虚构其他文件名\n");
fileListBuilder.append("2. 如果某项检查未涉及上述文件,则 workPaperIndex 填写\"[]\"\n");
fileListBuilder.append("3. 所有文件必须来自提供的知识库内容\n");
results.add(fileListBuilder.toString());
return new ArrayList<>(results); return new ArrayList<>(results);
} }