@lobehub/chat 0.72.4 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.github/workflows/contributor-help.yml +1 -1
  2. package/.github/workflows/sync.yml +43 -0
  3. package/.github/workflows/wiki-sync.yml +1 -0
  4. package/CHANGELOG.md +51 -0
  5. package/README.md +14 -1
  6. package/{README-zh_CN.md → README.zh-CN.md} +13 -0
  7. package/docs/Home.md +6 -0
  8. package/docs/Upstream-Sync.en-US.md +16 -0
  9. package/docs/Upstream-Sync.zh-CN.md +16 -0
  10. package/docs/_Sidebar.md +6 -0
  11. package/locales/en_US/setting.json +60 -1
  12. package/locales/ru_RU/setting.json +60 -1
  13. package/next.config.mjs +6 -2
  14. package/package.json +5 -10
  15. package/src/config/server.ts +2 -0
  16. package/src/const/fetch.ts +15 -2
  17. package/src/const/llm.ts +17 -0
  18. package/src/const/settings.ts +16 -8
  19. package/src/locales/default/setting.ts +59 -13
  20. package/src/pages/api/{openai.ts → createChatCompletion.ts} +7 -36
  21. package/src/pages/api/openai/chat.api.ts +43 -0
  22. package/src/pages/api/openai/createAzureOpenai.ts +26 -0
  23. package/src/pages/api/openai/createOpenai.ts +17 -0
  24. package/src/pages/api/openai/models.api.ts +17 -0
  25. package/src/pages/settings/features/Settings/Common.tsx +2 -26
  26. package/src/pages/settings/features/Settings/LLM/Checker.tsx +85 -0
  27. package/src/pages/settings/features/Settings/LLM/ModelList.tsx +51 -0
  28. package/src/pages/settings/features/Settings/LLM/getModelList.ts +9 -0
  29. package/src/pages/settings/features/Settings/LLM/index.tsx +152 -0
  30. package/src/pages/settings/features/Settings/index.tsx +13 -12
  31. package/src/services/_header.ts +33 -0
  32. package/src/services/_url.ts +17 -0
  33. package/src/services/chatModel.ts +4 -10
  34. package/src/services/modelList.ts +15 -0
  35. package/src/services/plugin.ts +1 -1
  36. package/src/services/pluginMarket.ts +1 -1
  37. package/src/store/global/hooks/index.ts +1 -0
  38. package/src/store/global/hooks/useEffectAfterHydrated.ts +22 -0
  39. package/src/store/global/initialState.ts +4 -0
  40. package/src/store/global/selectors.test.ts +264 -0
  41. package/src/store/global/selectors.ts +4 -5
  42. package/src/store/global/slices/settings.ts +16 -4
  43. package/src/store/global/store.ts +34 -5
  44. package/src/types/settings.ts +45 -8
  45. package/src/utils/fetch.ts +4 -12
  46. package/src/pages/api/openai.api.ts +0 -24
  47. package/src/services/url.ts +0 -8
@@ -13,7 +13,7 @@ jobs:
13
13
  with:
14
14
  token: ${{ secrets.GH_TOKEN }}
15
15
  style: 'simple'
16
- update-files: 'README.md, README-zh_CN.md'
16
+ update-files: 'README.md, README.zh-CN.md'
17
17
  update-places: '<!-- CONTRIBUTION GROUP -->/<!-- CONTRIBUTION END -->, <!-- CONTRIBUTION GROUP -->/<!-- CONTRIBUTION END -->'
18
18
 
19
19
  - name: Commit and push if changed
