mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-01-24 20:41:22 +08:00
Merge branch 'tencentmusic:master' into master_fixdatasetchoose
This commit is contained in:
@@ -46,7 +46,8 @@ public class DataInterpretProcessor implements ExecuteResultProcessor {
|
||||
public boolean accept(ExecuteContext executeContext) {
|
||||
Agent agent = executeContext.getAgent();
|
||||
ChatApp chatApp = agent.getChatAppConfig().get(APP_KEY);
|
||||
return Objects.nonNull(chatApp) && chatApp.isEnable();
|
||||
return Objects.nonNull(chatApp) && chatApp.isEnable()&&
|
||||
StringUtils.isNotBlank(executeContext.getResponse().getTextResult()); // 如果都没结果,则无法处理,直接跳过
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,8 @@ public enum EngineType {
|
||||
STARROCKS(10, "STARROCKS"),
|
||||
KYUUBI(11, "KYUUBI"),
|
||||
PRESTO(12, "PRESTO"),
|
||||
TRINO(13, "TRINO"),;
|
||||
TRINO(13, "TRINO"),
|
||||
ORACLE(14, "ORACLE");
|
||||
|
||||
private Integer code;
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@ public class DateModeUtils {
|
||||
}
|
||||
|
||||
public String getDateWhereStr(DateConf dateInfo, ItemDateResp dateDate) {
|
||||
if (Objects.isNull(dateInfo)) {
|
||||
if (Objects.isNull(dateInfo) || Objects.isNull(dateInfo.getDateField())) {
|
||||
return "";
|
||||
}
|
||||
String dateStr = "";
|
||||
|
||||
@@ -179,13 +179,15 @@ public class NatureHelper {
|
||||
}
|
||||
|
||||
public static Long parseIdFromNature(String nature, int index) {
|
||||
try {
|
||||
String[] split = nature.split(DictWordType.NATURE_SPILT);
|
||||
if (split.length > index) {
|
||||
return Long.valueOf(split[index]);
|
||||
if(nature.startsWith("_")){ // 框架的字典都是以_开头的
|
||||
try {
|
||||
String[] split = nature.split(DictWordType.NATURE_SPILT);
|
||||
if (split.length > index) {
|
||||
return Long.valueOf(split[index]);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("Error parsing long from nature: {}", nature, e);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("Error parsing long from nature: {}", nature, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,9 @@ public class EmbeddingMatchStrategy extends BatchMatchStrategy<EmbeddingResult>
|
||||
variable.put("retrievedInfo", JSONObject.toJSONString(results));
|
||||
|
||||
Prompt prompt = PromptTemplate.from(LLM_FILTER_PROMPT).apply(variable);
|
||||
ChatLanguageModel chatLanguageModel = ModelProvider.getChatModel(chatQueryContext.getRequest().getChatAppConfig().get("REWRITE_MULTI_TURN").getChatModelConfig());
|
||||
ChatLanguageModel chatLanguageModel =
|
||||
ModelProvider.getChatModel(chatQueryContext.getRequest().getChatAppConfig()
|
||||
.get("REWRITE_MULTI_TURN").getChatModelConfig());
|
||||
String response = chatLanguageModel.generate(prompt.toUserMessage().singleText());
|
||||
|
||||
if (StringUtils.isBlank(response)) {
|
||||
|
||||
@@ -22,6 +22,7 @@ public class DbAdaptorFactory {
|
||||
dbAdaptorMap.put(EngineType.KYUUBI.getName(), new KyuubiAdaptor());
|
||||
dbAdaptorMap.put(EngineType.PRESTO.getName(), new PrestoAdaptor());
|
||||
dbAdaptorMap.put(EngineType.TRINO.getName(), new TrinoAdaptor());
|
||||
dbAdaptorMap.put(EngineType.ORACLE.getName(), new OracleAdaptor());
|
||||
}
|
||||
|
||||
public static DbAdaptor getEngineAdaptor(String engineType) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.tencent.supersonic.headless.core.adaptor.db;
|
||||
|
||||
public class OracleAdaptor extends DefaultDbAdaptor {
|
||||
|
||||
}
|
||||
@@ -48,16 +48,23 @@ public class SqlQueryParser implements QueryParser {
|
||||
List<String> queryFields = SqlSelectHelper.getAllSelectFields(sqlQuery.getSql());
|
||||
Set<String> queryAliases = SqlSelectHelper.getAliasFields(sqlQuery.getSql());
|
||||
Set<String> ontologyMetricsDimensions = Collections.synchronizedSet(new HashSet<String>());
|
||||
Set<String> ontologyBizNameMetricsDimensions = Collections.synchronizedSet(new HashSet<String>());
|
||||
Set<String> ontologyBizNameMetricsDimensions = Collections.synchronizedSet(new HashSet<>());
|
||||
queryFields.removeAll(queryAliases);
|
||||
Ontology ontology = queryStatement.getOntology();
|
||||
OntologyQuery ontologyQuery = buildOntologyQuery(ontology, queryFields);
|
||||
Set<String> queryFieldsSet = new HashSet<>(queryFields);
|
||||
ontologyQuery.getMetrics().forEach(m -> {ontologyMetricsDimensions.add(m.getName()); ontologyBizNameMetricsDimensions.add(m.getBizName());});
|
||||
ontologyQuery.getDimensions().forEach(d -> {ontologyMetricsDimensions.add(d.getName()); ontologyBizNameMetricsDimensions.add(d.getBizName());});
|
||||
ontologyQuery.getMetrics().forEach(m -> {
|
||||
ontologyMetricsDimensions.add(m.getName());
|
||||
ontologyBizNameMetricsDimensions.add(m.getBizName());
|
||||
});
|
||||
ontologyQuery.getDimensions().forEach(d -> {
|
||||
ontologyMetricsDimensions.add(d.getName());
|
||||
ontologyBizNameMetricsDimensions.add(d.getBizName());
|
||||
});
|
||||
// check if there are fields not matched with any metric or dimension
|
||||
|
||||
if (!(queryFieldsSet.containsAll(ontologyMetricsDimensions)||queryFieldsSet.containsAll(ontologyBizNameMetricsDimensions))) {
|
||||
if (!(queryFieldsSet.containsAll(ontologyMetricsDimensions)
|
||||
|| queryFieldsSet.containsAll(ontologyBizNameMetricsDimensions))) {
|
||||
List<String> semanticFields = Lists.newArrayList();
|
||||
ontologyQuery.getMetrics().forEach(m -> semanticFields.add(m.getName()));
|
||||
ontologyQuery.getDimensions().forEach(d -> semanticFields.add(d.getName()));
|
||||
|
||||
@@ -36,8 +36,10 @@ public class DataModelNode extends SemanticNode {
|
||||
&& !dataModel.getModelDetail().getSqlQuery().isEmpty()) {
|
||||
sqlTable = dataModel.getModelDetail().getSqlQuery();
|
||||
// if model has sqlVariables, parse sqlVariables
|
||||
if (Objects.nonNull(dataModel.getModelDetail().getSqlVariables()) || (CollectionUtils.isEmpty(dataModel.getModelDetail().getSqlVariables()))) {
|
||||
sqlTable = SqlVariableParseUtils.parse(sqlTable, dataModel.getModelDetail().getSqlVariables(), Lists.newArrayList());
|
||||
if (Objects.nonNull(dataModel.getModelDetail().getSqlVariables())
|
||||
|| (CollectionUtils.isEmpty(dataModel.getModelDetail().getSqlVariables()))) {
|
||||
sqlTable = SqlVariableParseUtils.parse(sqlTable,
|
||||
dataModel.getModelDetail().getSqlVariables(), Lists.newArrayList());
|
||||
}
|
||||
} else if (dataModel.getModelDetail().getTableQuery() != null
|
||||
&& !dataModel.getModelDetail().getTableQuery().isEmpty()) {
|
||||
|
||||
@@ -711,6 +711,15 @@ public class MetricServiceImpl extends ServiceImpl<MetricDOMapper, MetricDO>
|
||||
}
|
||||
if (!modelCluster.isContainsPartitionDimensions()) {
|
||||
queryMetricReq.setDateInfo(null);
|
||||
} else {
|
||||
// set date field
|
||||
DimensionResp partitionDimension = dimensionResps.stream()
|
||||
.filter(entry -> modelCluster.getModelIds().contains(entry.getModelId()))
|
||||
.filter(entry -> entry.getStatus().equals(StatusEnum.ONLINE.getCode()))
|
||||
.filter(entry -> entry.isPartitionTime()).findFirst().orElse(null);
|
||||
if (partitionDimension != null) {
|
||||
queryMetricReq.getDateInfo().setDateField(partitionDimension.getName());
|
||||
}
|
||||
}
|
||||
// 4. set groups
|
||||
List<String> dimensionNames = dimensionResps.stream()
|
||||
|
||||
@@ -136,9 +136,10 @@ public class QueryUtils {
|
||||
return false;
|
||||
}
|
||||
return type.toLowerCase().endsWith("int") || type.toLowerCase().startsWith("int")
|
||||
|| type.equalsIgnoreCase("float") || type.equalsIgnoreCase("double")
|
||||
|| type.toLowerCase().endsWith("float") || type.toLowerCase().startsWith("float")
|
||||
|| type.toLowerCase().endsWith("double") || type.toLowerCase().startsWith("double")
|
||||
|| type.equalsIgnoreCase("real") || type.equalsIgnoreCase("numeric")
|
||||
|| type.toLowerCase().startsWith("decimal") || type.equalsIgnoreCase("decfloat");
|
||||
|| type.toLowerCase().startsWith("decimal");
|
||||
}
|
||||
|
||||
private String getName(String nameEn) {
|
||||
|
||||
@@ -102,7 +102,6 @@ const ChatItem: React.FC<Props> = ({
|
||||
{}
|
||||
);
|
||||
const [isParserError, setIsParseError] = useState<boolean>(false);
|
||||
|
||||
const resetState = () => {
|
||||
setParseLoading(false);
|
||||
setParseTimeCost(undefined);
|
||||
@@ -441,6 +440,8 @@ const ChatItem: React.FC<Props> = ({
|
||||
|
||||
const { register, call } = useMethodRegister(() => message.error('该条消息暂不支持该操作'));
|
||||
|
||||
let actualQueryText=parseInfo?.properties.CONTEXT.queryText // lance修改 结果显示多轮对话转义的内容
|
||||
actualQueryText=actualQueryText==null?msg:actualQueryText
|
||||
return (
|
||||
<ChartItemContext.Provider value={{ register, call }}>
|
||||
<div className={prefixCls}>
|
||||
@@ -509,7 +510,7 @@ const ChatItem: React.FC<Props> = ({
|
||||
<SqlItem
|
||||
agentId={agentId}
|
||||
queryId={parseInfo.queryId}
|
||||
question={msg}
|
||||
question={actualQueryText}
|
||||
llmReq={llmReq}
|
||||
llmResp={llmResp}
|
||||
integrateSystem={integrateSystem}
|
||||
@@ -522,7 +523,7 @@ const ChatItem: React.FC<Props> = ({
|
||||
<ExecuteItem
|
||||
isSimpleMode={isSimpleMode}
|
||||
queryId={parseInfo?.queryId}
|
||||
question={msg}
|
||||
question={actualQueryText}
|
||||
queryMode={parseInfo?.queryMode}
|
||||
executeLoading={executeLoading}
|
||||
executeTip={executeTip}
|
||||
|
||||
@@ -82,7 +82,11 @@
|
||||
background-color: #fafafa !important;
|
||||
}
|
||||
|
||||
.ant-table-cell {
|
||||
.ant-table-cell { // 更新修改,解决表格内容太长导致显示的问题
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 250px;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ const ChatMsg: React.FC<Props> = ({
|
||||
dateInfo: {
|
||||
...chatContext.dateInfo,
|
||||
dateMode: dateModeValue,
|
||||
unit: currentDateOption || chatContext.dateInfo.unit,
|
||||
unit: currentDateOption || chatContext.dateInfo?.unit,
|
||||
},
|
||||
dimensions: [
|
||||
...(chatContext.dimensions || []),
|
||||
@@ -310,7 +310,7 @@ const ChatMsg: React.FC<Props> = ({
|
||||
dateInfo: {
|
||||
...chatContext.dateInfo,
|
||||
dateMode: dateModeValue,
|
||||
unit: currentDateOption || chatContext.dateInfo.unit,
|
||||
unit: currentDateOption || chatContext.dateInfo?.unit,
|
||||
},
|
||||
dimensions: drillDownDimension
|
||||
? [...(chatContext.dimensions || []), drillDownDimension]
|
||||
|
||||
Reference in New Issue
Block a user