From 59865fe32772e92ed391ddc0fbf1c766659ed185 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 29 May 2024 10:04:14 +0800 Subject: [PATCH 01/36] execution --- xdoc/notes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xdoc/notes.txt b/xdoc/notes.txt index 49a3da64a..421accc08 100644 --- a/xdoc/notes.txt +++ b/xdoc/notes.txt @@ -68,7 +68,7 @@ npm config set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/ scp -r ~/work/qiniu/deeptest/* lighthouse@111.231.16.35:~/work/qiniu/deeptest nohup light-server -s ~/work/qiniu/deeptest > ~/light-server.log 2>&1 & -git push -f github master:main +git push -f github dt:main git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params ENV=dp rm -rf bin && make default From 13cc1b0baf3012f139356906a07904240cd1564f Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 15:31:11 +0800 Subject: [PATCH 02/36] execution --- Makefile | 10 ++++++++-- client/src/app/app.js | 2 ++ client/src/app/utils/checkPort.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 74d235d91..0326d9503 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main. default: compile_ui_web win64 win32 linux mac # 非客户端版本打包 +# 先运行 make compile_ui_client win64: prepare compile_agent_win64 compile_server_win64 zip_web_win64 win32: prepare compile_agent_win32 compile_server_win32 zip_web_win32 linux: prepare compile_agent_linux compile_server_linux zip_web_linux @@ -60,7 +61,8 @@ mac: prepare compile_agent_mac compile_server_mac zip_web_mac dp-win64: prepare build_gui_win64 compile_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade dp-win32: prepare build_gui_win32 compile_launcher_win32 compile_server_win32 copy_files_win32 zip_win32 zip_win32_upgrade dp-linux: prepare build_gui_linux compile_server_linux copy_files_linux zip_linux zip_linux_upgrade -dp-mac: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade +dp-mac: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade +dp-mac-test: compile_ui_client_test build_gui_mac # 乐研 打包 ly-win64: prepare compile_ly_ui_client build_gui_win64 compile_ly_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade @@ -87,8 +89,12 @@ compile_ui_web: @cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/client/ui && cd ../leyanapi-backend compile_ui_demo: @cd ../deeptest-ui && yarn build:demo --dest ../deeptest/client/ui && cd ../deeptest + compile_ui_client: - @cd ui && yarn build --dest ../client/ui && cd .. + @cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd .. +compile_ui_client_test: + @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:clientTest --dest ../leyanapi-backend/client/ui && cd .. + compile_ly_ui_client: @cd ../leyanapi-frontend && yarn build:client && cd ../leyanapi-backend diff --git a/client/src/app/app.js b/client/src/app/app.js index 09201fb32..3356aa140 100644 --- a/client/src/app/app.js +++ b/client/src/app/app.js @@ -46,6 +46,7 @@ export class DeepTestApp { app.commandLine.appendSwitch('disable-site-isolation-trials') app.commandLine.appendSwitch('disable-features','BlockInsecurePrivateNetworkRequests') this._windows = new Map(); + // 需要启动本地 Agent 服务,之后再会启动 UI 服务 (async () => { port = await getUsefulPort(portAgent,56999); @@ -95,6 +96,7 @@ export class DeepTestApp { mainWin.show() this._windows.set('main', mainWin); + // 最终都是返回 http地址,远端 或者 本地http服务 const uiPort = process.env.UI_SERVER_PORT || await getUsefulPort(portClient,55999); const url = await startUIService(uiPort); diff --git a/client/src/app/utils/checkPort.js b/client/src/app/utils/checkPort.js index c9524222a..a46c793a4 100644 --- a/client/src/app/utils/checkPort.js +++ b/client/src/app/utils/checkPort.js @@ -23,7 +23,7 @@ export const getUsefulPort = async function (port, maxPort) { port: port, // minimum port maxPort: maxPort, // maximum port }); - logInfo(`>> getUsefulPort port ${port} is used ${newPort} : ${newPort !== port}`); + logInfo(`>> getUsefulPort: port = ${port}, newPort = ${newPort}`); return newPort; } From 8c9f1191e344899b023b8b3edc9ea9797b224540 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 15:46:21 +0800 Subject: [PATCH 03/36] execution --- client/src/app/app.js | 7 +++++-- client/src/app/core/ui.js | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/client/src/app/app.js b/client/src/app/app.js index 3356aa140..18b39862c 100644 --- a/client/src/app/app.js +++ b/client/src/app/app.js @@ -50,11 +50,14 @@ export class DeepTestApp { // 需要启动本地 Agent 服务,之后再会启动 UI 服务 (async () => { port = await getUsefulPort(portAgent,56999); + + logInfo(`>> starting deeptest agent on port ${port}`); + startAgent(port).then((agentUrl)=> { - if (agentUrl) logInfo(`>> deeptest server started successfully on : ${agentUrl}`); + if (agentUrl) logInfo(`>> deeptest agent started successfully at ${agentUrl}`); this.bindElectronEvents(); }).catch((err) => { - logErr('>> agent started failed, err: ' + err); + logErr('>> deeptest agent started failed on port ${port}, err: ' + err); process.exit(1); }) })() diff --git a/client/src/app/core/ui.js b/client/src/app/core/ui.js index 7eb369ee4..e13176f1b 100644 --- a/client/src/app/core/ui.js +++ b/client/src/app/core/ui.js @@ -27,43 +27,45 @@ export function startUIService(portClient) { } // 从环境变量中获取 ui 服务地址 - let {UI_SERVER_URL: uiServerUrl} = process.env; + let {UI_SERVER_URL: uiServerUrlOrPath} = process.env; - if (!uiServerUrl && !DEBUG) { - uiServerUrl = path.resolve(process.resourcesPath, 'ui'); + if (!uiServerUrlOrPath && !DEBUG) { + uiServerUrlOrPath = path.resolve(process.resourcesPath, 'ui'); } - // uiServerUrl = path.resolve(process.resourcesPath, 'ui'); - uiServerUrl = uiServerUrl || path.resolve(process.resourcesPath, 'ui'); + // uiServerUrlOrPath = path.resolve(process.resourcesPath, 'ui'); + uiServerUrlOrPath = uiServerUrlOrPath || path.resolve(process.resourcesPath, 'ui'); - if (uiServerUrl) { + if (uiServerUrlOrPath) { // 有效的 http 地址 - if (/^https?:\/\//.test(uiServerUrl)) { - return Promise.resolve(uiServerUrl); + if (/^https?:\/\//.test(uiServerUrlOrPath)) { + return Promise.resolve(uiServerUrlOrPath); } // 返回本地的静态资源路径,启动 express 服务 return new Promise((resolve, reject) => { - if (!path.isAbsolute(uiServerUrl)) { - uiServerUrl = path.resolve(app.getAppPath(), uiServerUrl); + if (!path.isAbsolute(uiServerUrlOrPath)) { + uiServerUrlOrPath = path.resolve(app.getAppPath(), uiServerUrlOrPath); } const port = portClient; - logInfo(`>> starting ui serer at ${uiServerUrl} with port ${port}`); + logInfo(`>> starting deeptest webui from dir ${uiServerUrlOrPath} with port ${port}`); const uiServer = express(); uiServer.use(history()); - uiServer.use(express.static(uiServerUrl)); + uiServer.use(express.static(uiServerUrlOrPath)); + const server = uiServer.listen(port, serverError => { if (serverError) { - console.error('>>> start ui server failed with error', serverError); + console.error('>>> start deeptest webui failed with error', serverError); _uiService = null; reject(serverError); } else { - logInfo(`>> ui server started successfully on http://localhost:${port}.`); + logInfo(`>> deeptest webui started successfully on http://localhost:${port}.`); resolve(`http://localhost:${port}`); } }); + // express 服务关闭时,清空 _uiService server.on('close', () => { _uiService = null; From 5ecda8ac3602c27a595edbc8655db5425921e738 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 16:30:59 +0800 Subject: [PATCH 04/36] execution --- client/src/app/app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/app/app.js b/client/src/app/app.js index 18b39862c..c45aa201b 100644 --- a/client/src/app/app.js +++ b/client/src/app/app.js @@ -106,7 +106,9 @@ export class DeepTestApp { await mainWin.loadURL(url); // 通知渲染进程,agent服务端口 - mainWin.webContents.send(electronMsgUsePort, {uiPort,agentPort:port}); + const data = {uiPort, agentPort: port} + logInfo(`send event to webpage, uiPort=${data.uiPort}, agentPort=${data.agentPort}`) + mainWin.webContents.send(electronMsgUsePort, data); // 读取服务配置 const confPath = path.join(os.homedir(), App, 'conf.yaml'); @@ -201,6 +203,7 @@ export class DeepTestApp { // this.buildAppMenu(); this.openOrCreateWindow() this.setAboutPanel(); + // 使用默认的快捷键,和常用的快捷键有冲突 // globalShortcut.register('CommandOrControl+D', () => { // const mainWin = this._windows.get('main'); @@ -239,6 +242,7 @@ export class DeepTestApp { // createWindow(); // } }); + // Quit when all windows are closed, except on macOS. There, it's common // for applications and their menu bar to stay active until the user quits // explicitly with Cmd + Q. From 4d90856d90222e1bfd2dce821b4f6d129daa27f1 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 16:53:01 +0800 Subject: [PATCH 05/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- xdoc/notes.txt | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0326d9503..acbfcb64d 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ compile_ui_demo: @cd ../deeptest-ui && yarn build:demo --dest ../deeptest/client/ui && cd ../deeptest compile_ui_client: - @cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd .. + @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd .. compile_ui_client_test: @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:clientTest --dest ../leyanapi-backend/client/ui && cd .. diff --git a/xdoc/notes.txt b/xdoc/notes.txt index 421accc08..a474eb723 100644 --- a/xdoc/notes.txt +++ b/xdoc/notes.txt @@ -71,13 +71,6 @@ nohup light-server -s ~/work/qiniu/deeptest > ~/light-server.log 2>&1 & git push -f github dt:main git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params -ENV=dp rm -rf bin && make default - -ENV=dp make win64 -ENV=dp make win32 -ENV=dp make linux -ENV=dp make mac - 测试: 基本Websocket ws://111.231.16.35:9090/ws @@ -93,3 +86,15 @@ gRPC ${eval("'url is ' + escape('https://baidu.com')")} 加 ${x} ${_do_something('test ' + g_var1 + ' ' + escape('https://baidu.com'))} int2=='101' && function(x) {return x + 100} (6) == 106 + +# 打包命令 +ENV=dp rm -rf bin && make default + +ENV=dp make compile_ui_client_test +ENV=dp make dp-win64 +ENV=dp make dp-win32 +ENV=dp make dp-linux +ENV=dp make dp-mac + +# 测试客户端 +ENV=dp make dp-mac-test \ No newline at end of file From bfa7c0bfe35c77678faca630841ec3a6bc0612c6 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 20:55:08 +0800 Subject: [PATCH 06/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-config | 2 +- client/forge.config.js | 4 +++- client/package.json | 23 ++++++++++------------- log/2024-01-23.log_lock | 0 4 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 log/2024-01-23.log_lock diff --git a/backend-config b/backend-config index 188cd29d7..aa600bfd9 160000 --- a/backend-config +++ b/backend-config @@ -1 +1 @@ -Subproject commit 188cd29d770cf5422e58d75409d270de1e8e98d3 +Subproject commit aa600bfd958d9721cd4cff639b19658017cec9e9 diff --git a/client/forge.config.js b/client/forge.config.js index 2760123ba..5d413b28d 100644 --- a/client/forge.config.js +++ b/client/forge.config.js @@ -17,7 +17,9 @@ module.exports = { { name: '@electron-forge/maker-squirrel', config: { - name: pkg?.name || 'deeptest' + name: pkg?.name || 'deeptest', + authors: 'AaronChen', + description: 'DeepTest Electron Client' } }, { diff --git a/client/package.json b/client/package.json index 33956e0f2..fea472f1f 100644 --- a/client/package.json +++ b/client/package.json @@ -17,27 +17,24 @@ "lint": "echo \"No linting configured\"" }, "keywords": [], - "author": { - "name": "Aaron Chen", - "email": "chenqi@easycorp.ltd" - }, + "author": "Aaron Chen", "license": "GPL3", "config": { "forge": "./forge.config.js" }, "devDependencies": { - "@electron-forge/cli": "^6.4.1", - "@electron-forge/maker-deb": "^6.4.1", - "@electron-forge/maker-rpm": "^6.4.1", - "@electron-forge/maker-squirrel": "^6.4.1", - "@electron-forge/maker-zip": "^6.4.1", - "@electron-forge/plugin-auto-unpack-natives": "^6.4.1", - "@electron-forge/plugin-webpack": "^6.4.1", + "@electron-forge/cli": "7.4.0", + "@electron-forge/maker-deb": "7.4.0", + "@electron-forge/maker-rpm": "7.4.0", + "@electron-forge/maker-squirrel": "7.4.0", + "@electron-forge/maker-zip": "7.4.0", + "@electron-forge/plugin-auto-unpack-natives": "7.4.0", + "@electron-forge/plugin-webpack": "7.4.0", "@timfish/forge-externals-plugin": "^0.2.0", "@vercel/webpack-asset-relocator-loader": "1.7.3", "css-loader": "^6.5.1", - "electron": "26.1.0", - "electron-packager": "15.4.0", + "electron": "30.0.9", + "electron-packager": "17.1.2", "node-loader": "^2.0.0", "style-loader": "^3.3.1" }, diff --git a/log/2024-01-23.log_lock b/log/2024-01-23.log_lock deleted file mode 100644 index e69de29bb..000000000 From 5a2b94ef540399269b9072b9506937c715be35e3 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 1 Jun 2024 20:56:47 +0800 Subject: [PATCH 07/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 +-- client/package.json | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index acbfcb64d..16b58f8d0 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,7 @@ BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main. default: compile_ui_web win64 win32 linux mac -# 非客户端版本打包 -# 先运行 make compile_ui_client +# 非客户端版本打包,更新客户端需先运行 make compile_ui_client win64: prepare compile_agent_win64 compile_server_win64 zip_web_win64 win32: prepare compile_agent_win32 compile_server_win32 zip_web_win32 linux: prepare compile_agent_linux compile_server_linux zip_web_linux diff --git a/client/package.json b/client/package.json index fea472f1f..f49dec263 100644 --- a/client/package.json +++ b/client/package.json @@ -23,6 +23,9 @@ "forge": "./forge.config.js" }, "devDependencies": { + "electron": "30.0.9", + "electron-packager": "17.1.2", + "@electron-forge/cli": "7.4.0", "@electron-forge/maker-deb": "7.4.0", "@electron-forge/maker-rpm": "7.4.0", @@ -30,11 +33,10 @@ "@electron-forge/maker-zip": "7.4.0", "@electron-forge/plugin-auto-unpack-natives": "7.4.0", "@electron-forge/plugin-webpack": "7.4.0", + "@timfish/forge-externals-plugin": "^0.2.0", "@vercel/webpack-asset-relocator-loader": "1.7.3", "css-loader": "^6.5.1", - "electron": "30.0.9", - "electron-packager": "17.1.2", "node-loader": "^2.0.0", "style-loader": "^3.3.1" }, From 57225cb5b6191112d488377e652d7ee6f89190bb Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:01:09 +0800 Subject: [PATCH 08/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/config/model.go | 8 ++++++++ internal/pkg/consts/consts.go | 5 ----- internal/server/modules/service/account.go | 14 ++++++++------ pkg/lib/mail/mail.go | 16 ++++++---------- res/server.yaml | 10 +++++++++- xdoc/notes.txt | 7 ++++--- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/internal/pkg/config/model.go b/internal/pkg/config/model.go index b0cfbb770..5fc7d619c 100644 --- a/internal/pkg/config/model.go +++ b/internal/pkg/config/model.go @@ -8,6 +8,7 @@ import ( type Config struct { MaxSize int64 `mapstructure:"max-size" json:"burst" yaml:"max-size"` System System `mapstructure:"system" json:"system" yaml:"system"` + Mail Mail `mapstructure:"mail" json:"mail" yaml:"mail"` Limit Limit `mapstructure:"limit" json:"limit" yaml:"limit"` Zap myZap.Zap `mapstructure:"zap" json:"zap" yaml:"zap"` Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"` @@ -34,6 +35,13 @@ type System struct { TimeFormat string `mapstructure:"time-format" json:"timeFormat" yaml:"time-format"` } +type Mail struct { + SmtpAddress string `mapstructure:"smtpAddress" json:"smtpAddress" yaml:"smtpAddress"` + SmtpPort int `mapstructure:"smtpPort" json:"smtpPort" yaml:"smtpPort"` + Account string `mapstructure:"account" json:"account" yaml:"account"` + Password string `mapstructure:"password" json:"password" yaml:"password"` +} + type Limit struct { Disable bool `mapstructure:"disable" json:"disable" yaml:"disable"` Limit float64 `mapstructure:"limit" json:"limit" yaml:"limit"` diff --git a/internal/pkg/consts/consts.go b/internal/pkg/consts/consts.go index fd1054417..6b999092a 100644 --- a/internal/pkg/consts/consts.go +++ b/internal/pkg/consts/consts.go @@ -41,11 +41,6 @@ const ( ExtractorErr = "extractor_err" ContentErr = "content_err" - EmailSmtpAddress = "smtp.exmail.qq.com" - EmailSmtpPort = 465 - EmailAccount = "chenqi@deeptest.com" - EmailPassword = "" - HttpRequestTimeout = 60 * time.Second DeepestKey = "com_deeptest_prop_for_selection" KEY_BASE_URL = "_base_url_" diff --git a/internal/server/modules/service/account.go b/internal/server/modules/service/account.go index 9efa74e48..28ff4c3e4 100644 --- a/internal/server/modules/service/account.go +++ b/internal/server/modules/service/account.go @@ -110,12 +110,14 @@ func (s *AccountService) Register(tenantId consts.TenantId, req v1.RegisterReq) s.UserRepo.Register(tenantId, &user) - //mp := map[string]string{ - // "name": user.Name, - // "sys": consts.Sys, - // "url": consts.Url, - //} - //_mailUtils.Send(user.Email, _i118Utils.Sprintf("register_success"), "register-success", mp) + if config.CONFIG.System.Name == "deeptest" { + mp := map[string]string{ + "name": user.Name, + "sys": consts.Sys, + "url": consts.Url, + } + _mailUtils.Send(user.Email, _i118Utils.Sprintf("register_success"), "register-success", mp) + } return } diff --git a/pkg/lib/mail/mail.go b/pkg/lib/mail/mail.go index de90f5f71..4b1a97f31 100644 --- a/pkg/lib/mail/mail.go +++ b/pkg/lib/mail/mail.go @@ -5,6 +5,7 @@ import ( "bytes" "fmt" "github.com/aaronchen2k/deeptest" + "github.com/aaronchen2k/deeptest/internal/pkg/config" "github.com/aaronchen2k/deeptest/internal/pkg/consts" "github.com/aaronchen2k/deeptest/pkg/lib/comm" "github.com/aaronchen2k/deeptest/pkg/lib/i118" @@ -20,18 +21,13 @@ import ( "strings" ) -// name -// inviter -// sys -// url -// vcode - func Send(to, subject, tmpl string, mp map[string]string) (err error) { d := gomail.NewDialer( - consts.EmailSmtpAddress, - consts.EmailSmtpPort, - consts.EmailAccount, - consts.EmailPassword) + config.CONFIG.Mail.SmtpAddress, + config.CONFIG.Mail.SmtpPort, + config.CONFIG.Mail.Account, + config.CONFIG.Mail.Password) + s, err := d.Dial() if err != nil { return diff --git a/res/server.yaml b/res/server.yaml index a1258e3be..c1f1f3200 100644 --- a/res/server.yaml +++ b/res/server.yaml @@ -9,6 +9,13 @@ limit: disable: true limit: 0 burst: 5 + +mail: + smtpAddress: smtp.exmail.qq.com + smtpPort: 465 + account: mail@deeptest.com + password: + max-size: 1024 maxsize: 1024 mcs: @@ -44,7 +51,7 @@ saas: appSecret: "" host: "" system: - name: "" + name: "deeptest" sysEnv: "" level: debug serverAddress: 0.0.0.0:8085 @@ -54,6 +61,7 @@ system: db-type: mysql cache-type: redis time-format: "2006-01-02 15:04:05" + thirdparty: username: "" password: "" diff --git a/xdoc/notes.txt b/xdoc/notes.txt index a474eb723..b35a5b4d9 100644 --- a/xdoc/notes.txt +++ b/xdoc/notes.txt @@ -68,9 +68,6 @@ npm config set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/ scp -r ~/work/qiniu/deeptest/* lighthouse@111.231.16.35:~/work/qiniu/deeptest nohup light-server -s ~/work/qiniu/deeptest > ~/light-server.log 2>&1 & -git push -f github dt:main -git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params - 测试: 基本Websocket ws://111.231.16.35:9090/ws @@ -87,6 +84,10 @@ gRPC ${_do_something('test ' + g_var1 + ' ' + escape('https://baidu.com'))} int2=='101' && function(x) {return x + 100} (6) == 106 +# 版本库 +git push -f github dt:main +git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params + # 打包命令 ENV=dp rm -rf bin && make default From 34ca3cfc9010ecf92e8e95240c64ac89ea7214ad Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:08:21 +0800 Subject: [PATCH 09/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/server.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/server.yaml b/res/server.yaml index c1f1f3200..0c0e98501 100644 --- a/res/server.yaml +++ b/res/server.yaml @@ -11,9 +11,9 @@ limit: burst: 5 mail: - smtpAddress: smtp.exmail.qq.com + smtpAddress: smtp.qq.com smtpPort: 465 - account: mail@deeptest.com + account: password: max-size: 1024 From f1e25add2929792370060eef43b6cfb041a37321 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:16:53 +0800 Subject: [PATCH 10/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/lib/mail/mail.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/lib/mail/mail.go b/pkg/lib/mail/mail.go index 4b1a97f31..66da7fc01 100644 --- a/pkg/lib/mail/mail.go +++ b/pkg/lib/mail/mail.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/aaronchen2k/deeptest" "github.com/aaronchen2k/deeptest/internal/pkg/config" - "github.com/aaronchen2k/deeptest/internal/pkg/consts" "github.com/aaronchen2k/deeptest/pkg/lib/comm" "github.com/aaronchen2k/deeptest/pkg/lib/i118" "github.com/aaronchen2k/deeptest/pkg/lib/log" @@ -34,7 +33,7 @@ func Send(to, subject, tmpl string, mp map[string]string) (err error) { } m := gomail.NewMessage() - m.SetHeader("From", consts.SupportEmail) + m.SetHeader("From", config.CONFIG.Mail.Account) m.SetAddressHeader("To", to, mp["name"]) m.SetHeader("Subject", subject) From 40ed48eed1b87d354e2b4649a35480a373cc6417 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:19:12 +0800 Subject: [PATCH 11/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/tmpl/reset-password.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/tmpl/reset-password.ftl b/res/tmpl/reset-password.ftl index d2bc77f3a..4eba21aa3 100644 --- a/res/tmpl/reset-password.ftl +++ b/res/tmpl/reset-password.ftl @@ -15,7 +15,7 @@
- 请访问 ${url}#/user/resetPassword/${name}/${vcode}, 重置您的密码。 + 请访问 ${url}user/resetPassword/${name}/${vcode}, 重置您的密码。
\ No newline at end of file From 9e35f65c6204a0d29e8500068d7b28fb6214e4d7 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:49:47 +0800 Subject: [PATCH 12/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/pkg/config/model.go | 6 +++++- internal/pkg/consts/consts.go | 5 +---- internal/server/modules/service/account.go | 8 ++++---- internal/server/modules/service/user.go | 7 ++++--- res/server.yaml | 6 +++++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/internal/pkg/config/model.go b/internal/pkg/config/model.go index 5fc7d619c..2bacbe35e 100644 --- a/internal/pkg/config/model.go +++ b/internal/pkg/config/model.go @@ -23,7 +23,11 @@ type Config struct { } type System struct { - Name string `mapstructure:"name" json:"name" yaml:"name"` + Name string `mapstructure:"name" json:"name" yaml:"name"` + + SupportMail string `mapstructure:"supportMail" json:"supportMail" yaml:"supportMail"` + Website string `mapstructure:"website" json:"website" yaml:"website"` + SysEnv string `mapstructure:"sysEnv" json:"sysEnv" yaml:"sysEnv"` // dev, leyan_test, deeptest_demo etc. Level string `mapstructure:"level" json:"level" yaml:"level"` // debug,release,test ServerAddress string `mapstructure:"serverAddress" json:"serverAddress" yaml:"serverAddress"` diff --git a/internal/pkg/consts/consts.go b/internal/pkg/consts/consts.go index 6b999092a..23ed45523 100644 --- a/internal/pkg/consts/consts.go +++ b/internal/pkg/consts/consts.go @@ -33,10 +33,7 @@ const ( ServerConfigFileName = "server.yaml" CasbinFileName = "rbac_model.conf" // casbin 规则文件名称 - SupportEmail = "chenqi@deeptest.com" - Sys = "DeepTest" - Url = "https://deeptest.com/" - UrlDev = "http://localhost:8000/" + WebsiteDev = "http://localhost:8000/" ExtractorErr = "extractor_err" ContentErr = "content_err" diff --git a/internal/server/modules/service/account.go b/internal/server/modules/service/account.go index 28ff4c3e4..dccd2e8dd 100644 --- a/internal/server/modules/service/account.go +++ b/internal/server/modules/service/account.go @@ -113,8 +113,8 @@ func (s *AccountService) Register(tenantId consts.TenantId, req v1.RegisterReq) if config.CONFIG.System.Name == "deeptest" { mp := map[string]string{ "name": user.Name, - "sys": consts.Sys, - "url": consts.Url, + "sys": config.CONFIG.System.Name, + "url": config.CONFIG.System.Website, } _mailUtils.Send(user.Email, _i118Utils.Sprintf("register_success"), "register-success", mp) } @@ -127,9 +127,9 @@ func (s *AccountService) ForgotPassword(tenantId consts.TenantId, usernameOrPass vcode, err := s.UserRepo.GenAndUpdateVcode(tenantId, user.ID) - url := consts.Url + url := config.CONFIG.System.Website if !consts.IsRelease { - url = consts.UrlDev + url = consts.WebsiteDev } settings := map[string]string{ "name": user.Username, diff --git a/internal/server/modules/service/user.go b/internal/server/modules/service/user.go index da1e6cf7c..f8cc3f5a9 100644 --- a/internal/server/modules/service/user.go +++ b/internal/server/modules/service/user.go @@ -2,6 +2,7 @@ package service import ( v1 "github.com/aaronchen2k/deeptest/cmd/server/v1/domain" + "github.com/aaronchen2k/deeptest/internal/pkg/config" "github.com/aaronchen2k/deeptest/internal/pkg/consts" "github.com/aaronchen2k/deeptest/internal/server/modules/model" "github.com/aaronchen2k/deeptest/internal/server/modules/repo" @@ -81,15 +82,15 @@ func (s *UserService) Invite(tenantId consts.TenantId, req v1.InviteUserReq) (us vcode, _ := s.UserRepo.GenAndUpdateVcode(tenantId, user.ID) - url := consts.Url + url := config.CONFIG.System.Website if !consts.IsRelease { - url = consts.UrlDev + url = consts.WebsiteDev } settings := map[string]string{ "name": user.Username, "url": url, "vcode": vcode, - "sys": consts.Sys, + "sys": config.CONFIG.System.Name, } _mailUtils.Send(user.Email, _i118Utils.Sprintf("invite_user"), "invite-user", settings) diff --git a/res/server.yaml b/res/server.yaml index 0c0e98501..c4dbfeab4 100644 --- a/res/server.yaml +++ b/res/server.yaml @@ -51,8 +51,12 @@ saas: appSecret: "" host: "" system: - name: "deeptest" + name: "DeepTest" sysEnv: "" + + supportMail: chenqi@deeptest.com + website: http://deeptest.com/ + level: debug serverAddress: 0.0.0.0:8085 agentAddress: "" From eacc8e501115af5a557748349c6ba125ad3e7958 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:51:20 +0800 Subject: [PATCH 13/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/server/modules/service/account.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/server/modules/service/account.go b/internal/server/modules/service/account.go index dccd2e8dd..da2775277 100644 --- a/internal/server/modules/service/account.go +++ b/internal/server/modules/service/account.go @@ -16,6 +16,7 @@ import ( "go.uber.org/zap" "golang.org/x/crypto/bcrypt" "strconv" + "strings" "time" ) @@ -110,7 +111,7 @@ func (s *AccountService) Register(tenantId consts.TenantId, req v1.RegisterReq) s.UserRepo.Register(tenantId, &user) - if config.CONFIG.System.Name == "deeptest" { + if strings.ToLower(config.CONFIG.System.Name) == "deeptest" { mp := map[string]string{ "name": user.Name, "sys": config.CONFIG.System.Name, From bb4f300b56ffddd794463c04b7bb35f04c8c8828 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 15:54:18 +0800 Subject: [PATCH 14/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/server.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/server.yaml b/res/server.yaml index c4dbfeab4..28fb2afa6 100644 --- a/res/server.yaml +++ b/res/server.yaml @@ -55,7 +55,7 @@ system: sysEnv: "" supportMail: chenqi@deeptest.com - website: http://deeptest.com/ + website: http://demo.deeptest.com/ level: debug serverAddress: 0.0.0.0:8085 From 0d809c6a88a4cc4193ff8885e381a647f4ef79b7 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sun, 2 Jun 2024 16:14:31 +0800 Subject: [PATCH 15/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/server/modules/service/account.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/server/modules/service/account.go b/internal/server/modules/service/account.go index da2775277..6a16f1a88 100644 --- a/internal/server/modules/service/account.go +++ b/internal/server/modules/service/account.go @@ -113,9 +113,10 @@ func (s *AccountService) Register(tenantId consts.TenantId, req v1.RegisterReq) if strings.ToLower(config.CONFIG.System.Name) == "deeptest" { mp := map[string]string{ - "name": user.Name, - "sys": config.CONFIG.System.Name, - "url": config.CONFIG.System.Website, + "name": user.Name, + "sys": config.CONFIG.System.Name, + "url": config.CONFIG.System.Website, + "toEmail": user.Email, } _mailUtils.Send(user.Email, _i118Utils.Sprintf("register_success"), "register-success", mp) } @@ -133,9 +134,10 @@ func (s *AccountService) ForgotPassword(tenantId consts.TenantId, usernameOrPass url = consts.WebsiteDev } settings := map[string]string{ - "name": user.Username, - "url": url, - "vcode": vcode, + "name": user.Username, + "url": url, + "vcode": vcode, + "toEmail": user.Email, } _mailUtils.Send(user.Email, _i118Utils.Sprintf("reset_password"), "reset-password", settings) From 9c6cc6927fd8851c10a625c50fba6943942d693f Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Tue, 4 Jun 2024 09:10:15 +0800 Subject: [PATCH 16/36] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/agent.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/agent.yaml b/res/agent.yaml index fc377c9ca..f58bf475e 100644 --- a/res/agent.yaml +++ b/res/agent.yaml @@ -1,6 +1,6 @@ limit: disable: true - limit: 10 + limit: 0 burst: 5 system: level: debug From 20f4e3f5553471549490c6933abe7d60d1d32892 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 12 Jun 2024 11:02:13 +0800 Subject: [PATCH 17/36] OpenAI --- cmd/server/v1/domain/aichat.go | 34 ++++++++ cmd/server/v1/handler/aichat.go | 61 +++++++++++++ cmd/server/v1/index.go | 4 + cmd/server/v1/router/aichat.go | 22 +++++ go.mod | 2 + go.sum | 5 ++ internal/pkg/config/model.go | 5 +- internal/server/modules/service/aichat.go | 102 ++++++++++++++++++++++ res/server.yaml | 4 + 9 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 cmd/server/v1/domain/aichat.go create mode 100644 cmd/server/v1/handler/aichat.go create mode 100644 cmd/server/v1/router/aichat.go create mode 100644 internal/server/modules/service/aichat.go diff --git a/cmd/server/v1/domain/aichat.go b/cmd/server/v1/domain/aichat.go new file mode 100644 index 000000000..13f1027a5 --- /dev/null +++ b/cmd/server/v1/domain/aichat.go @@ -0,0 +1,34 @@ +package serverDomain + +type KnowledgeBaseChatReq struct { + Query string `json:"query"` + KnowledgeBaseName string `json:"knowledge_base_name"` + TopK int `json:"top_k"` + ScoreThreshold int `json:"score_threshold"` + History []struct { + Role string `json:"role"` + Content string `json:"content"` + } `json:"history"` + Stream bool `json:"stream"` + ModelName string `json:"model_name"` + Temperature float64 `json:"temperature"` + MaxTokens int `json:"max_tokens"` + PromptName string `json:"prompt_name"` +} + +type ChatChatModelReq struct { + ControllerAddress string `json:"controller_address"` + Placeholder string `json:"placeholder"` +} + +type ChatChatModel struct { + Type string `json:"type"` + Code string `json:"code"` + Name string `json:"name"` + + Host string `json:"host"` + Port int `json:"port"` + Device string `json:"device"` + InferTurbo bool `json:"infer_turbo"` + ModelPath string `json:"model_path"` +} diff --git a/cmd/server/v1/handler/aichat.go b/cmd/server/v1/handler/aichat.go new file mode 100644 index 000000000..d4a7afcdf --- /dev/null +++ b/cmd/server/v1/handler/aichat.go @@ -0,0 +1,61 @@ +package handler + +import ( + v1 "github.com/aaronchen2k/deeptest/cmd/server/v1/domain" + "github.com/aaronchen2k/deeptest/internal/server/modules/service" + _domain "github.com/aaronchen2k/deeptest/pkg/domain" + "github.com/kataras/iris/v12" +) + +type AiChatCtrl struct { + BaseCtrl + AiChatService *service.AiChatService `inject:""` +} + +func (c *AiChatCtrl) ListValidModel(ctx iris.Context) { + req := v1.ChatChatModelReq{} + err := ctx.ReadJSON(&req) + if err != nil { + ctx.JSON(_domain.Response{Code: _domain.SystemErr.Code, Msg: err.Error()}) + return + } + + data, err := c.AiChatService.ListValidModel(req) + if err != nil { + ctx.JSON(_domain.Response{Code: _domain.SystemErr.Code, Msg: err.Error()}) + return + } + + ctx.JSON(_domain.Response{Code: _domain.NoErr.Code, Data: data}) +} + +func (c *AiChatCtrl) ListKnowledgeBase(ctx iris.Context) { + data, err := c.AiChatService.ListKnowledgeBase() + if err != nil { + ctx.JSON(_domain.Response{Code: _domain.SystemErr.Code, Msg: err.Error()}) + return + } + + ctx.JSON(_domain.Response{Code: _domain.NoErr.Code, Data: data}) +} + +func (c *AiChatCtrl) KnowledgeBaseChat(ctx iris.Context) { + flusher, ok := ctx.ResponseWriter().Flusher() + if !ok { + ctx.StopWithText(iris.StatusHTTPVersionNotSupported, "Streaming unsupported!") + return + } + + ctx.ContentType("text/event-stream") + //ctx.Header("content-type", "text/event-stream") + ctx.Header("Cache-Control", "no-cache") + + req := v1.KnowledgeBaseChatReq{} + err := ctx.ReadJSON(&req) + if err != nil { + ctx.JSON(_domain.Response{Code: _domain.SystemErr.Code, Msg: err.Error()}) + return + } + + c.AiChatService.KnowledgeBaseChat(req, flusher, ctx) +} diff --git a/cmd/server/v1/index.go b/cmd/server/v1/index.go index 525de932d..ea3c90e55 100644 --- a/cmd/server/v1/index.go +++ b/cmd/server/v1/index.go @@ -90,6 +90,8 @@ type IndexModule struct { SaaSModule *router.SaaSModule `inject:""` EndpointFavoriteModule *router.EndpointFavoriteModule `inject:""` + + AiChatModule *router.AiChatModule `inject:""` } func NewIndexModule() *IndexModule { @@ -184,6 +186,8 @@ func (m *IndexModule) ApiParty() module.WebModule { m.ProjectCronModule.Party(), m.SaaSModule.Party(), m.EndpointFavoriteModule.Party(), + + m.AiChatModule.Party(), } return module.NewModule(consts.ApiPathServer, handler, modules...) diff --git a/cmd/server/v1/router/aichat.go b/cmd/server/v1/router/aichat.go new file mode 100644 index 000000000..e614db422 --- /dev/null +++ b/cmd/server/v1/router/aichat.go @@ -0,0 +1,22 @@ +package router + +import ( + "github.com/aaronchen2k/deeptest/cmd/server/v1/handler" + "github.com/aaronchen2k/deeptest/internal/pkg/core/module" + "github.com/kataras/iris/v12" +) + +type AiChatModule struct { + AiChatCtrl *handler.AiChatCtrl `inject:""` +} + +// Party chatchat +func (m *AiChatModule) Party() module.WebModule { + handler := func(index iris.Party) { + index.Post("/list_valid_models", m.AiChatCtrl.ListValidModel).Name = "列出大模型" + index.Get("/list_knowledge_bases", m.AiChatCtrl.ListKnowledgeBase).Name = "列出知识库" + + index.Post("/knowledge_base_chat", m.AiChatCtrl.KnowledgeBaseChat).Name = "与知识库对话" + } + return module.NewModule("/aichat", handler) +} diff --git a/go.mod b/go.mod index 31f3f20ec..04857d537 100644 --- a/go.mod +++ b/go.mod @@ -181,6 +181,7 @@ require ( github.com/pelletier/go-toml v1.9.3 // indirect github.com/pierrec/lz4/v4 v4.0.3 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/r3labs/sse/v2 v2.10.0 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.3 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect @@ -221,6 +222,7 @@ require ( google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect + gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect diff --git a/go.sum b/go.sum index 8d74f2e4e..8bc00bd03 100644 --- a/go.sum +++ b/go.sum @@ -740,6 +740,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/r3labs/sse/v2 v2.10.0 h1:hFEkLLFY4LDifoHdiCN/LlGBAdVJYsANaLqNYa1l/v0= +github.com/r3labs/sse/v2 v2.10.0/go.mod h1:Igau6Whc+F17QUgML1fYe1VPZzTV6EMCnYktEmkNJ7I= github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM= github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= @@ -1047,6 +1049,7 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1425,6 +1428,8 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gG gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= +gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y= +gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/pkg/config/model.go b/internal/pkg/config/model.go index 2bacbe35e..0ae4e2448 100644 --- a/internal/pkg/config/model.go +++ b/internal/pkg/config/model.go @@ -18,8 +18,11 @@ type Config struct { ThirdParty ThirdParty `mapstructure:"third-party" json:"third-party" yaml:"third-party"` Mcs Mcs `mapstructure:"mcs" json:"mcs" yaml:"mcs"` Environment Environment `mapstructure:"environment" json:"environment" yaml:"environment"` - OpenApi OpenApi `mapstructure:"openapi" json:"openapi" yaml:"openapi"` Saas Saas `mapstructure:"saas" json:"saas" yaml:"saas"` + + OpenApi OpenApi `mapstructure:"openapi" json:"openapi" yaml:"openapi"` + ChatChatUrl string `mapstructure:"chatChatUrl" json:"chatChatUrl" yaml:"chatChatUrl"` + ChatChatControllerAddress string `mapstructure:"chatChatControllerAddress" json:"chatChatControllerAddress" yaml:"chatChatControllerAddress"` } type System struct { diff --git a/internal/server/modules/service/aichat.go b/internal/server/modules/service/aichat.go new file mode 100644 index 000000000..bc54ae1c1 --- /dev/null +++ b/internal/server/modules/service/aichat.go @@ -0,0 +1,102 @@ +package service + +import ( + "bytes" + "encoding/json" + v1 "github.com/aaronchen2k/deeptest/cmd/server/v1/domain" + "github.com/aaronchen2k/deeptest/internal/pkg/config" + "github.com/aaronchen2k/deeptest/pkg/domain" + _httpUtils "github.com/aaronchen2k/deeptest/pkg/lib/http" + "github.com/kataras/iris/v12" + "net/http" +) + +type AiChatService struct { +} + +func (s *AiChatService) KnowledgeBaseChat(req v1.KnowledgeBaseChatReq, flusher http.Flusher, ctx iris.Context) (ret _domain.PageData, err error) { + url := _httpUtils.AddSepIfNeeded(config.CONFIG.ChatChatUrl) + "chat/knowledge_base_chat" + + bts, err := json.Marshal(req) + + reader := bytes.NewReader(bts) + request, err := http.NewRequest("POST", url, reader) + if err != nil { + return + } + + request.Header.Set("Cache-Control", "no-cache") + request.Header.Set("Accept", "text/event-stream") + request.Header.Set("Connection", "keep-alive") + + client := &http.Client{} + resp, err := client.Do(request) + if err != nil { + return + } + + for { + data := make([]byte, 1024) + _, err1 := resp.Body.Read(data) + if err1 != nil { + break + } + + // must with prefix "data:" which is from openai response msg, + // must add a postfix "\n\n" + ctx.Writef("%s\n\n", string(data)) + + flusher.Flush() + } + + return +} + +func (s *AiChatService) ListValidModel(v1.ChatChatModelReq) (ret []v1.ChatChatModel, err error) { + // now no local models, just return one online openai-api llm + ret = append(ret, v1.ChatChatModel{ + Type: "online", + Code: "openai-api", + Name: "OpenAI", + }) + + //url := _httpUtils.AddSepIfNeeded(config.CONFIG.ChatChatUrl) + "llm_model/list_running_models" + // + //body := v1.ChatChatModelReq{ + // ControllerAddress: config.CONFIG.ChatChatControllerAddress, + //} + // + //bytes, err := _httpUtils.Post(url, body) + //if err != nil { + // return + //} + // + // resp := iris.Map{} + //err = json.Unmarshal(bytes, &resp) + //if err != nil { + // return + //} + // + // ret = resp["data"].([]v1.ChatChatModel) + + return +} + +func (s *AiChatService) ListKnowledgeBase() (ret []interface{}, err error) { + url := _httpUtils.AddSepIfNeeded(config.CONFIG.ChatChatUrl) + "knowledge_base/list_knowledge_bases" + + bytes, err := _httpUtils.Get(url) + if err != nil { + return + } + + resp := iris.Map{} + err = json.Unmarshal(bytes, &resp) + if err != nil { + return + } + + ret = resp["data"].([]interface{}) + + return +} diff --git a/res/server.yaml b/res/server.yaml index 28fb2afa6..298fae969 100644 --- a/res/server.yaml +++ b/res/server.yaml @@ -1,3 +1,4 @@ + captcha: key-long: 6 img-width: 240 @@ -85,3 +86,6 @@ zap: encode-level: "" stacktrace-key: stacktrace log-in-console: true + +chatChatUrl: http://127.0.0.1:7861/ +chatChatControllerAddress: http://127.0.0.1:20001/ From 6f09695ae19acf934e8043cffba5ffc1bb5129bb Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Fri, 14 Jun 2024 09:56:03 +0800 Subject: [PATCH 18/36] OpenAI --- internal/server/modules/service/aichat.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/server/modules/service/aichat.go b/internal/server/modules/service/aichat.go index bc54ae1c1..1741a168e 100644 --- a/internal/server/modules/service/aichat.go +++ b/internal/server/modules/service/aichat.go @@ -3,20 +3,29 @@ package service import ( "bytes" "encoding/json" + "fmt" v1 "github.com/aaronchen2k/deeptest/cmd/server/v1/domain" "github.com/aaronchen2k/deeptest/internal/pkg/config" "github.com/aaronchen2k/deeptest/pkg/domain" _httpUtils "github.com/aaronchen2k/deeptest/pkg/lib/http" "github.com/kataras/iris/v12" "net/http" + "strings" ) type AiChatService struct { } func (s *AiChatService) KnowledgeBaseChat(req v1.KnowledgeBaseChatReq, flusher http.Flusher, ctx iris.Context) (ret _domain.PageData, err error) { - url := _httpUtils.AddSepIfNeeded(config.CONFIG.ChatChatUrl) + "chat/knowledge_base_chat" + if strings.TrimSpace(req.Query) == "小乐" { + str := fmt.Sprintf(`data: {"answer": "您好,有什么可以帮助您的?"}`) + + ctx.Writef("%s\n\n", str) + flusher.Flush() + return + } + url := _httpUtils.AddSepIfNeeded(config.CONFIG.ChatChatUrl) + "chat/knowledge_base_chat" bts, err := json.Marshal(req) reader := bytes.NewReader(bts) From 726eb8cc957029a85afde2c009d402846b94174d Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 11:12:47 +0800 Subject: [PATCH 19/36] Create nancal.yaml --- .github/workflows/nancal.yaml | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/nancal.yaml diff --git a/.github/workflows/nancal.yaml b/.github/workflows/nancal.yaml new file mode 100644 index 000000000..3320486a2 --- /dev/null +++ b/.github/workflows/nancal.yaml @@ -0,0 +1,46 @@ +name: nancal site deploy + +on: + workflow_dispatch + # pull_request: + # branches: [ "main" ] + # push: + # branches: [ "main" ] + +jobs: + build-and-deploy: + runs-on: nancal + defaults: + run: + working-directory: /home/nancal/rd/project/deeptest + steps: + - name: checkout backend codes + run: git pull + + - name: checkout frontend codes + run: git pull + working-directory: /home/nancal/rd/project/deeptest-ui + + - name: make server + run: ENV=dp make compile_server_linux + + - name: make agent + run: ENV=dp make compile_agent_linux + + - name: make ui + run: make compile_ui_demo + + - name: copy files + run: | + cp -f bin/linux/deeptest-server /home/nancal/rd/server/ + cp -f client/bin/linux/deeptest-agent /home/nancal/rd/server/ + + rm -rf /home/nancal/rd/server/deeptest-ui + cp -fr client/ui /home/nancal/rd/server/deeptest-ui + + - name: start service + run: | + ps -ef | grep 'deeptest-' | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 + cd /home/nancal/rd/server + RUNNER_TRACKING_ID="" && nohup ./deeptest-server > server.log 2>&1 & + RUNNER_TRACKING_ID="" && nohup ./deeptest-agent > agent.log 2>&1 & From 8a121a8fe7706df78c39cf40bb6d9c3f0f932283 Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 11:13:33 +0800 Subject: [PATCH 20/36] Update nancal.yaml --- .github/workflows/nancal.yaml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nancal.yaml b/.github/workflows/nancal.yaml index 3320486a2..5994fe695 100644 --- a/.github/workflows/nancal.yaml +++ b/.github/workflows/nancal.yaml @@ -1,25 +1,25 @@ -name: nancal site deploy +name: demo site deploy on: workflow_dispatch # pull_request: - # branches: [ "main" ] - # push: - # branches: [ "main" ] +# branches: [ "main" ] +# push: +# branches: [ "main" ] jobs: build-and-deploy: - runs-on: nancal + runs-on: self-hosted defaults: run: - working-directory: /home/nancal/rd/project/deeptest + working-directory: /rd/project/deeptest steps: - name: checkout backend codes run: git pull - name: checkout frontend codes run: git pull - working-directory: /home/nancal/rd/project/deeptest-ui + working-directory: /rd/project/deeptest-ui - name: make server run: ENV=dp make compile_server_linux @@ -32,15 +32,16 @@ jobs: - name: copy files run: | - cp -f bin/linux/deeptest-server /home/nancal/rd/server/ - cp -f client/bin/linux/deeptest-agent /home/nancal/rd/server/ + mkdir -p /rd/server + cp -f bin/linux/deeptest-server /rd/server/ + cp -f client/bin/linux/deeptest-agent /rd/server/ - rm -rf /home/nancal/rd/server/deeptest-ui - cp -fr client/ui /home/nancal/rd/server/deeptest-ui + rm -rf /rd/server/deeptest-ui + cp -fr client/ui /rd/server/deeptest-ui - name: start service run: | ps -ef | grep 'deeptest-' | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 - cd /home/nancal/rd/server + cd /rd/server RUNNER_TRACKING_ID="" && nohup ./deeptest-server > server.log 2>&1 & RUNNER_TRACKING_ID="" && nohup ./deeptest-agent > agent.log 2>&1 & From a115c3cddd989f17c241ef2a00d5d2ac273aa439 Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 11:15:07 +0800 Subject: [PATCH 21/36] Update nancal.yaml --- .github/workflows/nancal.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nancal.yaml b/.github/workflows/nancal.yaml index 5994fe695..64ba95f36 100644 --- a/.github/workflows/nancal.yaml +++ b/.github/workflows/nancal.yaml @@ -12,14 +12,14 @@ jobs: runs-on: self-hosted defaults: run: - working-directory: /rd/project/deeptest + working-directory: /home/nancal/rd/project/deeptest steps: - name: checkout backend codes run: git pull - name: checkout frontend codes run: git pull - working-directory: /rd/project/deeptest-ui + working-directory: /home/nancal/rd/project/deeptest-ui - name: make server run: ENV=dp make compile_server_linux @@ -32,16 +32,16 @@ jobs: - name: copy files run: | - mkdir -p /rd/server - cp -f bin/linux/deeptest-server /rd/server/ - cp -f client/bin/linux/deeptest-agent /rd/server/ + mkdir -p /home/nancal/rd/server + cp -f bin/linux/deeptest-server /home/nancal/rd/server/ + cp -f client/bin/linux/deeptest-agent /home/nancal/rd/server/ - rm -rf /rd/server/deeptest-ui - cp -fr client/ui /rd/server/deeptest-ui + rm -rf /home/nancal/rd/server/deeptest-ui + cp -fr client/ui /home/nancal/rd/server/deeptest-ui - name: start service run: | ps -ef | grep 'deeptest-' | grep -v grep | awk '{print $2}' | xargs --no-run-if-empty kill -9 - cd /rd/server + cd /home/nancal/rd/server RUNNER_TRACKING_ID="" && nohup ./deeptest-server > server.log 2>&1 & RUNNER_TRACKING_ID="" && nohup ./deeptest-agent > agent.log 2>&1 & From db31dbdf3ff246d9d4a20b959ac411a39639d5a9 Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 11:15:31 +0800 Subject: [PATCH 22/36] Update nancal.yaml --- .github/workflows/nancal.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nancal.yaml b/.github/workflows/nancal.yaml index 64ba95f36..02004af21 100644 --- a/.github/workflows/nancal.yaml +++ b/.github/workflows/nancal.yaml @@ -1,4 +1,4 @@ -name: demo site deploy +name: nancal site deploy on: workflow_dispatch @@ -9,7 +9,7 @@ on: jobs: build-and-deploy: - runs-on: self-hosted + runs-on: nancal defaults: run: working-directory: /home/nancal/rd/project/deeptest From 3b8ec97db21837ff5e94123512ed5651e49400dd Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 11:22:07 +0800 Subject: [PATCH 23/36] Rename nancal.yaml to nancal.yml --- .github/workflows/{nancal.yaml => nancal.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{nancal.yaml => nancal.yml} (100%) diff --git a/.github/workflows/nancal.yaml b/.github/workflows/nancal.yml similarity index 100% rename from .github/workflows/nancal.yaml rename to .github/workflows/nancal.yml From bacb6aeccd75243d12222d9cb5ce47054008c2b3 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Fri, 14 Jun 2024 14:04:11 +0800 Subject: [PATCH 24/36] OpenAI --- xdoc/notes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/xdoc/notes.txt b/xdoc/notes.txt index b35a5b4d9..5be0ef2b8 100644 --- a/xdoc/notes.txt +++ b/xdoc/notes.txt @@ -87,6 +87,7 @@ gRPC # 版本库 git push -f github dt:main git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params +git push -f github feature/chenqi99/openai:feature/chenqi99/openai # 打包命令 ENV=dp rm -rf bin && make default From 78fe2bdeab7d68fc6ff891c82fa3eb7b97215a8e Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 14:09:14 +0800 Subject: [PATCH 25/36] Update nancal.yml --- .github/workflows/nancal.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nancal.yml b/.github/workflows/nancal.yml index 02004af21..f7454fe7f 100644 --- a/.github/workflows/nancal.yml +++ b/.github/workflows/nancal.yml @@ -3,9 +3,9 @@ name: nancal site deploy on: workflow_dispatch # pull_request: -# branches: [ "main" ] -# push: -# branches: [ "main" ] + # branches: [ "main" ] + # push: + # branches: [ "main" ] jobs: build-and-deploy: From a011c5f5ba35807dd7b1c94d75f0d79de9aac968 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Fri, 14 Jun 2024 14:09:45 +0800 Subject: [PATCH 26/36] OpenAI --- xdoc/notes.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xdoc/notes.txt b/xdoc/notes.txt index 5be0ef2b8..4e0071eed 100644 --- a/xdoc/notes.txt +++ b/xdoc/notes.txt @@ -89,6 +89,8 @@ git push -f github dt:main git push -f github feature/chenqi99/var_in_params:feature/chenqi99/var_in_params git push -f github feature/chenqi99/openai:feature/chenqi99/openai +git pull github feature/chenqi99/openai + # 打包命令 ENV=dp rm -rf bin && make default From 133fa362f384088b2d8b8a636c07fc7ac1290ccf Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Fri, 14 Jun 2024 14:16:49 +0800 Subject: [PATCH 27/36] OpenAI --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 16b58f8d0..072df3a7e 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,8 @@ compile_ui_web: @cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/client/ui && cd ../leyanapi-backend compile_ui_demo: @cd ../deeptest-ui && yarn build:demo --dest ../deeptest/client/ui && cd ../deeptest +compile_ui_nancal: + @cd ../deeptest-ui && yarn build:nancal --dest ../deeptest/client/ui && cd ../deeptest compile_ui_client: @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd .. From c4136013651b94119dd839890bd45a3299318da8 Mon Sep 17 00:00:00 2001 From: Aaron Chen <462826@qq.com> Date: Fri, 14 Jun 2024 14:21:52 +0800 Subject: [PATCH 28/36] Update nancal.yml --- .github/workflows/nancal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nancal.yml b/.github/workflows/nancal.yml index f7454fe7f..690e641cc 100644 --- a/.github/workflows/nancal.yml +++ b/.github/workflows/nancal.yml @@ -28,7 +28,7 @@ jobs: run: ENV=dp make compile_agent_linux - name: make ui - run: make compile_ui_demo + run: make compile_ui_nancal - name: copy files run: | From 20cbb917290cb34b48d289a41870b752435a1828 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Mon, 17 Jun 2024 16:44:27 +0800 Subject: [PATCH 29/36] OpenAI --- internal/server/modules/service/aichat.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/server/modules/service/aichat.go b/internal/server/modules/service/aichat.go index 1741a168e..a5917d161 100644 --- a/internal/server/modules/service/aichat.go +++ b/internal/server/modules/service/aichat.go @@ -17,6 +17,7 @@ type AiChatService struct { } func (s *AiChatService) KnowledgeBaseChat(req v1.KnowledgeBaseChatReq, flusher http.Flusher, ctx iris.Context) (ret _domain.PageData, err error) { + //req.KnowledgeBaseName = "samples" if strings.TrimSpace(req.Query) == "小乐" { str := fmt.Sprintf(`data: {"answer": "您好,有什么可以帮助您的?"}`) From b93e38ce5e5aa54737682f5e8067d8f926573885 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 13 Jul 2024 10:02:48 +0800 Subject: [PATCH 30/36] OpenAI --- Makefile | 6 ++++++ cmd/server/v1/router/aichat.go | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 072df3a7e..8d49d83f8 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,7 @@ BUILD_CMD_UNIX=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.Build BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" default: compile_ui_web win64 win32 linux mac +server: compile_server_win64 compile_server_win32 compile_server_linux compile_server_mac copy_server # 非客户端版本打包,更新客户端需先运行 make compile_ui_client win64: prepare compile_agent_win64 compile_server_win64 zip_web_win64 @@ -392,6 +393,11 @@ upload_to: @qshell qupload2 --src-dir=${QINIU_DIR} --bucket=download --thread-count=10 --log-file=qshell.log \ --skip-path-prefixes=ztf,zd,zv,zmanager,driver --rescan-local --overwrite --check-hash +copy_server: + @cp bin/win64/${PROJECT}-server.exe ${QINIU_DIST_DIR}win64/ + @cp bin/win32/${PROJECT}-server.exe ${QINIU_DIST_DIR}win32/ + @cp bin/linux/${PROJECT}-server ${QINIU_DIST_DIR}linux/ + @cp bin/darwin/${PROJECT}-server ${QINIU_DIST_DIR}darwin/ DEMO_BIN=/home/lighthouse/rd/server/deeptest diff --git a/cmd/server/v1/router/aichat.go b/cmd/server/v1/router/aichat.go index e614db422..db7a5208c 100644 --- a/cmd/server/v1/router/aichat.go +++ b/cmd/server/v1/router/aichat.go @@ -13,10 +13,10 @@ type AiChatModule struct { // Party chatchat func (m *AiChatModule) Party() module.WebModule { handler := func(index iris.Party) { + index.Post("/knowledge_base_chat", m.AiChatCtrl.KnowledgeBaseChat).Name = "与知识库对话" + index.Post("/list_valid_models", m.AiChatCtrl.ListValidModel).Name = "列出大模型" index.Get("/list_knowledge_bases", m.AiChatCtrl.ListKnowledgeBase).Name = "列出知识库" - - index.Post("/knowledge_base_chat", m.AiChatCtrl.KnowledgeBaseChat).Name = "与知识库对话" } return module.NewModule("/aichat", handler) } From 97edf7b2d8662187f1a3f8a746fa6ef5c3cef6c9 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Sat, 13 Jul 2024 10:03:33 +0800 Subject: [PATCH 31/36] OpenAI --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1676b29ea..a02d54324 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ client/icon/ly client/src/app/package-ly.json +client/node_modules client-ly/node_modules client-ly/out client-ly/.webpack From 9725772e3d1e550328e8f87247aecf52de3e229b Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 17 Jul 2024 09:20:20 +0800 Subject: [PATCH 32/36] OpenAI --- Makefile | 123 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index 8d49d83f8..dd6b78d2b 100644 --- a/Makefile +++ b/Makefile @@ -48,27 +48,26 @@ GIT_HASH=`git show -s --format=%H` BUILD_CMD_UNIX=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" -default: compile_ui_web win64 win32 linux mac -server: compile_server_win64 compile_server_win32 compile_server_linux compile_server_mac copy_server - -# 非客户端版本打包,更新客户端需先运行 make compile_ui_client -win64: prepare compile_agent_win64 compile_server_win64 zip_web_win64 -win32: prepare compile_agent_win32 compile_server_win32 zip_web_win32 -linux: prepare compile_agent_linux compile_server_linux zip_web_linux -mac: prepare compile_agent_mac compile_server_mac zip_web_mac - -# 客户端版本打包 -dp-win64: prepare build_gui_win64 compile_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade -dp-win32: prepare build_gui_win32 compile_launcher_win32 compile_server_win32 copy_files_win32 zip_win32 zip_win32_upgrade -dp-linux: prepare build_gui_linux compile_server_linux copy_files_linux zip_linux zip_linux_upgrade -dp-mac: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade -dp-mac-test: compile_ui_client_test build_gui_mac +default: compile_ui_web win64-web win32-web linux-web mac-web + +# 非客户端版本打包,需先运行 make compile_ui_web +win64-web: prepare compile_agent_win64 compile_server_win64 zip_win64_web +win32-web: prepare compile_agent_win32 compile_server_win32 zip_win32_web +linux-web: prepare compile_agent_linux compile_server_linux zip_linux_web +mac-web: prepare compile_agent_mac compile_server_mac zip_mac_web + +# 客户端版本打包,需先运行 make compile_ui_ +dp-win64-client: prepare build_gui_win64 compile_launcher_win64 compile_server_win64 copy_files_win64 zip_win64_client zip_win64_upgrade +dp-win32-client: prepare build_gui_win32 compile_launcher_win32 compile_server_win32 copy_files_win32 zip_win32_client zip_win32_upgrade +dp-linux-client: prepare build_gui_linux compile_server_linux copy_files_linux zip_linux_client zip_linux_upgrade +dp-mac-client: prepare build_gui_mac compile_server_mac copy_files_mac zip_mac_client zip_mac_upgrade +dp-mac-test-client: compile_ui_client_test build_gui_mac # 乐研 打包 -ly-win64: prepare compile_ly_ui_client build_gui_win64 compile_ly_launcher_win64 compile_server_win64 copy_files_win64 zip_win64 zip_win64_upgrade -ly-win32: prepare compile_ly_ui_client build_gui_win32 compile_ly_launcher_win32 compile_server_win32 copy_files_win32 zip_win32 zip_win32_upgrade -ly-linux: prepare compile_ly_ui_client build_gui_linux compile_server_linux copy_files_linux zip_linux zip_linux_upgrade -ly-mac: prepare compile_ly_ui_client build_gui_mac compile_server_mac copy_files_mac zip_mac zip_mac_upgrade +ly-win64-client: prepare compile_ly_ui_client build_gui_win64 compile_ly_launcher_win64 compile_server_win64 copy_files_win64 zip_win64_client zip_win64_upgrade +ly-win32-client: prepare compile_ly_ui_client build_gui_win32 compile_ly_launcher_win32 compile_server_win32 copy_files_win32 zip_win32_client zip_win32_upgrade +ly-linux-client: prepare compile_ly_ui_client build_gui_linux compile_server_linux copy_files_linux zip_linux_client zip_linux_upgrade +ly-mac-client: prepare compile_ly_ui_client build_gui_mac compile_server_mac copy_files_mac zip_mac_client zip_mac_upgrade prepare: init_client_project update_version @@ -85,21 +84,21 @@ gen_version_file: compile_ui: @cd ui && yarn build --dest ../client/ui && cd .. -compile_ui_web: - @cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/client/ui && cd ../leyanapi-backend -compile_ui_demo: +compile_ui_demo: # DeepTest测试 @cd ../deeptest-ui && yarn build:demo --dest ../deeptest/client/ui && cd ../deeptest -compile_ui_nancal: +compile_ui_nancal: # 内网测试 @cd ../deeptest-ui && yarn build:nancal --dest ../deeptest/client/ui && cd ../deeptest - compile_ui_client: @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:client --dest ../leyanapi-backend/client/ui && cd .. compile_ui_client_test: @rm -rf client/ui && cd ../leyanapi-frontend && yarn build:clientTest --dest ../leyanapi-backend/client/ui && cd .. - compile_ly_ui_client: @cd ../leyanapi-frontend && yarn build:client && cd ../leyanapi-backend + +compile_ui_web: + @cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/bin/deeptest-ui && cd ../leyanapi-backend + # launcher compile_launcher_win64: @echo 'start compile win64 launcher' @@ -249,15 +248,15 @@ copy_files_mac: @echo 'start copy files darwin' # zip web files -zip_web_win64: +zip_win64_web: @echo 'start zip win64' @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip @cp -rf config ${BIN_DIR}win64/ @cp -rf ${CLIENT_BIN_DIR}win32/deeptest-agent.exe ${BIN_DIR}win64/ - @rm -rf ${BIN_DIR}win64/deeptest-ui && mkdir ${BIN_DIR}win64/deeptest-ui - @cp -rf client/ui/* ${BIN_DIR}win64/deeptest-ui + @rm -rf ${BIN_DIR}win64/deeptest-ui + @cp -rf bin/deeptest-ui ${BIN_DIR}win64 @cd ${BIN_DIR}win64/ && \ zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip ./* && \ @@ -265,15 +264,15 @@ zip_web_win64: xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-web.zip.md5 && \ cd ../..; \ -zip_web_win32: +zip_win32_web: @echo 'start zip win32' @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip @cp -rf config ${BIN_DIR}win32/ @cp -rf ${CLIENT_BIN_DIR}win32/deeptest-agent.exe ${BIN_DIR}win32/ - @rm -rf ${BIN_DIR}win32/deeptest-ui && mkdir ${BIN_DIR}win32/deeptest-ui - @cp -rf client/ui/* ${BIN_DIR}win32/deeptest-ui + @rm -rf ${BIN_DIR}win32/deeptest-ui + @cp -rf bin/deeptest-ui ${BIN_DIR}win32 @cd ${BIN_DIR}win32/ && \ zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip ./* && \ @@ -281,15 +280,15 @@ zip_web_win32: xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}-web.zip.md5 && \ cd ../..; \ -zip_web_linux: +zip_linux_web: @echo 'start zip linux' @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip @cp -rf config ${BIN_DIR}linux/ @cp -rf ${CLIENT_BIN_DIR}linux/deeptest-agent ${BIN_DIR}linux/ - @rm -rf ${BIN_DIR}linux/deeptest-ui && mkdir ${BIN_DIR}linux/deeptest-ui - @cp -rf client/ui/* ${BIN_DIR}linux/deeptest-ui + @rm -rf ${BIN_DIR}linux/deeptest-ui + @cp -rf bin/deeptest-ui ${BIN_DIR}linux @cd ${BIN_DIR}linux/ && \ zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip ./* && \ @@ -297,15 +296,15 @@ zip_web_linux: xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-web.zip.md5 && \ cd ../..; \ -zip_web_mac: +zip_mac_web: @echo 'start zip darwin' @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip @cp -rf config ${BIN_DIR}darwin/ @cp -rf ${CLIENT_BIN_DIR}darwin/deeptest-agent ${BIN_DIR}darwin/ - @rm -rf ${BIN_DIR}darwin/deeptest-ui && mkdir ${BIN_DIR}darwin/deeptest-ui - @cp -rf client/ui/* ${BIN_DIR}darwin/deeptest-ui + @rm -rf ${BIN_DIR}darwin/deeptest-ui + @cp -rf bin/deeptest-ui ${BIN_DIR}darwin @cd ${BIN_DIR}darwin/ && \ zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip ./* && \ @@ -314,44 +313,44 @@ zip_web_mac: cd ../..; \ # zip client files -zip_win64: +zip_win64_client: @echo 'start zip win64' @find . -name .DS_Store -print0 | xargs -0 rm -f - @mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}.zip + @mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}win64 && \ - zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}.zip ./* && \ - md5sum ${QINIU_DIST_DIR}win64/${PROJECT}.zip | awk '{print $$1}' | \ - xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}.zip.md5 && \ + zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip ./* && \ + md5sum ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip | awk '{print $$1}' | \ + xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip.md5 && \ cd ../../..; \ -zip_win32: +zip_win32_client: @echo 'start zip win32' @find . -name .DS_Store -print0 | xargs -0 rm -f - @mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}.zip + @mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}win32 && \ - zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}.zip ./* && \ - md5sum ${QINIU_DIST_DIR}win32/${PROJECT}.zip | awk '{print $$1}' | \ - xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}.zip.md5 && \ + zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip ./* && \ + md5sum ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip | awk '{print $$1}' | \ + xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip.md5 && \ cd ../../..; \ -zip_linux: +zip_linux_client: @echo 'start zip linux' @find . -name .DS_Store -print0 | xargs -0 rm -f - @mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}.zip + @mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}linux && \ - zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}.zip ./* && \ - md5sum ${QINIU_DIST_DIR}linux/${PROJECT}.zip | awk '{print $$1}' | \ - xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}.zip.md5 && \ + zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip ./* && \ + md5sum ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip | awk '{print $$1}' | \ + xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip.md5 && \ cd ../../..; \ -zip_mac: +zip_mac_client: @echo 'start zip darwin' @find . -name .DS_Store -print0 | xargs -0 rm -f - @mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}.zip + @mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}darwin && \ - zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}.zip ./* && \ - md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}.zip | awk '{print $$1}' | \ - xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}.zip.md5 && \ + zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip ./* && \ + md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip | awk '{print $$1}' | \ + xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip.md5 && \ cd ../../..; \ # zip upgrade package @@ -393,11 +392,17 @@ upload_to: @qshell qupload2 --src-dir=${QINIU_DIR} --bucket=download --thread-count=10 --log-file=qshell.log \ --skip-path-prefixes=ztf,zd,zv,zmanager,driver --rescan-local --overwrite --check-hash -copy_server: +zip_server: @cp bin/win64/${PROJECT}-server.exe ${QINIU_DIST_DIR}win64/ + @cp bin/win32/${PROJECT}-server.exe ${QINIU_DIST_DIR}win32/ @cp bin/linux/${PROJECT}-server ${QINIU_DIST_DIR}linux/ - @cp bin/darwin/${PROJECT}-server ${QINIU_DIST_DIR}darwin/ + + # zip -r /Users/aaron/work/qiniu/deeptest/3.0/darwin/deeptest-server.zip config bin/deeptest-ui bin/darwin/deeptest-server + @zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-server.zip \ + bin/darwin/${PROJECT}-server config client/ui && \ + md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-upgrade.zip | awk '{print $$1}' | \ + xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-upgrade.zip.md5 && \ DEMO_BIN=/home/lighthouse/rd/server/deeptest From b55e46cc6a817b17d38dc8dda03fe642fed1f697 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 17 Jul 2024 09:33:28 +0800 Subject: [PATCH 33/36] OpenAI --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index dd6b78d2b..cb3862192 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ GIT_HASH=`git show -s --format=%H` BUILD_CMD_UNIX=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" -default: compile_ui_web win64-web win32-web linux-web mac-web +web: compile_ui_web win64-web win32-web linux-web mac-web # 非客户端版本打包,需先运行 make compile_ui_web win64-web: prepare compile_agent_win64 compile_server_win64 zip_win64_web @@ -307,7 +307,7 @@ zip_mac_web: @cp -rf bin/deeptest-ui ${BIN_DIR}darwin @cd ${BIN_DIR}darwin/ && \ - zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip ./* && \ + zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip ./* -x Leyan* && \ md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip | awk '{print $$1}' | \ xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-web.zip.md5 && \ cd ../..; \ @@ -318,7 +318,7 @@ zip_win64_client: @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}win64 && \ - zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip ./* && \ + zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip ./* -x Leyan* && \ md5sum ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip | awk '{print $$1}' | \ xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-client.zip.md5 && \ cd ../../..; \ @@ -328,7 +328,7 @@ zip_win32_client: @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}win32 && rm -rf ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}win32 && \ - zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip ./* && \ + zip -ry ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip ./* -x Leyan* && \ md5sum ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip | awk '{print $$1}' | \ xargs echo > ${QINIU_DIST_DIR}win32/${PROJECT}-client.zip.md5 && \ cd ../../..; \ @@ -338,7 +338,7 @@ zip_linux_client: @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}linux && \ - zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip ./* && \ + zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip ./* -x Leyan* && \ md5sum ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip | awk '{print $$1}' | \ xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-client.zip.md5 && \ cd ../../..; \ @@ -348,7 +348,7 @@ zip_mac_client: @find . -name .DS_Store -print0 | xargs -0 rm -f @mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip @cd ${CLIENT_OUT_DIR_EXECUTABLE}darwin && \ - zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip ./* && \ + zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip ./* -x Leyan* && \ md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip | awk '{print $$1}' | \ xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-client.zip.md5 && \ cd ../../..; \ From fe1763a6e6b227df4da1ff558ece0d0e83027f8e Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 17 Jul 2024 10:27:03 +0800 Subject: [PATCH 34/36] OpenAI --- internal/pkg/config/init.go | 4 ++-- pkg/lib/mail/mail.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/pkg/config/init.go b/internal/pkg/config/init.go index 3c682da16..b05772913 100644 --- a/internal/pkg/config/init.go +++ b/internal/pkg/config/init.go @@ -78,7 +78,7 @@ func Init() { // server config serverConfigPath := filepath.Join(consts.WorkDir, consts.ServerConfigFileName) if !dir.IsExist(serverConfigPath) { // create config if not exist - configRes := filepath.Join("res", consts.ServerConfigFileName) + configRes := path.Join("res", consts.ServerConfigFileName) yamlDefault, _ := deeptest.ReadResData(configRes) if err := VIPER.ReadConfig(bytes.NewBuffer(yamlDefault)); err != nil { @@ -114,7 +114,7 @@ func Init() { // create casbin rbac_model.conf if needed casbinPath := filepath.Join(consts.WorkDir, consts.CasbinFileName) if !dir.IsExist(casbinPath) { - casbinRes := filepath.Join("res", consts.CasbinFileName) + casbinRes := path.Join("res", consts.CasbinFileName) yamlDefault, err := deeptest.ReadResData(casbinRes) if err != nil { panic(fmt.Errorf("failed to read casbin rbac_model.conf from res: %s", err.Error())) diff --git a/pkg/lib/mail/mail.go b/pkg/lib/mail/mail.go index 66da7fc01..9f86cb0d8 100644 --- a/pkg/lib/mail/mail.go +++ b/pkg/lib/mail/mail.go @@ -15,7 +15,7 @@ import ( "io" "os" "os/exec" - "path/filepath" + "path" "regexp" "strings" ) @@ -37,7 +37,7 @@ func Send(to, subject, tmpl string, mp map[string]string) (err error) { m.SetAddressHeader("To", to, mp["name"]) m.SetHeader("Subject", subject) - tmplFile := filepath.Join("res", "tmpl", tmpl+".ftl") + tmplFile := path.Join("res", "tmpl", tmpl+".ftl") content, _ := deeptest.ReadResData(tmplFile) body := os.Expand(string(content), func(k string) string { return mp[k] }) From 887e99ade442a056c19603bc2c85d66f1c5603c1 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 17 Jul 2024 10:39:06 +0800 Subject: [PATCH 35/36] OpenAI --- internal/pkg/config/init.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/pkg/config/init.go b/internal/pkg/config/init.go index b05772913..b1bc72b59 100644 --- a/internal/pkg/config/init.go +++ b/internal/pkg/config/init.go @@ -13,6 +13,7 @@ import ( "github.com/go-redis/redis/v8" "github.com/snowlyg/helper/dir" "github.com/spf13/viper" + "log" "os" "path" "path/filepath" @@ -117,7 +118,9 @@ func Init() { casbinRes := path.Join("res", consts.CasbinFileName) yamlDefault, err := deeptest.ReadResData(casbinRes) if err != nil { - panic(fmt.Errorf("failed to read casbin rbac_model.conf from res: %s", err.Error())) + panic(fmt.Errorf("failed to read casbin rbac_model.conf from res: %s\n", err.Error())) + } else { + log.Printf("success to read casbin rbac_model.conf from res path %s\n", casbinRes) } err = _fileUtils.WriteFile(casbinPath, string(yamlDefault)) From c7728ec4fa91e1ae7dbdc01ad5d8704e5ea8e171 Mon Sep 17 00:00:00 2001 From: chenqi99 Date: Wed, 17 Jul 2024 12:28:27 +0800 Subject: [PATCH 36/36] OpenAI --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index cb3862192..938e09a51 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,6 @@ compile_ui_client_test: compile_ly_ui_client: @cd ../leyanapi-frontend && yarn build:client && cd ../leyanapi-backend - compile_ui_web: @cd ../leyanapi-frontend && yarn build:web --dest ../leyanapi-backend/bin/deeptest-ui && cd ../leyanapi-backend