@@ -0,0 +1,43 @@
1
+ name: Upstream Sync
2
+
3
+ permissions:
4
+ contents: write
5
+
6
+ on:
7
+ schedule:
8
+ - cron: "0 0 * * *" # every day
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ sync_latest_from_upstream:
13
+ name: Sync latest commits from upstream repo
14
+ runs-on: ubuntu-latest
15
+ if: ${{ github.event.repository.fork }}
16
+
17
+ steps:
18
+ # Step 1: run a standard checkout action
19
+ - name: Checkout target repo
20
+ uses: actions/checkout@v3
21
+
22
+ # Step 2: run the sync action
23
+ - name: Sync upstream changes
24
+ id: sync
25
+ uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
26
+ with:
27
+ upstream_sync_repo: lobehub/lobe-chat
28
+ upstream_sync_branch: main
29
+ target_sync_branch: main
30
+ target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
31
+
32
+ # Set test_mode true to run tests instead of the true action!!
33
+ test_mode: false
34
+
35
+ # Step 3: run check
36
+ - name: Sync check
37
+ if: failure()
38
+ uses: actions-cool/issues-helper@v3
39
+ with:
40
+ actions: 'create-issue'
41
+ token: ${{ secrets.GITHUB_TOKEN }}
42
+ title: '🚨 同步失败 | Sync Fail'
43
+ body: '由于 [LobeChat][lobechat] 上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,请查看[详细教程][tutorial-zh-CN]\n---\nDue to a change in the workflow file of the [LobeChat][lobechat] upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed [Tutorial][tutorial-en-US] for instructions.\n\n[lobechat]: https://github.com/lobehub/lobe-chat\n[tutorial-zh-CN]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN\n[tutorial-en-US]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN'
@@ -1,6 +1,7 @@
1
1
  name: Wiki Sync
2
2
 
3
3
  on:
4
+ workflow_dispatch:
4
5
  push:
5
6
  paths:
6
7
  - 'docs/**'
