From 2b5b6fd511917ea624d6d3dc61ca095831e1fda7 Mon Sep 17 00:00:00 2001 From: Harry Yep Date: Wed, 8 Mar 2023 07:33:23 +0000 Subject: [PATCH] feat: add proxy API config and zh-Hant prompt (#7) --- src/info.json | 9 ++++++++- src/main.js | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/info.json b/src/info.json index 1d92e9e..75517bd 100644 --- a/src/info.json +++ b/src/info.json @@ -10,6 +10,13 @@ "appcast": "https://raw.githubusercontent.com/yetone/bob-plugin-openai-polisher/main/appcast.json", "minBobVersion": "0.5.0", "options": [ + { + "identifier": "api_url", + "type": "text", + "title": "API URL", + "defaultValue": "https://api.openai.com", + "desc": "如果您的网络环境需要代理才能访问 OpenAI API, 可在这里修改为反代 API 的地址 默认为 https://api.openai.com" + }, { "identifier": "api_keys", "type": "text", @@ -57,4 +64,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/src/main.js b/src/main.js index b7bcc02..86d928f 100644 --- a/src/main.js +++ b/src/main.js @@ -20,6 +20,11 @@ function translate(query, completion) { } switch (query.detectFrom) { case "zh-Hant": + prompt = "潤色此句"; + if (detailedPolishingMode) { + prompt = `${prompt}。請列出修改項目,並簡述修改原因`; + } + break; case "zh-Hans": prompt = "润色此句"; if (detailedPolishingMode) { @@ -73,8 +78,8 @@ function translate(query, completion) { const resp = await $http.request({ method: "POST", url: - "https://api.openai.com/v1" + - (isChatGPTModel ? "/chat/completions" : "/completions"), + $option.api_url + + (isChatGPTModel ? "/v1/chat/completions" : "/v1/completions"), header, body, });