This commit is contained in:
Liuyang 2025-02-10 12:26:52 +08:00
parent c5500e3cb6
commit ee60016755
2 changed files with 24 additions and 5 deletions

View File

@ -118,9 +118,21 @@ public class ConversationServiceImpl implements ConversationService {
@Override
public ChatRespVO chat(ChatReqVO chatReqVO) {
// 模型推理 - 模型 - 可能选择向量知识库库选择向量知识库时先查询知识库
if(chatReqVO.getKnowledgeId()!= null){
}
//2.08 修改推理接口先查询知识库知识库查询为空则继续查询
if(chatReqVO.getSystemPrompt() == null || chatReqVO.getSystemPrompt().equals("")){
if(chatReqVO.getApplicationId() != null){
ApplicationRespVO application = applicationService.getApplication(chatReqVO.getApplicationId());
// 获取知识库ID
if (application.getModelServiceId() != null){
// 查询知识库知识库查询结果不为空直接返回
}
List<String> messageHistoryList = stringRedisTemplate.opsForList().range(CHAT_HIStORY_REDIS_KEY + ":" + chatReqVO.getUuid(), 0, -1);
if (CollectionUtils.isEmpty(messageHistoryList)){
application.setChatCount(application.getChatCount() + 1);

View File

@ -4,9 +4,7 @@ package cn.iocoder.yudao.module.llm.service.http;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgebase.KnowledgeBaseDO;
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments.KnowledgeDocumentsDO;
import cn.iocoder.yudao.module.llm.dal.mysql.knowledgebase.KnowledgeBaseMapper;
import cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocuments.KnowledgeDocumentsMapper;
import cn.iocoder.yudao.module.llm.framework.backend.config.LLMBackendProperties;
import cn.iocoder.yudao.module.llm.service.http.vo.*;
import com.alibaba.fastjson.JSON;
@ -45,6 +43,7 @@ public class RagHttpService {
private LLMBackendProperties llmBackendProperties;
@Resource
private KnowledgeBaseMapper knowledgeBaseMapper;
/**
* RAG健康检查API
*/
@ -222,6 +221,11 @@ public class RagHttpService {
String ragEmbed = llmBackendProperties.getEmbed();
log.info("url : {}", ragEmbed);
KnowledgeBaseDO aDo = knowledgeBaseMapper.selectById(id);
aDo.setKnowledgeBaseIntro(ragEmbed);
knowledgeBaseMapper.updateById(aDo);
// 构建请求参数
HttpResponse<String> response = Unirest.post(ragEmbed)
.field("file_id", reqVO.getFileId())
@ -232,15 +236,18 @@ public class RagHttpService {
JSONObject jsonObject = JSON.parseObject(body);
KnowledgeBaseDO aDo = knowledgeBaseMapper.selectById(id);
aDo.setKnowledgeBaseIntro(body);
int updateById = knowledgeBaseMapper.updateById(aDo);
knowledgeBaseMapper.updateById(aDo);
if (jsonObject.getBoolean("status")) {
log.info(" ========= Response Body Result: {}", response.getBody());
aDo.setKnowledgeBaseIntro("11-- success: " + ragEmbed);
knowledgeBaseMapper.updateById(aDo);
throw exception(new ErrorCode(10047, " ------------ 知识库上传成功"));
} else {
aDo.setKnowledgeBaseIntro("11-- error: " + ragEmbed);
knowledgeBaseMapper.updateById(aDo);
throw exception(new ErrorCode(10047, " xxxxxxxxxxxx 知识库上传失败"));
}
}