|
@@ -58,7 +58,7 @@ public class DifyDatasetService {
|
|
|
/**
|
|
|
* 创建知识库
|
|
|
*/
|
|
|
- public void createDataset(DifyDataset difyDataset) throws IOException, DifyApiException {
|
|
|
+ public String createDataset(DifyDataset difyDataset) throws IOException, DifyApiException {
|
|
|
// 创建知识库请求
|
|
|
CreateDatasetRequest request = CreateDatasetRequest.builder()
|
|
|
.name(difyDataset.getName())
|
|
@@ -70,6 +70,7 @@ public class DifyDatasetService {
|
|
|
DatasetResponse response = getClient().createDataset(request);
|
|
|
difyDataset.setDatasetId(response.getId());
|
|
|
difyDatasetDao.save(difyDataset);
|
|
|
+ return response.getId();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -270,7 +271,7 @@ public class DifyDatasetService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void uploadFileToDataset(String datasetId, MultipartFile multipartFile) throws IOException {
|
|
|
+ public String uploadFileToDataset(String datasetId, MultipartFile multipartFile) throws IOException {
|
|
|
String apiUrl = "http://203.110.233.149:80/v1/datasets/{dataset_id}/document/create-by-file";
|
|
|
String response = uploadFile(apiUrl, "dataset-SWjJp6FOFqT85n7KxxyCFPSS", datasetId, multipartFile);
|
|
|
DocumentResponse documentResponse = JSONObject.parseObject(response, DocumentResponse.class);
|
|
@@ -281,6 +282,7 @@ public class DifyDatasetService {
|
|
|
difyDatasetDocument.setDocumentId(documentId);
|
|
|
difyDatasetDocument.setName(multipartFile.getOriginalFilename());
|
|
|
difyDatasetDocumentDao.save(difyDatasetDocument);
|
|
|
+ return documentId;
|
|
|
}
|
|
|
|
|
|
public String retrieve(String apiUrl, String apiKey, String datasetId, String json) throws IOException {
|