(improvement)(chat) update llm url to llmParser in chat project (#92)

This commit is contained in:
lexluo09
2023-09-14 22:59:11 +08:00
committed by GitHub
parent 30f5fc9ab1
commit 682d35b2b2
5 changed files with 17 additions and 11 deletions

View File

@@ -58,6 +58,9 @@ function setEnvToWeb {
}
function resetEnvironment {
if [[ ${app_name} == $LLMPARSER_APP_NAME ]]; then
return
fi
if [[ "$command" == "start" || "$command" == "restart" ]]; then
#1. clear file
mkdir -p ${runtimeDir}

View File

@@ -7,10 +7,10 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@Data
public class LLMConfig {
public class LLMParserConfig {
@Value("${llm.url:}")
@Value("${llm.parser.url:}")
private String url;
@Value("${query2sql.path:/query2sql}")

View File

@@ -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.request.QueryFilter;
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.parser.SatisfactionChecker;
import com.tencent.supersonic.chat.parser.plugin.function.ModelResolver;
@@ -66,9 +66,9 @@ public class LLMDslParser implements SemanticParser {
@Override
public void parse(QueryContext queryCtx, ChatContext chatCtx) {
QueryReq request = queryCtx.getRequest();
LLMConfig llmConfig = ContextUtils.getBean(LLMConfig.class);
if (StringUtils.isEmpty(llmConfig.getUrl())) {
log.info("llm url is empty, skip dsl parser, llmConfig:{}", llmConfig);
LLMParserConfig llmParserConfig = ContextUtils.getBean(LLMParserConfig.class);
if (StringUtils.isEmpty(llmParserConfig.getUrl())) {
log.info("llm parser url is empty, skip dsl parser, llmParserConfig:{}", llmParserConfig);
return;
}
if (SatisfactionChecker.check(queryCtx)) {
@@ -88,7 +88,7 @@ public class LLMDslParser implements SemanticParser {
}
LLMReq llmReq = getLlmReq(queryCtx, modelId);
LLMResp llmResp = requestLLM(llmReq, modelId, llmConfig);
LLMResp llmResp = requestLLM(llmReq, modelId, llmParserConfig);
if (Objects.isNull(llmResp)) {
return;
@@ -319,8 +319,8 @@ public class LLMDslParser implements SemanticParser {
return modelId;
}
private LLMResp requestLLM(LLMReq llmReq, Long modelId, LLMConfig llmConfig) {
String questUrl = llmConfig.getUrl() + llmConfig.getQueryToSqlPath();
private LLMResp requestLLM(LLMReq llmReq, Long modelId, LLMParserConfig llmParserConfig) {
String questUrl = llmParserConfig.getUrl() + llmParserConfig.getQueryToSqlPath();
long startTime = System.currentTimeMillis();
log.info("requestLLM request, modelId:{},llmReq:{}", modelId, llmReq);
RestTemplate restTemplate = ContextUtils.getBean(RestTemplate.class);

View File

@@ -29,4 +29,5 @@ semantic:
prefix: http://127.0.0.1:9081
llm:
url: http://127.0.0.1:9092/
parser:
url: http://127.0.0.1:9092

View File

@@ -36,7 +36,9 @@ time:
mybatis:
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
llm:
parser:
url: http://127.0.0.1:9092
embedding:
url: http://127.0.0.1:9092