Skip to content

Commit

Permalink
✨feature(gpt): support got-4o-mini
Browse files Browse the repository at this point in the history
  • Loading branch information
vacuityv committed Jul 19, 2024
1 parent 9fc0243 commit 98ad5e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
8 changes: 4 additions & 4 deletions appcast.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"identifier": "me.vacuity.chat.gptranslate",
"versions": [
{
"version": "1.3.9",
"desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/1.3.9",
"sha256": "011f4224ec2a4845c2a1539b51e60009291f37c3b4124a4308f1e276e2124c7e",
"url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/1.3.9/bob-plugin-vac-gptranslate.bobplugin",
"version": "1.4.0",
"desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/1.4.0",
"sha256": "abb8a9bddd7b800a767ae72560dac072354c51b3d77305aaec9f3f01d52aecc2",
"url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/1.4.0/bob-plugin-vac-gptranslate.bobplugin",
"minBobVersion": "0.5.0"
}
]
Expand Down
12 changes: 6 additions & 6 deletions info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"identifier": "me.vacuity.chat.gptranslate",
"version": "1.3.9",
"version": "1.4.0",
"category": "translate",
"name": "GPTranslate",
"summary": "调用chatgpt/gemini/claude实现翻译功能",
Expand All @@ -24,15 +24,15 @@
"identifier": "modelType",
"type": "menu",
"title": "模型选择",
"defaultValue": "gpt3.5",
"defaultValue": "gpt-4o-mini",
"menuValues": [
{
"title": "gpt3.5",
"value": "gpt3.5"
"title": "gpt-4o-mini",
"value": "gpt-4o-mini"
},
{
"title": "gpt4.0",
"value": "gpt4.0"
"title": "gpt3.5",
"value": "gpt3.5"
},
{
"title": "gpt4o",
Expand Down
26 changes: 22 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var langMap = {
};
var usaHttp = "https://chat.vacuity.me/vac-chat-api/chat/ext/loginTranslate";
var usaWss = "wss://chat.vacuity.me/vac-chat-api/stream/chat/chat";
// var usaHttp = "http://127.0.0.1:8081/vac-chat-api/chat/ext/loginTranslate";
// var usaWss = "ws://127.0.0.1:8081/vac-chat-api/stream/chat/chat";

var socket = '';
var readyState = false;
Expand All @@ -51,9 +53,11 @@ function translate(query, completion) {
var env = $env;
if (typeof env !== "undefined") {
appVersion = $env.appVersion;
if (appVersion >= '1.8.0') {
streamSupFlag = true;
if (compareVersions(appVersion, '1.8.0') >= 0) {
streamSupFlag = true
}
} else {
$log.info('get env error, process as old version');
}
} catch (error) {
$log.info('get env error, process as old version');
Expand All @@ -63,10 +67,9 @@ function translate(query, completion) {
$log.info('useStreamFlag');
$log.info(useStreamFlag);


if (streamSupFlag && useStreamFlag === 'y') {
// newTrans(query, completion);
$log.info("vac-body" + initReqBody(query));
$log.info("vac-body-stream" + initReqBody(query));
websocketTrans(query, completion);
} else {
oldTranslate(query, completion);
Expand Down Expand Up @@ -222,3 +225,18 @@ function initReqBody(query) {
};
}

function compareVersions(version1, version2) {
const v1Parts = version1.split('.').map(Number);
const v2Parts = version2.split('.').map(Number);

for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
const v1Part = v1Parts[i] || 0;
const v2Part = v2Parts[i] || 0;

if (v1Part > v2Part) return 1;
if (v1Part < v2Part) return -1;
}

return 0;
}

0 comments on commit 98ad5e6

Please sign in to comment.