mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 20:25:12 +00:00
(improvement)(chat) update llm url to llmParser in chat project (#92)
This commit is contained in:
@@ -58,6 +58,9 @@ function setEnvToWeb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function resetEnvironment {
|
function resetEnvironment {
|
||||||
|
if [[ ${app_name} == $LLMPARSER_APP_NAME ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
if [[ "$command" == "start" || "$command" == "restart" ]]; then
|
if [[ "$command" == "start" || "$command" == "restart" ]]; then
|
||||||
#1. clear file
|
#1. clear file
|
||||||
mkdir -p ${runtimeDir}
|
mkdir -p ${runtimeDir}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Data
|
@Data
|
||||||
public class LLMConfig {
|
public class LLMParserConfig {
|
||||||
|
|
||||||
|
|
||||||
@Value("${llm.url:}")
|
@Value("${llm.parser.url:}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
@Value("${query2sql.path:/query2sql}")
|
@Value("${query2sql.path:/query2sql}")
|
||||||
@@ -15,7 +15,7 @@ import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
|||||||
import com.tencent.supersonic.chat.api.pojo.SemanticSchema;
|
import com.tencent.supersonic.chat.api.pojo.SemanticSchema;
|
||||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||||
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
import com.tencent.supersonic.chat.api.pojo.request.QueryReq;
|
||||||
import com.tencent.supersonic.chat.config.LLMConfig;
|
import com.tencent.supersonic.chat.config.LLMParserConfig;
|
||||||
import com.tencent.supersonic.chat.corrector.BaseSemanticCorrector;
|
import com.tencent.supersonic.chat.corrector.BaseSemanticCorrector;
|
||||||
import com.tencent.supersonic.chat.parser.SatisfactionChecker;
|
import com.tencent.supersonic.chat.parser.SatisfactionChecker;
|
||||||
import com.tencent.supersonic.chat.parser.plugin.function.ModelResolver;
|
import com.tencent.supersonic.chat.parser.plugin.function.ModelResolver;
|
||||||
@@ -66,9 +66,9 @@ public class LLMDslParser implements SemanticParser {
|
|||||||
@Override
|
@Override
|
||||||
public void parse(QueryContext queryCtx, ChatContext chatCtx) {
|
public void parse(QueryContext queryCtx, ChatContext chatCtx) {
|
||||||
QueryReq request = queryCtx.getRequest();
|
QueryReq request = queryCtx.getRequest();
|
||||||
LLMConfig llmConfig = ContextUtils.getBean(LLMConfig.class);
|
LLMParserConfig llmParserConfig = ContextUtils.getBean(LLMParserConfig.class);
|
||||||
if (StringUtils.isEmpty(llmConfig.getUrl())) {
|
if (StringUtils.isEmpty(llmParserConfig.getUrl())) {
|
||||||
log.info("llm url is empty, skip dsl parser, llmConfig:{}", llmConfig);
|
log.info("llm parser url is empty, skip dsl parser, llmParserConfig:{}", llmParserConfig);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SatisfactionChecker.check(queryCtx)) {
|
if (SatisfactionChecker.check(queryCtx)) {
|
||||||
@@ -88,7 +88,7 @@ public class LLMDslParser implements SemanticParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LLMReq llmReq = getLlmReq(queryCtx, modelId);
|
LLMReq llmReq = getLlmReq(queryCtx, modelId);
|
||||||
LLMResp llmResp = requestLLM(llmReq, modelId, llmConfig);
|
LLMResp llmResp = requestLLM(llmReq, modelId, llmParserConfig);
|
||||||
|
|
||||||
if (Objects.isNull(llmResp)) {
|
if (Objects.isNull(llmResp)) {
|
||||||
return;
|
return;
|
||||||
@@ -319,8 +319,8 @@ public class LLMDslParser implements SemanticParser {
|
|||||||
return modelId;
|
return modelId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LLMResp requestLLM(LLMReq llmReq, Long modelId, LLMConfig llmConfig) {
|
private LLMResp requestLLM(LLMReq llmReq, Long modelId, LLMParserConfig llmParserConfig) {
|
||||||
String questUrl = llmConfig.getUrl() + llmConfig.getQueryToSqlPath();
|
String questUrl = llmParserConfig.getUrl() + llmParserConfig.getQueryToSqlPath();
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
log.info("requestLLM request, modelId:{},llmReq:{}", modelId, llmReq);
|
log.info("requestLLM request, modelId:{},llmReq:{}", modelId, llmReq);
|
||||||
RestTemplate restTemplate = ContextUtils.getBean(RestTemplate.class);
|
RestTemplate restTemplate = ContextUtils.getBean(RestTemplate.class);
|
||||||
|
|||||||
@@ -29,4 +29,5 @@ semantic:
|
|||||||
prefix: http://127.0.0.1:9081
|
prefix: http://127.0.0.1:9081
|
||||||
|
|
||||||
llm:
|
llm:
|
||||||
url: http://127.0.0.1:9092/
|
parser:
|
||||||
|
url: http://127.0.0.1:9092
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ time:
|
|||||||
mybatis:
|
mybatis:
|
||||||
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
|
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
|
||||||
|
|
||||||
|
|
||||||
llm:
|
llm:
|
||||||
|
parser:
|
||||||
url: http://127.0.0.1:9092
|
url: http://127.0.0.1:9092
|
||||||
embedding:
|
embedding:
|
||||||
url: http://127.0.0.1:9092
|
url: http://127.0.0.1:9092
|
||||||
|
|||||||
Reference in New Issue
Block a user