Skip to content

Commit

Permalink
feat: add proxy API config and zh-Hant prompt (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
okisdev authored Mar 8, 2023
1 parent c2c371c commit 2b5b6fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -57,4 +64,4 @@
]
}
]
}
}
9 changes: 7 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
});
Expand Down

0 comments on commit 2b5b6fd

Please sign in to comment.