9 Commits

Author SHA1 Message Date
QJ_wonder
01ead7307b Merge fa65b6eff7 into 79a44b27ee 2025-07-01 16:20:38 +08:00
jerryjzhang
79a44b27ee [fix][heaadless]Fix NPE issues.
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled
2025-06-28 08:51:04 +08:00
jerryjzhang
76cc5ee111 [opt][heaadless]Add user field to QueryStatement for consistency.
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run
2025-06-27 19:46:00 +08:00
QJ_wonder
fa65b6eff7 Update NL2PluginParser.java 去除多数据集条件判断 2025-05-28 15:47:58 +08:00
QJ_wonder
0ab44c0866 Merge branch 'tencentmusic:master' into master_fixplugin 2025-05-27 14:54:49 +08:00
QJ_wonder
449fdf180f (fix)(chat)多个数据集也只保留召回的第一个结果
这里的多数据集其实对召回的结果没有影响,取第一个就好了
2025-05-27 14:42:34 +08:00
QJ_wonder
d275a145d5 Update WebServiceQuery.java 2025-05-27 14:07:32 +08:00
QJ_wonder
c8f690c1c2 (fix)(chat) 修改判断是否需要NL2SQL的条件判断
修改判断是否需要NL2SQL的条件判断,如果respone里已经有返回体,则不需要NL2SQL的执行,直接返回。避免插件返回体被NL2SQL返回体覆盖的问题
2025-05-27 13:39:48 +08:00
QJ_wonder
38af6e3a28 (fix)(chat) 修复插件调用问题
修复插件调用问题,将原有的Json解析替换成fastjson的json解析,并按String解析返回体,否则会报:Error while extracting response for type [class java.lang.Object] and content type [application/xml;charset=UTF-8]
2025-05-27 13:34:34 +08:00
7 changed files with 18 additions and 10 deletions

View File

@@ -88,10 +88,10 @@ public class WebServiceQuery extends PluginSemanticQuery {
restTemplate = ContextUtils.getBean(RestTemplate.class);
try {
responseEntity =
restTemplate.exchange(requestUrl, HttpMethod.POST, entity, Object.class);
restTemplate.exchange(requestUrl, HttpMethod.POST, entity, String.class);
objectResponse = responseEntity.getBody();
log.info("objectResponse:{}", objectResponse);
Map<String, Object> response = JsonUtil.objectToMap(objectResponse);
Map<String, Object> response = JSON.parseObject(objectResponse.toString());
webServiceResponse.setResult(response);
} catch (Exception e) {
log.info("Exception:{}", e.getMessage());

View File

@@ -19,7 +19,7 @@ public class ParseContext {
}
public boolean enableNL2SQL() {
return Objects.nonNull(agent) && agent.containsDatasetTool();
return Objects.nonNull(agent) && agent.containsDatasetTool()&&response.getSelectedParses().size() == 0;
}
public boolean enableLLM() {

View File

@@ -1,5 +1,6 @@
package com.tencent.supersonic.headless.core.pojo;
import com.tencent.supersonic.common.pojo.User;
import com.tencent.supersonic.headless.api.pojo.response.QueryState;
import com.tencent.supersonic.headless.api.pojo.response.SemanticSchemaResp;
import lombok.Data;
@@ -24,6 +25,7 @@ public class QueryStatement {
private SemanticSchemaResp semanticSchema;
private Integer limit = 1000;
private Boolean isTranslated = false;
private User user;
public boolean isOk() {
return StringUtils.isBlank(errMsg) && StringUtils.isNotBlank(sql);

View File

@@ -296,6 +296,9 @@ public class S2SemanticLayerService implements SemanticLayerService {
queryStatement.setSql(semanticQueryReq.getSqlInfo().getQuerySQL());
queryStatement.setIsTranslated(true);
}
if (queryStatement != null) {
queryStatement.setUser(user);
}
return queryStatement;
}

View File

@@ -178,8 +178,9 @@ public class ChatWorkflowEngine {
// 如果物理SQL被修正了更新querySQL为修正后的版本
SemanticParseInfo parseInfo = semanticQuery.getParseInfo();
if (StringUtils.isNotBlank(parseInfo.getSqlInfo().getCorrectedQuerySQL())) {
parseInfo.getSqlInfo().setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
log.info("Physical SQL corrected and updated querySQL: {}",
parseInfo.getSqlInfo()
.setQuerySQL(parseInfo.getSqlInfo().getCorrectedQuerySQL());
log.info("Physical SQL corrected and updated querySQL: {}",
parseInfo.getSqlInfo().getQuerySQL());
}
break;

View File

@@ -138,7 +138,8 @@ public class DictUtils {
semanticQueryReq.setNeedAuth(false);
String bizName = dictItemResp.getBizName();
try {
SemanticQueryResp semanticQueryResp = queryService.queryByReq(semanticQueryReq, null);
SemanticQueryResp semanticQueryResp =
queryService.queryByReq(semanticQueryReq, User.getDefaultUser());
if (Objects.isNull(semanticQueryResp)
|| CollectionUtils.isEmpty(semanticQueryResp.getResultList())) {
return lines;
@@ -274,7 +275,8 @@ public class DictUtils {
private QuerySqlReq constructQuerySqlReq(DictItemResp dictItemResp) {
ModelResp model = modelService.getModel(dictItemResp.getModelId());
String tableStr = model.getModelDetail().getTableQuery() != null ? model.getModelDetail().getTableQuery()
String tableStr = StringUtils.isNotBlank(model.getModelDetail().getTableQuery())
? model.getModelDetail().getTableQuery()
: "(" + model.getModelDetail().getSqlQuery() + ")";
String sqlPattern =
"select %s,count(1) from %s %s group by %s order by count(1) desc limit %d";
@@ -289,8 +291,7 @@ public class DictUtils {
limit = Integer.MAX_VALUE;
}
String sql =
String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
String sql = String.format(sqlPattern, dimBizName, tableStr, where, dimBizName, limit);
Set<Long> modelIds = new HashSet<>();
modelIds.add(dictItemResp.getModelId());
QuerySqlReq querySqlReq = new QuerySqlReq();

View File

@@ -109,7 +109,8 @@ public class QueryUtils {
column.setModelId(metric.getModelId());
}
// if column nameEn contains metric alias, use metric dataFormatType
if (column.getDataFormatType() == null && StringUtils.isNotEmpty(metric.getAlias())) {
if (column.getDataFormatType() == null
&& StringUtils.isNotEmpty(metric.getAlias())) {
for (String alias : metric.getAlias().split(",")) {
if (nameEn.contains(alias)) {
column.setDataFormatType(metric.getDataFormatType());