diff --git a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages.properties b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages.properties index 0148a15b..6725b57d 100644 --- a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages.properties +++ b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages.properties @@ -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=不合法的执行语句 \ No newline at end of file +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 \ No newline at end of file diff --git a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_en_US.properties b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_en_US.properties index 0148a15b..0dbbdd8e 100644 --- a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_en_US.properties +++ b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_en_US.properties @@ -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=不合法的执行语句 \ No newline at end of file +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 \ No newline at end of file diff --git a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_zh_CN.properties b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_zh_CN.properties index 8dc0f5d2..d8f7314a 100644 --- a/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_zh_CN.properties +++ b/chat2db-server/chat2db-server-start/src/main/resources/i18n/messages_zh_CN.properties @@ -1,5 +1,5 @@ common.businessError=请尝试重新提交或者刷新页面 -common.systemError=系统发生异常,可在帮助中查看异常详情,如无法解决,可关注微信公众号Text2SQL咨询帮助 +common.systemError=系统发生异常,可在帮助中点击日志查看异常详情。如无法解决,可关注微信公众号Text2SQL咨询帮助 common.needLoggedIn=需要登陆页面 common.redirect=重定向页面 common.paramError=您输入的参数异常 diff --git a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/azure/client/AzureOpenAIClient.java b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/azure/client/AzureOpenAIClient.java index 96c3103d..893c489b 100644 --- a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/azure/client/AzureOpenAIClient.java +++ b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/ai/azure/client/AzureOpenAIClient.java @@ -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) { diff --git a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/ConfigController.java b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/ConfigController.java index c0420d6e..002d60f3 100644 --- a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/ConfigController.java +++ b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/ConfigController.java @@ -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 getSystemConfig(@PathVariable("code") String code) { DataResult result = configService.find(code); diff --git a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/request/AISystemConfigRequest.java b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/request/AISystemConfigRequest.java index a5e22d04..fcc34d88 100644 --- a/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/request/AISystemConfigRequest.java +++ b/chat2db-server/chat2db-server-web/chat2db-server-web-api/src/main/java/ai/chat2db/server/web/api/controller/config/request/AISystemConfigRequest.java @@ -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; }