mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(chat) solved query recall add embedding url check (#217)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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="
|
||||
|
||||
Reference in New Issue
Block a user