添加工作索引文件真实约束
This commit is contained in:
@@ -259,6 +259,13 @@ public abstract class AbstractAuditContentService {
|
||||
*/
|
||||
private List<String> processNodesToResults(List<RetrieveResponseBodyDataNodes> nodes, Map<String, String> fileUrlMap) {
|
||||
Set<String> results = new LinkedHashSet<>();
|
||||
|
||||
// 构建可用文件列表
|
||||
StringBuilder fileListBuilder = new StringBuilder();
|
||||
fileListBuilder.append("\n\n**可用真实文件列表(仅限以下文件,不得虚构其他文件名):**\n");
|
||||
|
||||
Set<String> processedFiles = new HashSet<>(); // 避免重复
|
||||
|
||||
for (RetrieveResponseBodyDataNodes node : nodes) {
|
||||
try {
|
||||
// 检查文本有效性
|
||||
@@ -271,27 +278,44 @@ public abstract class AbstractAuditContentService {
|
||||
String docName = extractDocumentName(node);
|
||||
String docId = extractDocumentId(node);
|
||||
String fileUrl = fileUrlMap.get(docId);
|
||||
if(StrUtil.isBlank(fileUrl)) {
|
||||
fileUrl = extractDocumentUrl(node);
|
||||
if (StrUtil.isBlank(fileUrl)) {
|
||||
fileUrl = extractDocumentUrl(node);
|
||||
}
|
||||
if(StrUtil.isBlank(fileUrl)) {
|
||||
fileUrl = "无链接";
|
||||
if (StrUtil.isBlank(fileUrl)) {
|
||||
fileUrl = "无链接";
|
||||
}
|
||||
|
||||
// 处理文件URL为空的情况
|
||||
// String url = StrUtil.isNotBlank(fileUrl) ? fileUrl : "无";
|
||||
// 格式化结果
|
||||
// String formattedText = String.format("《%s》【FileUrl:%s】%s", docName, url, text);
|
||||
// 添加文件名到列表(去重)
|
||||
if (StrUtil.isNotBlank(docName) && !processedFiles.contains(docName)) {
|
||||
processedFiles.add(docName);
|
||||
fileListBuilder.append("- 《").append(docName).append("》");
|
||||
if (!"无链接".equals(fileUrl)) {
|
||||
fileListBuilder.append(" || ").append(fileUrl);
|
||||
}
|
||||
fileListBuilder.append("\n");
|
||||
}
|
||||
|
||||
// 格式化为知识库内容
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("document_name", docName);
|
||||
json.put("file_url", fileUrl);
|
||||
json.put("content", text);
|
||||
String formattedText = json.toJSONString();
|
||||
results.add(formattedText);
|
||||
|
||||
} catch (Exception 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user