diff --git a/appcast.json b/appcast.json index cdd109f..a3b4055 100644 --- a/appcast.json +++ b/appcast.json @@ -2,10 +2,10 @@ "identifier": "me.vacuity.chat.gptranslate", "versions": [ { - "version": "0.1.2", - "desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/0.1.2", - "sha256": "0ac0dc28eab03a3b008242d5cabe467b61fd8a8c85e40debe7196ce1b84b0dca", - "url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/0.1.2/bob-plugin-vac-gptranslate.bobplugin", + "version": "1.0.0", + "desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/1.0.0", + "sha256": "d259fbaeb1b25090b58e5cb0ff2476ad680d4850a21abb98c8e658d3385fa693", + "url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/1.0.0/bob-plugin-vac-gptranslate.bobplugin", "minBobVersion": "0.5.0" } ] diff --git a/info.json b/info.json index 6415053..5306835 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "identifier": "me.vacuity.chat.gptranslate", - "version": "0.1.2", + "version": "1.0.0", "category": "translate", "name": "GPTranslate", "summary": "调用chatgpt实现翻译功能", @@ -21,18 +21,22 @@ "title": "登录密码" }, { - "identifier": "serverArea", + "identifier": "modelType", "type": "menu", - "title": "服务器选择", - "defaultValue": "hk", + "title": "模型选择", + "defaultValue": "gpt3.5", "menuValues": [ { - "title": "香港", - "value": "hk" + "title": "gpt3.5", + "value": "gpt3.5" }, { - "title": "美国", - "value": "usa" + "title": "gpt4.0", + "value": "gpt4.0" + }, + { + "title": "gemini-pro", + "value": "gemini-pro" } ] }, @@ -40,7 +44,7 @@ "identifier": "useStreamFlag", "type": "menu", "title": "流式传输", - "defaultValue": "false", + "defaultValue": "y", "menuValues": [ { "title": "不使用", diff --git a/main.js b/main.js index 80448e9..b5a9e03 100644 --- a/main.js +++ b/main.js @@ -32,12 +32,7 @@ var langMap = { 'pl': '波兰语', 'ar': '阿拉伯语' }; - -var hkHttp = "https://chat2.vacuity.me/vac-chat-api/chat/ext/loginTranslate"; -var hkStream = "https://chat2.vacuity.me/vac-chat-api/chat/ext/loginStreamTranslate"; -var hkWss = "wss://chat2.vacuity.me/vac-chat-api/stream/chat/chat"; var usaHttp = "https://chat.vacuity.me/vac-chat-api/chat/ext/loginTranslate"; -var usaStream = "https://chat.vacuity.me/vac-chat-api/chat/ext/loginStreamTranslate"; var usaWss = "wss://chat.vacuity.me/vac-chat-api/stream/chat/chat"; var socket = ''; @@ -78,15 +73,9 @@ function translate(query, completion) { } function oldTranslate(query, completion) { - - var area = $option.serverArea; - vacUrl = hkHttp; - if (area === 'usa') { - vacUrl = usaHttp; - } $http.request({ method: "POST", - url: vacUrl, + url: usaHttp, header: { "Content-Type": "application/json;charset=UTF-8" }, @@ -115,39 +104,6 @@ function oldTranslate(query, completion) { } -function newTrans(query, completion) { - - var area = $option.serverArea; - vacUrl = hkStream; - if (area === 'usa') { - vacUrl = usaStream; - } - resTxt = ''; - $http.streamRequest({ - method: "POST", - url: vacUrl, - header: { - "Content-Type": "application/json;charset=UTF-8" - }, - body: initReqBody(query), - streamHandler: function (resp) { - var txt = resp.text; - resTxt = resTxt + txt; - translateResult = { - 'toParagraphs': [resTxt] - } - query.onStream({'result': translateResult}); - }, - handler: function (data, rawData, response, error) { - query.onCompletion({ - result: { - toParagraphs: [resTxt], - } - }); - } - }); -} - var websocket = null; @@ -157,11 +113,7 @@ var signal = $signal.new() function initWebsocket() { - var area = $option.serverArea; - vacUrl = hkWss; - if (area === 'usa') { - vacUrl = usaWss; - } + vacUrl = usaWss; if (websocket == null) { $log.info(`initWebsocket`) @@ -274,12 +226,14 @@ function websocketTrans(query, completion) { function initReqBody(query) { var account = $option.loginAccount; var password = $option.loginPassword; + var modelType = $option.modelType; var content = query['text']; return { email: account, password: password, content: content, + modelType: modelType, targetLanguage: langMap[query['to']], translateFrom: 'bob' };