mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
[improvement](chat) Support frontend configuration for S2SQL generation method. (#520)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.tencent.supersonic.chat.config;
|
package com.tencent.supersonic.chat.config;
|
||||||
|
|
||||||
|
import com.tencent.supersonic.chat.query.llm.s2sql.LLMReq.SqlGenerationMode;
|
||||||
import com.tencent.supersonic.common.service.SysParameterService;
|
import com.tencent.supersonic.common.service.SysParameterService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -57,6 +58,9 @@ public class OptimizationConfig {
|
|||||||
@Value("${s2SQL.linking.value.switch:true}")
|
@Value("${s2SQL.linking.value.switch:true}")
|
||||||
private boolean useLinkingValueSwitch;
|
private boolean useLinkingValueSwitch;
|
||||||
|
|
||||||
|
@Value("${s2SQL.generation:TWO_PASS_AUTO_COT}")
|
||||||
|
private SqlGenerationMode sqlGenerationMode;
|
||||||
|
|
||||||
@Value("${s2SQL.use.switch:true}")
|
@Value("${s2SQL.use.switch:true}")
|
||||||
private boolean useS2SqlSwitch;
|
private boolean useS2SqlSwitch;
|
||||||
|
|
||||||
@@ -139,6 +143,10 @@ public class OptimizationConfig {
|
|||||||
return convertValue("s2SQL.linking.value.switch", Boolean.class, useLinkingValueSwitch);
|
return convertValue("s2SQL.linking.value.switch", Boolean.class, useLinkingValueSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SqlGenerationMode getSqlGenerationMode() {
|
||||||
|
return convertValue("s2SQL.generation", SqlGenerationMode.class, sqlGenerationMode);
|
||||||
|
}
|
||||||
|
|
||||||
public <T> T convertValue(String paramName, Class<T> targetType, T defaultValue) {
|
public <T> T convertValue(String paramName, Class<T> targetType, T defaultValue) {
|
||||||
try {
|
try {
|
||||||
String value = sysParameterService.getSysParameter().getParameterByName(paramName);
|
String value = sysParameterService.getSysParameter().getParameterByName(paramName);
|
||||||
@@ -151,6 +159,8 @@ public class OptimizationConfig {
|
|||||||
return targetType.cast(Integer.parseInt(value));
|
return targetType.cast(Integer.parseInt(value));
|
||||||
} else if (targetType == Boolean.class) {
|
} else if (targetType == Boolean.class) {
|
||||||
return targetType.cast(Boolean.parseBoolean(value));
|
return targetType.cast(Boolean.parseBoolean(value));
|
||||||
|
} else if (targetType == SqlGenerationMode.class) {
|
||||||
|
return targetType.cast(SqlGenerationMode.valueOf(value));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("convertValue", e);
|
log.error("convertValue", e);
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ public class LLMRequestService {
|
|||||||
currentDate = DateUtils.getBeforeDate(0);
|
currentDate = DateUtils.getBeforeDate(0);
|
||||||
}
|
}
|
||||||
llmReq.setCurrentDate(currentDate);
|
llmReq.setCurrentDate(currentDate);
|
||||||
|
llmReq.setSqlGenerationMode(optimizationConfig.getSqlGenerationMode());
|
||||||
return llmReq;
|
return llmReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import com.tencent.supersonic.chat.query.llm.s2sql.LLMReq.SqlGenerationMode;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sql generation factory
|
|
||||||
*/
|
|
||||||
public class SqlGenerationFactory {
|
public class SqlGenerationFactory {
|
||||||
|
|
||||||
private static Map<SqlGenerationMode, SqlGeneration> sqlGenerationMap = new ConcurrentHashMap<>();
|
private static Map<SqlGenerationMode, SqlGeneration> sqlGenerationMap = new ConcurrentHashMap<>();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class LLMReq {
|
|||||||
|
|
||||||
private String priorExts;
|
private String priorExts;
|
||||||
|
|
||||||
private SqlGenerationMode sqlGenerationMode = SqlGenerationMode.TWO_PASS_AUTO_COT;
|
private SqlGenerationMode sqlGenerationMode;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class ElementValue {
|
public static class ElementValue {
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ public class SysParameter {
|
|||||||
parameters.add(new Parameter("llm.temperature", "0.0",
|
parameters.add(new Parameter("llm.temperature", "0.0",
|
||||||
"温度值", "number", "Parser相关配置"));
|
"温度值", "number", "Parser相关配置"));
|
||||||
|
|
||||||
Parameter s2SQLParameter = new Parameter("s2SQL.generation", "2_pass_auto_cot_self_consistency",
|
Parameter s2SQLParameter = new Parameter("s2SQL.generation", "TWO_PASS_AUTO_COT",
|
||||||
"S2SQL生成方式", "list", "Parser相关配置");
|
"S2SQL生成方式", "list", "Parser相关配置");
|
||||||
s2SQLParameter.setCandidateValues(Lists.newArrayList("1_pass_auto_cot", "1_pass_auto_cot_self_consistency",
|
s2SQLParameter.setCandidateValues(Lists.newArrayList("ONE_PASS_AUTO_COT", "ONE_PASS_AUTO_COT_SELF_CONSISTENCY",
|
||||||
"2_pass_auto_cot", "2_pass_auto_cot_self_consistency"));
|
"TWO_PASS_AUTO_COT", "TWO_PASS_AUTO_COT_SELF_CONSISTENCY"));
|
||||||
parameters.add(s2SQLParameter);
|
parameters.add(s2SQLParameter);
|
||||||
parameters.add(new Parameter("s2SQL.linking.value.switch", "true",
|
parameters.add(new Parameter("s2SQL.linking.value.switch", "true",
|
||||||
"是否将Mapper探测识别到的维度值提供给大模型", "为了数据安全考虑, 这里可进行开关选择",
|
"是否将Mapper探测识别到的维度值提供给大模型", "为了数据安全考虑, 这里可进行开关选择",
|
||||||
|
|||||||
Reference in New Issue
Block a user