代码提交

topo_dev
liu
parent 3a7929a574
commit dbab5bcc5a

@ -0,0 +1,37 @@
package com.supervision.chat;
import org.springframework.web.bind.annotation.RequestPart;
public enum UploadParamEnum {
to_vector_store(null, true, null),
override(null, false, null),
not_refresh_vs_cache(null, false, null),
chunk_size(null, null, 250),
chunk_overlap(null, null, 50),
zh_title_enhance(null, false, null),
docs("{\"test.txt\":[{\"page_content\":\"custom doc\",\"metadata\":{},\"type\":\"Document\"}]}", null, null);
private final String strValue;
private final Boolean booleanValue;
private final Integer intValue;
UploadParamEnum(String strValue, Boolean booleanValue, Integer intValue) {
this.strValue = strValue;
this.booleanValue = booleanValue;
this.intValue = intValue;
}
public String getStrValue() {
return strValue;
}
public Boolean getBooleanValue() {
return booleanValue;
}
public Integer getIntValue() {
return intValue;
}
}

@ -41,12 +41,12 @@ public interface LangChainChatService {
LangChainChatRes uploadFile(@RequestPart String knowledge_base_name,
@RequestPart MultipartFile files,
@RequestPart String text_splitter_type,
@RequestPart String to_vector_store,
@RequestPart String override,
@RequestPart String not_refresh_vs_cache,
@RequestPart Boolean to_vector_store,
@RequestPart Boolean override,
@RequestPart Boolean not_refresh_vs_cache,
@RequestPart Integer chunk_size,
@RequestPart Integer chunk_overlap,
@RequestPart String zh_title_enhance,
@RequestPart Boolean zh_title_enhance,
@RequestPart String docs);
/**

@ -1,32 +0,0 @@
package com.supervision.chat.client;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.supervision.chat.client.dto.CreateBaseDTO;
import com.supervision.chat.client.dto.LangChainChatRes;
import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
public class LangChainChatServiceImpl{
@Value("${langChain-chat.url}")
private String LangChainChatClientUrl;
public LangChainChatRes chat(CreateBaseDTO createBaseDTO) {
String post = HttpUtil.post(LangChainChatClientUrl + "create_knowledge_base", JSONUtil.toJsonStr(createBaseDTO));
if (JSONUtil.isTypeJSON(post)) {
return JSONUtil.toBean(post, LangChainChatRes.class);
}
return null;
}
}

@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.chat.UploadParamEnum;
import com.supervision.chat.client.CustomMultipartFile;
import com.supervision.chat.client.LangChainChatService;
import com.supervision.chat.client.dto.DeleteFileDTO;
@ -116,18 +117,18 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
continue;
}
// 这里需要把文件传输,传输到知识库中去
CustomMultipartFile mockMultipartFile = new CustomMultipartFile(minioFile.getFilename(),inputStream);
CustomMultipartFile mockMultipartFile = new CustomMultipartFile(minioFile.getFilename(), inputStream);
LangChainChatRes langChainChatRes = langChainChatService.uploadFile("11111111",
mockMultipartFile,
"问讯笔录",
"true",
"false",
"false",
250,
50,
"false",
"{\"test.txt\":[{\"page_content\":\"custom doc\",\"metadata\":{},\"type\":\"Document\"}]}");
if (!langChainChatRes.getCode().equals(200)){
UploadParamEnum.to_vector_store.getBooleanValue(),
UploadParamEnum.override.getBooleanValue(),
UploadParamEnum.not_refresh_vs_cache.getBooleanValue(),
UploadParamEnum.chunk_size.getIntValue(),
UploadParamEnum.chunk_overlap.getIntValue(),
UploadParamEnum.zh_title_enhance.getBooleanValue(),
UploadParamEnum.docs.getStrValue());
if (!langChainChatRes.getCode().equals(200)) {
log.error("上传文件失败:{}", langChainChatRes.getMsg());
throw new RuntimeException("上传文件失败");
}
@ -158,8 +159,6 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
// 对笔录进行分类,并对笔录进行提取三元组
recordSplitProcessService.process(allTypeList, splitList);
}
}
caseStatusManageService.whenUploadRecord(record.getCaseId());
return "保存成功";
@ -279,7 +278,7 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
}
@Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class,noRollbackFor = BusinessException.class)
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class, noRollbackFor = BusinessException.class)
public void delRecords(String id) {
NoteRecord noteRecord = noteRecordMapper.selectById(id);
@ -295,8 +294,8 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
MinioFile minioFile = minioFileMapper.selectById(fileId);
// 删除文件
LangChainChatRes langChainChatRes = langChainChatService.deleteFile(DeleteFileDTO.create(noteRecord.getCaseId(), minioFile.getFilename()));
if (!langChainChatRes.getCode().equals(200)){
throw new BusinessException("删除文件:" + minioFile.getFilename() + " 失败!");
if (!langChainChatRes.getCode().equals(200)) {
throw new BusinessException("删除文件:" + minioFile.getFilename() + " 失败!");
}
minioFile.setDataStatus(StringUtils.getUUID());
minioFileMapper.updateById(minioFile);

Loading…
Cancel
Save