Skip to content

Commit 2875f8f

Browse files
committed
feat!: refactor service provider configuration
BREAKING CHANGES: - Remove `deploymentName` and `apiVersion` options - Add `serviceProvider` option to support different service providers - Change API URL format requirements for different providers - Improve configuration validation for each provider Documentation: - Update configuration manuals with new options and examples - Add links to service provider documentation - Improve formatting and readability
1 parent 6279e6c commit 2875f8f

File tree

7 files changed

+329
-189
lines changed

7 files changed

+329
-189
lines changed

README.md

+27-14
Original file line numberDiff line numberDiff line change
@@ -24,47 +24,60 @@
2424
>
2525
> 重要更新:非 macOS 用户可以使用我开发的基于 OpenAI API 的划词翻译浏览器插件 [openai-translator](https://github.com/yetone/openai-translator) 以解燃眉之急。
2626
27-
## 演示
28-
29-
![](https://user-images.githubusercontent.com/1206493/221086195-f1ed941d-4dfa-4aa0-9d47-56c258a8f854.gif)
30-
3127
## 简介
3228

3329
ChatGPT 向我们展示了 GPT 模型的伟大之处,所以我使用 OpenAI 的 API 实现了这个 Bob 的翻译 + 润色 + 语法修改插件,效果拔群!
3430

35-
### 润色功能
31+
<details>
3632

37-
此插件已支持使用 OpenAI API 对句子进行润色和语法修改,只需要把目标语言设置为与源语言一样即可,全面替代 Grammarly!而且理论上任何语言都可以润色,不仅仅是英语。
33+
<summary>演示 👀</summary>
3834

39-
如果你不喜欢将翻译功能和文本润色功能放在一起,这里单独拆分出了一个专门用来文本润色和语法纠错的插件: [bob-plugin-openai-polisher](https://github.com/yetone/bob-plugin-openai-polisher),这个润色插件具有更高级的润色功能,比如解释修改原因等。
35+
![演示](https://user-images.githubusercontent.com/1206493/221086195-f1ed941d-4dfa-4aa0-9d47-56c258a8f854.gif)
4036

41-
### 语言模型
37+
</details>
4238

43-
要使用 ChatGPT 的 API 需要在 Bob 的设置页面把此插件的模型改为 `gpt-3.5-turbo-0301` 或者 `gpt-3.5-turbo`:
4439

45-
![how to use OpenAI API](https://user-images.githubusercontent.com/1206493/222339607-d8f05042-4b65-495c-af58-849891de7434.png)
40+
### 润色功能
41+
42+
此插件已支持使用 OpenAI API 对句子进行润色和语法修改,只需要把目标语言设置为与源语言一样即可,全面替代 Grammarly!而且理论上任何语言都可以润色,不仅仅是英语。
43+
44+
如果你不喜欢将翻译功能和文本润色功能放在一起,这里单独拆分出了一个专门用来文本润色和语法纠错的插件: [bob-plugin-openai-polisher](https://github.com/openai-translator/bob-plugin-openai-polisher),这个润色插件具有更高级的润色功能,比如解释修改原因等。
4645

4746
## 使用方法
4847

4948
1. 安装 [Bob](https://bobtranslate.com/guide/#%E5%AE%89%E8%A3%85) (版本 >= 0.50),一款 macOS 平台的翻译和 OCR 软件
5049

5150
2. 下载此插件: [openai-translator.bobplugin](https://github.com/openai-translator/bob-plugin-openai-translator/releases/latest)
5251

53-
3. 安装此插件:
52+
3. <details>
53+
54+
<summary>安装此插件 👀</summary>
5455

5556
![安装步骤](https://user-images.githubusercontent.com/1206493/219937302-6be8d362-1520-4906-b8d6-284d01012837.gif)
5657

58+
</details>
59+
5760
4.[OpenAI](https://platform.openai.com/account/api-keys) 获取你的 API KEY
5861

5962
5. 把 API KEY 填入 Bob 偏好设置 > 服务 > 此插件配置界面的 API KEY 的输入框中
6063
- 如果你想了解关于其他设置的更多信息,请查看[配置手册](./docs/configuration_manual_CN.md)
6164

62-
![设置步骤](https://user-images.githubusercontent.com/1206493/219937398-8e5bb8d2-7dc8-404a-96e7-a937e08c939f.gif)
65+
<details>
66+
67+
<summary>演示 👀</summary>
68+
69+
![设置步骤](https://user-images.githubusercontent.com/1206493/219937398-8e5bb8d2-7dc8-404a-96e7-a937e08c939f.gif)
70+
71+
</details>
72+
73+
74+
6. <details>
6375

64-
6. 安装 [PopClip](https://bobtranslate.com/guide/integration/popclip.html) 实现划词后鼠标附近出现悬浮图标
76+
<summary>安装 PopClip 实现划词后鼠标附近出现悬浮图标 👀</summary>
6577

66-
![PopClip](https://user-images.githubusercontent.com/1206493/219933584-d0c2b6cf-8fa0-40a6-858f-8f4bf05f38ef.gif)
78+
[![PopClip](https://user-images.githubusercontent.com/1206493/219933584-d0c2b6cf-8fa0-40a6-858f-8f4bf05f38ef.gif)](https://bobtranslate.com/guide/integration/popclip.html)
6779

80+
</details>
6881

6982
## 贡献
7083

docs/README_EN.md

+25-15
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,59 @@
2424
>
2525
> Important update: Non-macOS users can use my browser extension based on OpenAI API for word translation [openai-translator](https://github.com/yetone/openai-translator) to solve urgent needs.
2626
27+
## Introduction
2728

28-
## Demonstration
29+
ChatGPT showcases the greatness of GPT models, so I have implemented the Bob translation + polishing + grammar modification plugin using OpenAI's API, with outstanding results!
2930

30-
![demo](https://user-images.githubusercontent.com/1206493/221086195-f1ed941d-4dfa-4aa0-9d47-56c258a8f854.gif)
31+
<details>
3132

32-
"""
33-
## Introduction
33+
<summary>Demonstration 👀</summary>
3434

35-
ChatGPT showcases the greatness of GPT models, so I have implemented the Bob translation + polishing + grammar modification plugin using OpenAI's API, with outstanding results!
35+
![demo](https://user-images.githubusercontent.com/1206493/219937398-8e5bb8d2-7dc8-404a-96e7-a937e08c939f.gif)
36+
37+
</details>
3638

3739
### Polishing Feature
3840

3941
This plugin supports polishing sentences and modifying grammar using the OpenAI API. To do so, just set the target language to be the same as the source language. It's a comprehensive alternative to Grammarly! And in theory, any language can be polished, not just English.
4042

4143
If you don't like combining translation functionality and text polishing, a separate plugin specifically for text polishing and grammar correction is available: [bob-plugin-openai-polisher](https://github.com/yetone/bob-plugin-openai-polisher). This polishing plugin has more advanced polishing features, such as explaining the modification reasons, etc.
4244

43-
### Language Model
44-
45-
To use the OpenAI API, go to Bob's settings page and change the plugin model to `gpt-3.5-turbo-0301` or `gpt-3.5-turbo`:
46-
47-
![how to use OpenAI API](https://user-images.githubusercontent.com/1206493/222339607-d8f05042-4b65-495c-af58-849891de7434.png)
48-
4945
## Usage
5046

5147
1. Install [Bob](https://bobtranslate.com/guide/#%E5%AE%89%E8%A3%85) (version >= 0.50), a macOS translation and OCR software
5248

5349
2. Download this plugin: [openai-translator.bobplugin](https://github.com/openai-translator/bob-plugin-openai-translator/releases/latest)
5450

55-
3. Install this plugin:
51+
3. <details>
5652

57-
![Installation Steps](https://user-images.githubusercontent.com/1206493/219937302-6be8d362-1520-4906-b8d6-284d01012837.gif)
53+
<summary>Install this plugin 👀</summary>
54+
55+
![Installation Steps](https://user-images.githubusercontent.com/1206493/219937302-6be8d362-1520-4906-b8d6-284d01012837.gif)
56+
57+
</details>
5858

5959
4. Get your API KEY from [OpenAI](https://platform.openai.com/account/api-keys)
6060

6161
5. Enter the API KEY in Bob Preferences > Services > This plugin configuration interface's API KEY input box:
6262
- If you would like to learn more about other settings, please refer to the [Configuration Manual](./docs/configuration_manual_EN.md)
6363

64+
<details>
65+
66+
<summary>Settings Steps 👀</summary>
67+
6468
![Settings Steps](https://user-images.githubusercontent.com/1206493/219937398-8e5bb8d2-7dc8-404a-96e7-a937e08c939f.gif)
6569

70+
</details>
71+
72+
6. <details>
73+
74+
<summary>Install PopClip for highlighted text mouse proximity floating icon 👀</summary>
75+
76+
[![PopClip](https://user-images.githubusercontent.com/1206493/219933584-d0c2b6cf-8fa0-40a6-858f-8f4bf05f38ef.gif)](https://bobtranslate.com/guide/integration/popclip.html)
6677

67-
6. Install [PopClip](https://bobtranslate.com/guide/integration/popclip.html) for highlighted text mouse proximity floating icon:
78+
</details>
6879

69-
![PopClip](https://user-images.githubusercontent.com/1206493/219933584-d0c2b6cf-8fa0-40a6-858f-8f4bf05f38ef.gif)
7080

7181
## Contributing
7282

docs/configuration_manual_CN.md

+69-27
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,122 @@
11
## 配置手册
22

3-
### 服务名称
3+
### 服务提供商
44

5-
- 可选项
6-
- 默认值: OpenAl Translator
5+
- 必选项
76

8-
### API URL
7+
- 默认值: OpenAI
98

10-
- 可选项
11-
- 默认值: `https://api.openai.com`
129
- 说明
13-
- 自定义 API URL 可以解决服务不稳定以及 IP 被封禁的问题,切换到反向代理服务来提高稳定性,并保护我们的 IP 地址不被 OpenAI 封禁
14-
- 或者是使用一些云服务商提供的 API 网关服务,比如 Cloudflare AI Gateway,除了可以代理 OpenAI 的 API 请求外,还额外增加了缓存、调用分析以及日志管理等功能
15-
- 将 API URL 设置为 `https://gateway.ai.cloudflare.com/v1/${ACCOUNT_TAG}/${GATEWAY}/openai` 即可体验
16-
- 更多信息请参阅 [Cloudflare AI Gateway 官方文档](https://developers.cloudflare.com/ai-gateway/)
1710

18-
### Dep. Name
11+
- OpenAI: 使用 OpenAI 官方服务
1912

20-
- 可选项
21-
- 默认值: 无
22-
- 说明
23-
- 当使用 Azure OpenAI Service 服务时,需要填写此项,具体步骤可参阅 [Azure OpenAI 翻译设置](https://bobtranslate.com/service/translate/azureopenai.html)
24-
- [🔗 Azure OpenAI Service 官方文档](https://learn.microsoft.com/zh-cn/azure/cognitive-services/openai/chatgpt-quickstart?tabs=command-line&pivots=rest-api)
13+
- Azure OpenAI: 使用 [Azure OpenAI Service](https://learn.microsoft.com/zh-cn/azure/ai-services/Translator/quickstart-text-rest-api)
2514

26-
### API Version
15+
- Custom: 使用自定义服务,如 [Cloudflare AI Gateway](https://developers.cloudflare.com/ai-gateway/) 或者 [Ollama](https://ollama.com/blog/openai-compatibility) 等服务商
16+
17+
18+
### API URL
19+
20+
- 可选项(OpenAI)/ 必填项(Azure OpenAI 和 Custom)
2721

28-
- 可选项
2922
- 默认值: 无
23+
3024
- 说明
31-
- 当使用 Azure OpenAI Service 服务时,需要填写此项,具体步骤可参阅 [Azure OpenAI 翻译设置](https://bobtranslate.com/service/translate/azureopenai.html)
32-
- [🔗 Azure OpenAI Service 官方文档](https://learn.microsoft.com/zh-cn/azure/cognitive-services/openai/chatgpt-quickstart?tabs=command-line&pivots=rest-api)
25+
26+
- OpenAI: 可选,默认为: `https://api.openai.com`
27+
28+
- Azure OpenAI: 必填,完整的 API URL,格式为:
29+
30+
```
31+
https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/chat/completions?api-version=API_VERSION
32+
```
33+
34+
- Custom: 必填,值为完整的 API URL,例如使用 Cloudflare AI Gateway 时,需填入:
35+
36+
```
37+
https://gateway.ai.cloudflare.com/v1/${CLOUDFLARE_ACCOUNT_ID}/${GATEWAY_ID}/openai/chat/completions
38+
```
3339
3440
### API KEY
3541
3642
- 必填项
43+
3744
- 默认值: 无
45+
3846
- 说明
47+
3948
- 可使用英文逗号分割多个账号下不同的 API KEY 以实现额度加倍及负载均衡
4049
4150
### 模型
4251
4352
- 必选项
44-
- 默认值: `gpt-3.5-turbo-1106`
53+
54+
- 默认值: `gpt-3.5-turbo`
55+
4556
- 说明
57+
4658
- 选择 `custom` 时,需要设置 `自定义模型` 配置项
4759
4860
### 自定义模型
4961
5062
- 可选项
63+
5164
- 默认值: `gpt-3.5-turbo`
65+
5266
- 说明
67+
5368
- 联动项,当 `模型` 配置选择 `custom` 时,会读取此配置项设置的模型
5469
5570
### 系统指令
5671
5772
- 可选项
73+
5874
- 默认值: `You are a translation engine that can only translate text and cannot interpret it.`
75+
5976
- 说明
77+
6078
- 自定义 System Prompt,填写则会覆盖默认的 System Prompt
79+
6180
- 自定义 Prompt可使用以下变量:
62-
1. `$text`:需要翻译的文本,即翻译窗口输入框内的文本
63-
2. `$sourceLang`:-原文语言, 即翻译窗口输入框内文本的语言,比如「简体中文」
64-
3. `$targetLang`:目标语言,即需要翻译成的语言,可以在翻译窗口中手动选择或自动检测,比如「English」
81+
82+
1. `$text`:需要翻译的文本,即翻译窗口输入框内的文本
83+
84+
2. `$sourceLang`:原文语言,即翻译窗口输入框内文本的语言,比如「简体中文」
85+
86+
3. `$targetLang`:目标语言,即需要翻译成的语言,可以在翻译窗口中手动选择或自动检测,比如「English」
6587
6688
### 用户指令
6789
6890
- 可选项
69-
- 默认值: `translate from $sourceLang to $targetLang:/n/n $text`
91+
92+
- 默认值: `translate from $sourceLang to $targetLang:\n\n$text`
93+
7094
- 说明
95+
7196
- 自定义 User Prompt,填写则会覆盖默认的 User Prompt
97+
7298
- 可以使用与系统指令中相同的变量
7399
100+
### 流式输出
101+
102+
- 可选项
103+
104+
- 默认值: `Enable`
105+
106+
- 说明
107+
108+
- 启用后翻译结果会实时显示
109+
110+
- 禁用后会等待翻译完成后一次性显示
111+
74112
### 温度
75113
76114
- 可选项
115+
77116
- 默认值: `0.2`
117+
78118
- 说明
79-
- 温度值越高,生成的文本越随机,更有创意。
80-
- 翻译任务建议设置在 `0.2` 左右,润色任务可以适当调高,如果需要严谨性,可以设置为 `0`
119+
120+
- 温度值越高,生成的文本越随机,更有创意
121+
122+
- 翻译任务建议设置在 `0.2` 左右,润色任务可以适当调高,如果需要严谨性,可以设置为 `0`

0 commit comments

Comments
 (0)