mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
add new chat corrector
在助理最终执行物理SQL前,加入一步LLM优化性能功能
This commit is contained in:
@@ -75,8 +75,12 @@ public class SqlExecutor implements ChatQueryExecutor {
|
||||
return null;
|
||||
}
|
||||
|
||||
QuerySqlReq sqlReq =
|
||||
QuerySqlReq.builder().sql(parseInfo.getSqlInfo().getCorrectedS2SQL()).build();
|
||||
// 使用querySQL,它已经包含了所有修正(包括物理SQL修正)
|
||||
String finalSql = StringUtils.isNotBlank(parseInfo.getSqlInfo().getQuerySQL())
|
||||
? parseInfo.getSqlInfo().getQuerySQL()
|
||||
: parseInfo.getSqlInfo().getCorrectedS2SQL();
|
||||
|
||||
QuerySqlReq sqlReq = QuerySqlReq.builder().sql(finalSql).build();
|
||||
sqlReq.setSqlInfo(parseInfo.getSqlInfo());
|
||||
sqlReq.setDataSetId(parseInfo.getDataSetId());
|
||||
|
||||
@@ -90,7 +94,7 @@ public class SqlExecutor implements ChatQueryExecutor {
|
||||
queryResult.setQueryTimeCost(System.currentTimeMillis() - startTime);
|
||||
if (queryResp != null) {
|
||||
queryResult.setQueryAuthorization(queryResp.getQueryAuthorization());
|
||||
queryResult.setQuerySql(queryResp.getSql());
|
||||
queryResult.setQuerySql(finalSql);
|
||||
queryResult.setQueryResults(queryResp.getResultList());
|
||||
queryResult.setQueryColumns(queryResp.getColumns());
|
||||
queryResult.setQueryState(QueryState.SUCCESS);
|
||||
|
||||
@@ -22,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -39,6 +40,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
||||
private MemoryService memoryService;
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ChatQueryService chatQueryService;
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.sf.jsqlparser.schema.Column;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -66,6 +67,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
@Autowired
|
||||
private SemanticLayerService semanticLayerService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private AgentService agentService;
|
||||
|
||||
private final List<ChatQueryParser> chatQueryParsers = ComponentFactory.getChatParsers();
|
||||
|
||||
Reference in New Issue
Block a user