package/CHANGELOG.md CHANGED
@@ -2,6 +2,57 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.74.0](https://github.com/lobehub/lobe-chat/compare/v0.73.0...v0.74.0)
6
+
7
+ <sup>Released on **2023-09-11**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Add russian localy, Update Russian and English localy (LLM tab).
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: Add russian localy ([7b67c9f](https://github.com/lobehub/lobe-chat/commit/7b67c9f))
21
+ - **misc**: Update Russian and English localy (LLM tab) ([3b23e70](https://github.com/lobehub/lobe-chat/commit/3b23e70))
22
+
23
+ </details>
24
+
25
+ <div align="right">
26
+
27
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
28
+
29
+ </div>
30
+
31
+ ## [Version 0.73.0](https://github.com/lobehub/lobe-chat/compare/v0.72.4...v0.73.0)
32
+
33
+ <sup>Released on **2023-09-10**</sup>
34
+
35
+ #### ✨ Features
36
+
37
+ - **misc**: Support Azure OpenAI.
38
+
39
+ <br/>
40
+
41
+ <details>
42
+ <summary><kbd>Improvements and Fixes</kbd></summary>
43
+
44
+ #### What's improved
45
+
46
+ - **misc**: Support Azure OpenAI, closes [#177](https://github.com/lobehub/lobe-chat/issues/177) ([f0c9532](https://github.com/lobehub/lobe-chat/commit/f0c9532))
47
+
48
+ </details>
49
+
50
+ <div align="right">
51
+
52
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
53
+
54
+ </div>
55
+
5
56
  ### [Version 0.72.4](https://github.com/lobehub/lobe-chat/compare/v0.72.3...v0.72.4)
6
57
 
7
58
  <sup>Released on **2023-09-10**</sup>
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-performance chatbot framework. <br/> It supports one-click free deployment of your private ChatGPT/LLM web application.
12
12
 
13
- **English** · [简体中文](./README-zh_CN.md) · [Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
13
+ **English** · [简体中文](./README.zh-CN.md) · [Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
14
14
 
15
15
  <!-- SHIELD GROUP -->
16
16
 
@@ -35,12 +35,21 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
35
35
  #### TOC
36
36
 
37
37
  - [👋🏻 Getting Started & Join Our Community](#-getting-started--join-our-community)
38
+
38
39
  - [✨ Features](#-features)
40
+
39
41
  - [🛳 Self Hosting](#-self-hosting)
42
+
43
+ - [Keep Updated](#keep-updated)
44
+
40
45
  - [📦 Ecosystem](#-ecosystem)
46
+
41
47
  - [🧩 Plugins](#-plugins)
48
+
42
49
  - [⌨️ Local Development](#️-local-development)
50
+
43
51
  - [🤝 Contributing](#-contributing)
52
+
44
53
  - [🔗 More Products](#-more-products)
45
54
 
46
55
  ####
@@ -99,6 +108,10 @@ LobeChat provides a [self-hosted version][deploy-url] with Vercel. This allows y
99
108
  | `OPENAI_PROXY_URL` | No | If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL | `https://api.chatanywhere.cn`<br/>The default value is<br/>`https://api.openai.com` |
100
109
  | `ACCESS_CODE` | No | Add a password to access this service, the password should be a 6-digit number or letter | `awCT74` or `e3@09!` |
101
110
 
111
+ ### Keep Updated
112
+
113
+ If you have deployed your own project following the one-click deployment steps in the README, you might encounter constant prompts indicating "updates available". This is because Vercel defaults to creating a new project instead of forking this one, resulting in an inability to accurately detect updates. We suggest you redeploy using the following steps, [Maintaining Updates with LobeChat Self-Deployment](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.en-US).
114
+
102
115
  <div align="right">
103
116
 
104
117
  [![][back-to-top]](#readme-top)
@@ -35,12 +35,21 @@ LobeChat 是一个开源的、可扩展的([Function Calling][fc-url])高性
35
35
  #### TOC
36
36
 
37
37
  - [👋🏻 开始使用 & 交流](#-开始使用--交流)
38
+
38
39
  - [✨ 功能特性](#-功能特性)
40
+
39
41
  - [🛳 开箱即用](#-开箱即用)
42
+
43
+ - [保持更新](#保持更新)
44
+
40
45
  - [📦 生态系统](#-生态系统)
46
+
41
47
  - [🧩 插件体系](#-插件体系)
48
+
42
49
  - [⌨️ 本地开发](#️-本地开发)
50
+
43
51
  - [🤝 参与贡献](#-参与贡献)
52
+
44
53
  - [🔗 更多工具](#-更多工具)
45
54
 
46
55
  ####
@@ -99,6 +108,10 @@ LobeChat 提供了 Vercel 的 [自托管版本][deploy-url]。这使你可以在
99
108
  | `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn`<br/>默认值:<br/>`https://api.openai.com` |
100
109
  | `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
101
110
 
111
+ ### 保持更新
112
+
113
+ 如果你根据 README 中的一键部署步骤部署了自己的项目,你可能会发现总是被提示“有可用更新”。这是因为 Vercel 默认为你创建新项目而非 fork 本项目,这将导致无法准确检测更新。我们建议按照 [LobeChat 自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN) 步骤重新部署。
114
+
102
115
  <div align="right">
103
116
 
104
117
  [![][back-to-top]](#readme-top)
package/docs/Home.md CHANGED
@@ -14,6 +14,12 @@ LobeChat is a open-source, extensible (Function Calling), high-performance chatb
14
14
 
15
15
  <br/>
16
16
 
17
+ ### 🤯 LobeChat
18
+
19
+ - [Upstream Sync](Upstream-Sync.en-US)
20
+ - [English](Upstream-Sync.en-US)
21
+ - [简体中文](Upstream-Sync.zh-CN)
22
+
17
23
  ## 🤖 Agents
18
24
 
19
25
  - [Agent Index](https://github.com/lobehub/lobe-chat-agents)
@@ -0,0 +1,16 @@
1
+ # Maintaining Updates with LobeChat Self-Deployment
2
+
3
+ If you have deployed your own project following the one-click deployment steps in the README, you might encounter constant prompts indicating "updates available". This is because Vercel defaults to creating a new project instead of forking this one, resulting in an inability to accurately detect updates. We suggest you redeploy using the following steps:
4
+
5
+ - Remove the original repository;
6
+ - Use the <kbd>Fork</kbd> button at the top right corner of the page to fork this project;
7
+ - Re-select and deploy on `Vercel`.
8
+
9
+ ## Enabling Automatic Updates
10
+
11
+ > **👉🏻 Note:** If you encounter an error executing Upstream Sync, manually Sync Fork once
12
+
13
+ Once you have forked the project, due to Github restrictions, you will need to manually enable Workflows on the Actions page of your forked project and activate the Upstream Sync Action. Once enabled, you can set up hourly automatic updates.
14
+
15
+ ![sync-1](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/266985117-4d48fe7b-0412-4667-8129-b25ebcf2c9de.png)
16
+ ![sync-2](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/266985177-7677b4ce-c348-4145-9f60-829d448d5be6.png)
@@ -0,0 +1,16 @@
1
+ # LobeChat 自部署保持更新
2
+
3
+ 如果你根据 README 中的一键部署步骤部署了自己的项目,你可能会发现总是被提示“有可用更新”。这是因为 Vercel 默认为你创建新项目而非 fork 本项目,这将导致无法准确检测更新。我们建议按照以下步骤重新部署:
4
+
5
+ - 删除原有的仓库;
6
+ - 使用页面右上角的 <kbd>Fork</kbd> 按钮,Fork 本项目;
7
+ - 在 `Vercel` 上重新选择并部署。
8
+
9
+ ## 启动自动更新
10
+
11
+ > **👉🏻 提示:** 如果你在执行 `Upstream Sync` 时遇到错误,请手动执再行一次
12
+
13
+ 当你 Fork 了项目后,由于 Github 的限制,你需要手动在你 Fork 的项目的 Actions 页面启用 Workflows,并启动 Upstream Sync Action。启用后,你可以设置每小时进行一次自动更新。
14
+
15
+ ![sync-1](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/266985117-4d48fe7b-0412-4667-8129-b25ebcf2c9de.png)
16
+ ![sync-2](https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/266985177-7677b4ce-c348-4145-9f60-829d448d5be6.png)
package/docs/_Sidebar.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  - [TOC](Home)
6
6
 
7
+ ### 🤯 LobeChat
8
+
9
+ - [Upstream Sync](Upstream-Sync.en-US)
10
+ - [English](Upstream-Sync.en-US)
11
+ - [简体中文](Upstream-Sync.zh-CN)
12
+
7
13
  ### 🤖 Agents
8
14
 
9
15
  - [Agent Index](https://github.com/lobehub/lobe-chat-agents)
@@ -20,6 +20,64 @@
20
20
  "session": "Session Settings",
21
21
  "sessionWithName": "Session Settings · {{name}}"
22
22
  },
23
+ "llm": {
24
+ "AzureOpenAI": {
25
+ "endpoint": {
26
+ "desc": "This value can be found in the Keys and Endpoints section when checking out a resource on an Azure site.",
27
+ "placeholder": "https://docs-test-001.openai.azure.com",
28
+ "title": "Azure API URL"
29
+ },
30
+ "models": {
31
+ "desc": "Supported models",
32
+ "title": "List of models"
33
+ },
34
+ "title": "Azure OpenAI Settings",
35
+ "token": {
36
+ "desc": "This value can be found in the Keys and Endpoints section when checking out a resource on an Azure site. You can use KEY1 or KEY2",
37
+ "placeholder": "Azure API Key",
38
+ "title": "API Key"
39
+ }
40
+ },
41
+ "OpenAI": {
42
+ "azureApiVersion": {
43
+ "desc": "Azure API version in YYYY-MM-DD format, check [latest version](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
44
+ "fetch": "Get list",
45
+ "title": "Azure API version"
46
+ },
47
+ "check": {
48
+ "button": "Check",
49
+ "desc": "Check that the Api Key and proxy server address are filled in correctly.",
50
+ "pass": "Connection successful",
51
+ "title": "Checking connectivity"
52
+ },
53
+ "endpoint": {
54
+ "desc": "Must contain http(s):// in addition to the default address.",
55
+ "placeholder": "https://api.openai.com/v1",
56
+ "title": "API proxy address"
57
+ },
58
+ "models": {
59
+ "count": "Total supported models: {{count}}",
60
+ "desc": "Supported models",
61
+ "fetch": "Fetching the list of models",
62
+ "notSupport": "Azure OpenAI currently does not support viewing lists of models",
63
+ "notSupportTip": "Make sure that the deployment name matches the model name",
64
+ "refetch": "Fetching the list of models",
65
+ "title": "List of models"
66
+ },
67
+ "title": "OpenAI Settings",
68
+ "token": {
69
+ "desc": "Use your own OpenAI key",
70
+ "placeholder": "OpenAI API Key",
71
+ "title": "API Key"
72
+ },
73
+ "useAzure": {
74
+ "desc": "Using OpenAI services from Azure",
75
+ "fetch": "Get list",
76
+ "title": "Azure OpenAI"
77
+ }
78
+ },
79
+ "waitingForMore": "<1>Access to other models is planned</1>, so stay tuned ✨"
80
+ },
23
81
  "settingAgent": {
24
82
  "avatar": {
25
83
  "title": "Avatar"
@@ -170,6 +228,7 @@
170
228
  },
171
229
  "tab": {
172
230
  "agent": "Default Assistant",
173
- "common": "Common Settings"
231
+ "common": "Common Settings",
232
+ "llm": "Custom LLM API"
174
233
  }
175
234
  }
@@ -20,6 +20,64 @@
20
20
  "session": "Настройки сессии",
21
21
  "sessionWithName": "Настройки сессии · {{name}}"
22
22
  },
23
+ "llm": {
24
+ "AzureOpenAI": {
25
+ "endpoint": {
26
+ "desc": "Это значение можно найти в разделе «Ключи и конечные точки» при проверке ресурса на сайте Azure.",
27
+ "placeholder": "https://docs-test-001.openai.azure.com",
28
+ "title": "Адрес API Azure"
29
+ },
30
+ "models": {
31
+ "desc": "Поддерживаемые модели",
32
+ "title": "Список моделей"
33
+ },
34
+ "title": "Настройки Azure OpenAI",
35
+ "token": {
36
+ "desc": "Это значение можно найти в разделе «Ключи и конечные точки» при проверке ресурса на сайте Azure. Можно использовать KEY1 или KEY2",
37
+ "placeholder": "Azure Ключ API",
38
+ "title": "Ключ API"
39
+ }
40
+ },
41
+ "OpenAI": {
42
+ "azureApiVersion": {
43
+ "desc": "Версия API Azure в формате ГГГГ-ММ-ДД, проверьте [последнюю версию](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
44
+ "fetch": "Получить список",
45
+ "title": "Версия Azure Api"
46
+ },
47
+ "check": {
48
+ "button": "Проверить",
49
+ "desc": "Проверьте правильность заполнения Api Key и адреса прокси-сервера.",
50
+ "pass": "Подключение успешно",
51
+ "title": "Проверка возможности подключения"
52
+ },
53
+ "endpoint": {
54
+ "desc": "Должен содержать http(s):// в дополнение к адресу по умолчанию.",
55
+ "placeholder": "https://api.openai.com/v1",
56
+ "title": "адрес API прокси"
57
+ },
58
+ "models": {
59
+ "count": "Всего поддерживается {{count}} моделей",
60
+ "desc": "Поддерживаемые модели",
61
+ "fetch": "Получение списка моделей",
62
+ "notSupport": "Azure OpenAI в настоящее время не поддерживает просмотр списков моделей",
63
+ "notSupportTip": "Необходимо убедиться в том, что имя развертывания совпадает с именем модели",
64
+ "refetch": "Получение списка моделей",
65
+ "title": "Список моделей"
66
+ },
67
+ "title": "Настройки OpenAI",
68
+ "token": {
69
+ "desc": "Используйте свой собственный ключ OpenAI",
70
+ "placeholder": "Ключ API OpenAI",
71
+ "title": "Ключ API"
72
+ },
73
+ "useAzure": {
74
+ "desc": "Использование служб OpenAI из Azure",
75
+ "fetch": "Получить список",
76
+ "title": "Azure OpenAI"
77
+ }
78
+ },
79
+ "waitingForMore": "<1>Планируется доступ к другим моделям</1>, так что следите за обновлениями ✨"
80
+ },
23
81
  "settingAgent": {
24
82
  "avatar": {
25
83
  "title": "Аватар"
@@ -170,6 +228,7 @@
170
228
  },
171
229
  "tab": {
172
230
  "agent": "Помощник по умолчанию",
173
- "common": "Общие настройки"
231
+ "common": "Общие настройки",
232
+ "llm": "Пользовательский API GPT"
174
233
  }
175
234
  }
package/next.config.mjs CHANGED
@@ -27,8 +27,12 @@ const nextConfig = {
27
27
  async rewrites() {
28
28
  return [
29
29
  {
30
- source: '/api/openai-dev',
31
- destination: `${API_END_PORT_URL}/api/openai`,
30
+ source: '/api/openai/chat-dev',
31
+ destination: `${API_END_PORT_URL}/api/openai/chat`,
32
+ },
33
+ {
34
+ source: '/api/openai/models-dev',
35
+ destination: `${API_END_PORT_URL}/api/openai/models`,
32
36
  },
33
37
  {
34
38
  source: '/api/plugins-dev',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.72.4",
3
+ "version": "0.74.0",
4
4
  "description": "Lobe Chat is an open-source chatbot client using Vercel AI SDK, Typescript and Next.js",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -65,11 +65,12 @@
65
65
  "dependencies": {
66
66
  "@ant-design/colors": "^7",
67
67
  "@ant-design/icons": "^5",
68
+ "@azure/openai": "latest",
68
69
  "@emoji-mart/data": "^1",
69
70
  "@emoji-mart/react": "^1",
70
71
  "@icons-pack/react-simple-icons": "^9",
71
- "@lobehub/chat-plugin-sdk": "^1.17.0",
72
- "@lobehub/chat-plugins-gateway": "^1.5.0",
72
+ "@lobehub/chat-plugin-sdk": "^1.17.7",
73
+ "@lobehub/chat-plugins-gateway": "^1.5.1",
73
74
  "@lobehub/ui": "latest",
74
75
  "@vercel/analytics": "^1",
75
76
  "ahooks": "^3",
@@ -96,11 +97,11 @@
96
97
  "react-i18next": "^13",
97
98
  "react-intersection-observer": "^9",
98
99
  "react-layout-kit": "^1.7.1",
99
- "serpapi": "^2",
100
100
  "swr": "^2",
101
101
  "systemjs": "^6.14.2",
102
102
  "ts-md5": "^1",
103
103
  "use-merge-value": "^1",
104
+ "utility-types": "^3",
104
105
  "uuid": "^9",
105
106
  "zustand": "^4.4",
106
107
  "zustand-utils": "^1"
@@ -142,12 +143,6 @@
142
143
  "typescript": "^5",
143
144
  "vitest": "latest"
144
145
  },
145
- "peerDependencies": {
146
- "antd": ">=5",
147
- "antd-style": ">=3",
148
- "react": ">=18",
149
- "react-dom": ">=18"
150
- },
151
146
  "publishConfig": {
152
147
  "access": "public",
153
148
  "registry": "https://registry.npmjs.org"
@@ -3,6 +3,7 @@ declare global {
3
3
  namespace NodeJS {
4
4
  interface ProcessEnv {
5
5
  ACCESS_CODE?: string;
6
+ AZURE_API_KEY?: string;
6
7
  OPENAI_API_KEY?: string;
7
8
  OPENAI_PROXY_URL?: string;
8
9
  }
@@ -16,6 +17,7 @@ export const getServerConfig = () => {
16
17
 
17
18
  return {
18
19
  ACCESS_CODE: process.env.ACCESS_CODE,
20
+ AZURE_API_KEY: process.env.AZURE_API_KEY,
19
21
  OPENAI_API_KEY: process.env.OPENAI_API_KEY,
20
22
  OPENAI_PROXY_URL: process.env.OPENAI_PROXY_URL,
21
23
  };
@@ -1,7 +1,20 @@
1
1
  export const OPENAI_END_POINT = 'X-OPENAI-END_POINT';
2
-
3
2
  export const OPENAI_API_KEY_HEADER_KEY = 'X-OPENAI-API-KEY';
4
3
 
4
+ export const USE_AZURE_OPENAI = 'X-USE_AZURE_OPENAI';
5
+
6
+ export const AZURE_OPENAI_API_VERSION = 'X-AZURE_OPENAI_API_VERSION';
7
+
5
8
  export const LOBE_CHAT_ACCESS_CODE = 'X-LOBE_CHAT_ACCESS_CODE';
6
9
 
7
- export const LOBE_PLUGIN_SETTINGS = 'X-LOBE_PLUGIN_SETTINGS';
10
+ export const getOpenAIAuthFromRequest = (req: Request) => {
11
+ const apiKey = req.headers.get(OPENAI_API_KEY_HEADER_KEY);
12
+ const endpoint = req.headers.get(OPENAI_END_POINT);
13
+ const accessCode = req.headers.get(LOBE_CHAT_ACCESS_CODE);
14
+ const useAzureStr = req.headers.get(USE_AZURE_OPENAI);
15
+ const apiVersion = req.headers.get(AZURE_OPENAI_API_VERSION);
16
+
17
+ const useAzure = !!useAzureStr;
18
+
19
+ return { accessCode, apiKey, apiVersion, endpoint, useAzure };
20
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A white list of language models that are allowed to display and be used in the app.
3
+ */
4
+ export const LanguageModelWhiteList = [
5
+ // OpenAI
6
+ 'gpt-3.5-turbo',
7
+ 'gpt-3.5-turbo-16k',
8
+ 'gpt-4',
9
+ 'gpt-4-32k',
10
+ ];
11
+
12
+ export const DEFAULT_OPENAI_MODEL_LIST = [
13
+ 'gpt-3.5-turbo',
14
+ 'gpt-3.5-turbo-16k',
15
+ 'gpt-4',
16
+ 'gpt-4-32k',
17
+ ];
@@ -1,18 +1,17 @@
1
+ import { DEFAULT_OPENAI_MODEL_LIST } from '@/const/llm';
1
2
  import { DEFAULT_AGENT_META } from '@/const/meta';
2
3
  import { LanguageModel } from '@/types/llm';
3
4
  import { LobeAgentConfig } from '@/types/session';
4
- import { GlobalBaseSettings, GlobalDefaultAgent, GlobalSettings } from '@/types/settings';
5
+ import {
6
+ GlobalBaseSettings,
7
+ GlobalDefaultAgent,
8
+ GlobalLLMConfig,
9
+ GlobalSettings,
10
+ } from '@/types/settings';
5
11
 
6
12
  export const DEFAULT_BASE_SETTINGS: GlobalBaseSettings = {
7
- OPENAI_API_KEY: '',
8
13
  avatar: '',
9
- compressThreshold: 24,
10
- enableCompressThreshold: false,
11
- enableHistoryCount: false,
12
- enableMaxTokens: true,
13
- endpoint: '',
14
14
  fontSize: 14,
15
- historyCount: 24,
16
15
  language: 'zh-CN',
17
16
  neutralColor: '',
18
17
  password: '',
@@ -34,6 +33,14 @@ export const DEFAULT_AGENT_CONFIG: LobeAgentConfig = {
34
33
  systemRole: '',
35
34
  };
36
35
 
36
+ export const DEFAULT_LLM_CONFIG: GlobalLLMConfig = {
37
+ openAI: {
38
+ OPENAI_API_KEY: '',
39
+ azureApiVersion: '2023-08-01-preview',
40
+ models: DEFAULT_OPENAI_MODEL_LIST,
41
+ },
42
+ };
43
+
37
44
  export const DEFAULT_AGENT: GlobalDefaultAgent = {
38
45
  config: DEFAULT_AGENT_CONFIG,
39
46
  meta: DEFAULT_AGENT_META,
@@ -41,5 +48,6 @@ export const DEFAULT_AGENT: GlobalDefaultAgent = {
41
48
 
42
49
  export const DEFAULT_SETTINGS: GlobalSettings = {
43
50
  defaultAgent: DEFAULT_AGENT,
51
+ languageModel: DEFAULT_LLM_CONFIG,
44
52
  ...DEFAULT_BASE_SETTINGS,
45
53
  };
@@ -20,6 +20,64 @@ export default {
20
20
  session: '会话设置',
21
21
  sessionWithName: '会话设置 · {{name}}',
22
22
  },
23
+ llm: {
24
+ AzureOpenAI: {
25
+ endpoint: {
26
+ desc: '从 Azure 门户检查资源时,可在“密钥和终结点”部分中找到此值',
27
+ placeholder: 'https://docs-test-001.openai.azure.com',
28
+ title: 'Azure API 地址',
29
+ },
30
+ models: {
31
+ desc: '支持的模型',
32
+ title: '模型列表',
33
+ },
34
+ title: 'Azure OpenAI 设置',
35
+ token: {
36
+ desc: '从 Azure 门户检查资源时,可在“密钥和终结点”部分中找到此值。 可以使用 KEY1 或 KEY2',
37
+ placeholder: 'Azure API Key',
38
+ title: 'API Key',
39
+ },
40
+ },
41
+ OpenAI: {
42
+ azureApiVersion: {
43
+ desc: 'Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查阅[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)',
44
+ fetch: '获取列表',
45
+ title: 'Azure Api Version',
46
+ },
47
+ check: {
48
+ button: '检查',
49
+ desc: '测试 Api Key 与代理地址是否正确填写',
50
+ pass: '检查通过',
51
+ title: '连通性检查',
52
+ },
53
+ endpoint: {
54
+ desc: '除默认地址外,必须包含 http(s)://',
55
+ placeholder: 'https://api.openai.com/v1',
56
+ title: '接口代理地址',
57
+ },
58
+ models: {
59
+ count: '共支持 {{count}} 个模型',
60
+ desc: '支持的模型',
61
+ fetch: '获取模型列表',
62
+ notSupport: 'Azure OpenAI 暂不支持查看模型列表',
63
+ notSupportTip: '你需要自行确保部署名称与模型名称一致',
64
+ refetch: '重新获取模型列表',
65
+ title: '模型列表',
66
+ },
67
+ title: 'OpenAI 设置',
68
+ token: {
69
+ desc: '使用自己的 OpenAI Key',
70
+ placeholder: 'OpenAI API Key',
71
+ title: 'API Key',
72
+ },
73
+ useAzure: {
74
+ desc: '使用 Azure 提供的 OpenAI 服务',
75
+ fetch: '获取列表',
76
+ title: 'Azure OpenAI',
77
+ },
78
+ },
79
+ waitingForMore: '更多模型正在 <1>计划接入</1> 中,敬请期待 ✨',
80
+ },
23
81
  settingAgent: {
24
82
  avatar: {
25
83
  title: '头像',
@@ -114,19 +172,6 @@ export default {
114
172
  title: '核采样',
115
173
  },
116
174
  },
117
- settingOpenAI: {
118
- endpoint: {
119
- desc: '除默认地址外,必须包含 http(s)://',
120
- placeholder: 'https://api.openai.com/v1',
121
- title: '接口代理地址',
122
- },
123
- title: 'OpenAI 设置',
124
- token: {
125
- desc: '使用自己的 OpenAI Key',
126
- placeholder: 'OpenAI API Key',
127
- title: 'API Key',
128
- },
129
- },
130
175
  settingPlugin: {
131
176
  add: '添加',
132
177
  addTooltip: '添加自定义插件',
@@ -173,5 +218,6 @@ export default {
173
218
  tab: {
174
219
  agent: '默认助手',
175
220
  common: '通用设置',
221
+ llm: '语言模型',
176
222
  },
177
223
  };