三重一大生成接口优化
This commit is contained in:
@@ -3,6 +3,7 @@ package com.gxwebsoft.ai.service.impl;
|
||||
import com.aliyun.bailian20231229.Client;
|
||||
import com.aliyun.bailian20231229.models.CreateIndexResponse;
|
||||
import com.aliyun.bailian20231229.models.DeleteIndexDocumentResponse;
|
||||
import com.aliyun.bailian20231229.models.DeleteIndexResponse;
|
||||
import com.aliyun.bailian20231229.models.ListIndexDocumentsResponse;
|
||||
import com.aliyun.bailian20231229.models.ListIndicesResponse;
|
||||
import com.aliyun.bailian20231229.models.RetrieveResponse;
|
||||
@@ -21,6 +22,8 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -82,6 +85,12 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||
throw new RuntimeException("创建知识库失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createKnowledgeBaseTemp() {
|
||||
String code = "Temp_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("MMddHHmmssSSS"));
|
||||
return createKnowledgeBase(code, code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsKnowledgeBase(String companyCode) {
|
||||
@@ -129,6 +138,18 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteIndex(String kbId) {
|
||||
String workspaceId = config.getWorkspaceId();
|
||||
try {
|
||||
Client client = clientFactory.createClient();
|
||||
DeleteIndexResponse indexDocumentResponse = KnowledgeBaseUtil.deleteIndex(client, workspaceId, kbId);
|
||||
return indexDocumentResponse.getBody().getSuccess();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("删除知识库失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteIndexDocument(String kbId, String fileIds) {
|
||||
String workspaceId = config.getWorkspaceId();
|
||||
@@ -170,6 +191,17 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
|
||||
throw new RuntimeException("添加文档到知识库失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitDocuments(String kbId, List<String> fileIds) {
|
||||
String workspaceId = config.getWorkspaceId();
|
||||
try {
|
||||
Client client = clientFactory.createClient();
|
||||
AiCloudKnowledgeBaseUtil.submitIndexAddDocumentsJob(client, workspaceId, kbId, fileIds);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("添加文档到知识库失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user