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="
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.tencent.supersonic.semantic.model.infrastructure.repository;
|
||||
|
||||
import com.clickhouse.client.internal.apache.commons.compress.utils.Lists;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DimensionDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.DimensionDOExample;
|
||||
import com.tencent.supersonic.semantic.model.domain.repository.DimensionRepository;
|
||||
@@ -7,6 +8,7 @@ import com.tencent.supersonic.semantic.model.domain.pojo.DimensionFilter;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.DimensionDOCustomMapper;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.DimensionDOMapper;
|
||||
import java.util.List;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -56,6 +58,9 @@ public class DimensionRepositoryImpl implements DimensionRepository {
|
||||
|
||||
@Override
|
||||
public List<DimensionDO> getDimensionListOfmodelIds(List<Long> modelIds) {
|
||||
if (CollectionUtils.isEmpty(modelIds)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
DimensionDOExample dimensionDOExample = new DimensionDOExample();
|
||||
dimensionDOExample.createCriteria().andModelIdIn(modelIds);
|
||||
return dimensionDOMapper.selectByExampleWithBLOBs(dimensionDOExample);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.tencent.supersonic.semantic.model.infrastructure.repository;
|
||||
|
||||
|
||||
import com.clickhouse.client.internal.apache.commons.compress.utils.Lists;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDO;
|
||||
import com.tencent.supersonic.semantic.model.domain.dataobject.MetricDOExample;
|
||||
import com.tencent.supersonic.semantic.model.domain.pojo.MetricFilter;
|
||||
@@ -8,6 +9,7 @@ import com.tencent.supersonic.semantic.model.domain.repository.MetricRepository;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.MetricDOCustomMapper;
|
||||
import com.tencent.supersonic.semantic.model.infrastructure.mapper.MetricDOMapper;
|
||||
import java.util.List;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -50,6 +52,9 @@ public class MetricRepositoryImpl implements MetricRepository {
|
||||
|
||||
@Override
|
||||
public List<MetricDO> getMetricList(List<Long> modelIds) {
|
||||
if (CollectionUtils.isEmpty(modelIds)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
MetricDOExample metricDOExample = new MetricDOExample();
|
||||
metricDOExample.createCriteria().andModelIdIn(modelIds);
|
||||
return metricDOMapper.selectByExampleWithBLOBs(metricDOExample);
|
||||
|
||||
Reference in New Issue
Block a user