代码提交

topo_dev
liu 11 months ago
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, LangChainChatRes uploadFile(@RequestPart String knowledge_base_name,
@RequestPart MultipartFile files, @RequestPart MultipartFile files,
@RequestPart String text_splitter_type, @RequestPart String text_splitter_type,
@RequestPart String to_vector_store, @RequestPart Boolean to_vector_store,
@RequestPart String override, @RequestPart Boolean override,
@RequestPart String not_refresh_vs_cache, @RequestPart Boolean not_refresh_vs_cache,
@RequestPart Integer chunk_size, @RequestPart Integer chunk_size,
@RequestPart Integer chunk_overlap, @RequestPart Integer chunk_overlap,
@RequestPart String zh_title_enhance, @RequestPart Boolean zh_title_enhance,
@RequestPart String docs); @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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.chat.UploadParamEnum;
import com.supervision.chat.client.CustomMultipartFile; import com.supervision.chat.client.CustomMultipartFile;
import com.supervision.chat.client.LangChainChatService; import com.supervision.chat.client.LangChainChatService;
import com.supervision.chat.client.dto.DeleteFileDTO; import com.supervision.chat.client.dto.DeleteFileDTO;
@ -120,13 +121,13 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
LangChainChatRes langChainChatRes = langChainChatService.uploadFile("11111111", LangChainChatRes langChainChatRes = langChainChatService.uploadFile("11111111",
mockMultipartFile, mockMultipartFile,
"问讯笔录", "问讯笔录",
"true", UploadParamEnum.to_vector_store.getBooleanValue(),
"false", UploadParamEnum.override.getBooleanValue(),
"false", UploadParamEnum.not_refresh_vs_cache.getBooleanValue(),
250, UploadParamEnum.chunk_size.getIntValue(),
50, UploadParamEnum.chunk_overlap.getIntValue(),
"false", UploadParamEnum.zh_title_enhance.getBooleanValue(),
"{\"test.txt\":[{\"page_content\":\"custom doc\",\"metadata\":{},\"type\":\"Document\"}]}"); UploadParamEnum.docs.getStrValue());
if (!langChainChatRes.getCode().equals(200)) { if (!langChainChatRes.getCode().equals(200)) {
log.error("上传文件失败:{}", langChainChatRes.getMsg()); log.error("上传文件失败:{}", langChainChatRes.getMsg());
throw new RuntimeException("上传文件失败"); throw new RuntimeException("上传文件失败");
@ -158,8 +159,6 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
// 对笔录进行分类,并对笔录进行提取三元组 // 对笔录进行分类,并对笔录进行提取三元组
recordSplitProcessService.process(allTypeList, splitList); recordSplitProcessService.process(allTypeList, splitList);
} }
} }
caseStatusManageService.whenUploadRecord(record.getCaseId()); caseStatusManageService.whenUploadRecord(record.getCaseId());
return "保存成功"; return "保存成功";

Loading…
Cancel
Save