(improvement)(chat) solved query recall add embedding url check (#217)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2023-10-13 19:53:22 +08:00
committed by GitHub
parent 40705181a0
commit a0b4fb33c1
4 changed files with 20 additions and 0 deletions

View File

@@ -203,6 +203,9 @@ public class ChatServiceImpl implements ChatService {
public List<SolvedQueryRecallResp> getSolvedQuery(String queryText, Integer agentId) {
//1. recall solved query by queryText
List<SolvedQueryRecallResp> solvedQueryRecallResps = solvedQueryManager.recallSolvedQuery(queryText, agentId);
if (CollectionUtils.isEmpty(solvedQueryRecallResps)) {
return Lists.newArrayList();
}
List<Long> queryIds = solvedQueryRecallResps.stream()
.map(SolvedQueryRecallResp::getQueryId).collect(Collectors.toList());
PageQueryInfoReq pageQueryInfoReq = new PageQueryInfoReq();

View File

@@ -10,6 +10,7 @@ import com.tencent.supersonic.chat.parser.plugin.embedding.EmbeddingResp;
import com.tencent.supersonic.chat.parser.plugin.embedding.RecallRetrieval;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
@@ -39,6 +40,9 @@ public class SolvedQueryManager {
}
public void saveSolvedQuery(SolvedQueryReq solvedQueryReq) {
if (StringUtils.isBlank(embeddingConfig.getUrl())) {
return;
}
String queryText = solvedQueryReq.getQueryText();
try {
String uniqueId = generateUniqueId(solvedQueryReq.getQueryId(), solvedQueryReq.getParseId());
@@ -57,6 +61,9 @@ public class SolvedQueryManager {
}
public List<SolvedQueryRecallResp> recallSolvedQuery(String queryText, Integer agentId) {
if (StringUtils.isBlank(embeddingConfig.getUrl())) {
return Lists.newArrayList();
}
List<SolvedQueryRecallResp> solvedQueryRecallResps = Lists.newArrayList();
try {
String url = embeddingConfig.getUrl() + embeddingConfig.getSolvedQueryRecallPath() + "?n_results="