Merge branch 'developing' of https://github.com/chat2db/Chat2DB into developing

This commit is contained in:
JiaJu Zhuang
2023-07-01 10:11:58 +08:00
6 changed files with 46 additions and 27 deletions

View File

@ -1,11 +1,9 @@
common.businessError=Please try resubmitting or refreshing the page later
common.systemError=系统开小差啦,请尝试刷新页面或者联系管理员
common.needLoggedIn=需要登陆页面
common.redirect=重定向页面
common.paramError=您输入的参数异常
common.paramDetailError=您输入的参数:{0},存在异常
common.paramCheckError=请检查以下参数:
common.maxUploadSize=您输入的文件超过最大限制
dataSource.sqlAnalysisError=不合法的执行语句
common.systemError=An exception occurs, you can view the exception details in the log in the help menu. If you can't fix it, you can subscribe to the WeChat public account Text2SQL to consult for help
common.needLoggedIn=Login required
common.redirect=Redirect
common.paramError=The parameter is incorrect
common.paramDetailError=The parameter: {0} is incorrect
common.paramCheckError=The following parameters are not valid:
common.maxUploadSize=The file exceeds the maximum limit
dataSource.sqlAnalysisError=Invalid statements

View File

@ -1,11 +1,9 @@
common.businessError=Please try resubmitting or refreshing the page later
common.systemError=系统开小差啦,请尝试刷新页面或者联系管理员
common.needLoggedIn=需要登陆页面
common.redirect=重定向页面
common.paramError=您输入的参数异常
common.paramDetailError=您输入的参数:{0},存在异常
common.paramCheckError=请检查以下参数:
common.maxUploadSize=您输入的文件超过最大限制
dataSource.sqlAnalysisError=不合法的执行语句
common.systemError=An exception occurs, you can view the exception details in the log in the help menu. If you can't fix it, you can subscribe to the WeChat public account Text2SQL to consult for help
common.needLoggedIn=Login required
common.redirect=Redirect
common.paramError=The parameter is incorrect
common.paramDetailError=The parameter: {0} is incorrect
common.paramCheckError=The following parameters are not valid
common.maxUploadSize=The file exceeds the maximum limit
dataSource.sqlAnalysisError=Invalid statements

View File

@ -1,5 +1,5 @@
common.businessError=请尝试重新提交或者刷新页面
common.systemError=系统发生异常,可在帮助中查看异常详情如无法解决可关注微信公众号Text2SQL咨询帮助
common.systemError=系统发生异常,可在帮助中点击日志查看异常详情如无法解决可关注微信公众号Text2SQL咨询帮助
common.needLoggedIn=需要登陆页面
common.redirect=重定向页面
common.paramError=您输入的参数异常

View File

@ -56,7 +56,7 @@ public class AzureOpenAIClient {
public static void refresh() {
String apikey = "";
String apiEndpoint = "";
String deployId = "";
String deployId = "gpt-3.5-turbo";
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
Config apiHostConfig = configService.find(AZURE_CHATGPT_ENDPOINT).getData();
if (apiHostConfig != null) {

View File

@ -14,6 +14,7 @@ import ai.chat2db.server.domain.api.service.ConfigService;
import ai.chat2db.server.tools.base.wrapper.result.ActionResult;
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
import ai.chat2db.server.web.api.aspect.ConnectionInfoAspect;
import ai.chat2db.server.web.api.controller.ai.azure.client.AzureOpenAIClient;
import ai.chat2db.server.web.api.controller.config.request.AISystemConfigRequest;
import ai.chat2db.server.web.api.controller.config.request.SystemConfigRequest;
import ai.chat2db.server.web.api.util.OpenAIClient;
@ -64,10 +65,14 @@ public class ConfigController {
SystemConfigParam param = SystemConfigParam.builder().code(RestAIClient.AI_SQL_SOURCE).content(sqlSource)
.build();
configService.createOrUpdate(param);
if (AiSqlSourceEnum.OPENAI.getCode().equals(sqlSource)) {
saveOpenAIConfig(request);
} else {
saveRestAIConfig(request);
AiSqlSourceEnum aiSqlSourceEnum = AiSqlSourceEnum.getByName(sqlSource);
switch (Objects.requireNonNull(aiSqlSourceEnum)) {
case OPENAI :
saveOpenAIConfig(request);
case RESTAI :
saveRestAIConfig(request);
case AZUREAI :
saveAzureAIConfig(request);
}
return ActionResult.isSuccess();
}
@ -111,6 +116,24 @@ public class ConfigController {
RestAIClient.refresh();
}
/**
* 保存azure配置
*
* @param request
*/
private void saveAzureAIConfig(AISystemConfigRequest request) {
SystemConfigParam apikeyParam = SystemConfigParam.builder().code(AzureOpenAIClient.AZURE_CHATGPT_API_KEY).content(
request.getAzureApiKey()).build();
configService.createOrUpdate(apikeyParam);
SystemConfigParam endpointParam = SystemConfigParam.builder().code(AzureOpenAIClient.AZURE_CHATGPT_ENDPOINT).content(
request.getAzureEndpoint()).build();
configService.createOrUpdate(endpointParam);
SystemConfigParam modelParam = SystemConfigParam.builder().code(AzureOpenAIClient.AZURE_CHATGPT_DEPLOYMENT_ID).content(
request.getAzureDeploymentId()).build();
configService.createOrUpdate(modelParam);
RestAIClient.refresh();
}
@GetMapping("/system_config/{code}")
public DataResult<Config> getSystemConfig(@PathVariable("code") String code) {
DataResult<Config> result = configService.find(code);

View File

@ -68,7 +68,7 @@ public class AISystemConfigRequest {
private String azureEndpoint;
/**
* deployment id of the deployed model
* deploymentId of the deployed model, default gpt-3.5-turbo
*/
private String azureDeploymentId;
}