perf(llm): 优化知识库更新功能和 HTTP 请求配置

- 更新知识库时增加了 HTTP 请求配置,提高请求超时时间和并发处理能力
- 设置默认的 Accept头为 application/json,提高与外部服务的兼容性
This commit is contained in:
Liuyang 2025-02-08 17:43:27 +08:00
parent e7d5551a0c
commit 972eab3262

View File

@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocuments.KnowledgeDocumen
import cn.iocoder.yudao.module.llm.service.application.ApplicationService;
import cn.iocoder.yudao.module.llm.service.async.AsyncKnowledgeBase;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import kong.unirest.Unirest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -71,6 +72,13 @@ public class KnowledgeBaseServiceImpl implements KnowledgeBaseService {
KnowledgeBaseDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgeBaseDO.class);
knowledgeBaseMapper.updateById(updateObj);
Unirest.config()
.socketTimeout(50000)
.connectTimeout(100000)
.concurrency(10, 5)
.setDefaultHeader("Accept", "application/json")
;
// 4. 处理附表知识文档数据
if (!CollectionUtils.isAnyEmpty(updateReqVO.getKnowledgeDocuments())) {
// 4.1 获取需要保留的文档 ID