@lobehub/chat 0.128.2 → 0.128.4

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 (146) hide show
  1. package/.github/workflows/issue-close-require.yml +3 -3
  2. package/.github/workflows/issues-translate.yml +3 -3
  3. package/.github/workflows/wiki-sync.yml +2 -2
  4. package/.husky/commit-msg +0 -3
  5. package/.husky/pre-commit +0 -3
  6. package/.i18nrc.js +2 -2
  7. package/CHANGELOG.md +50 -0
  8. package/README.md +3 -3
  9. package/README.zh-CN.md +3 -3
  10. package/contributing/Basic/Feature-Development.md +713 -0
  11. package/{docs/Development → contributing/Basic}/Feature-Development.zh-CN.md +2 -2
  12. package/{docs/Development → contributing/Basic}/Intro.zh-CN.md +5 -5
  13. package/{docs → contributing}/Home.md +21 -30
  14. package/{docs/Development → contributing/Internationalization}/Internationalization-Implementation.zh-CN.md +1 -1
  15. package/{docs → contributing}/_Sidebar.md +19 -30
  16. package/docs/agents/concepts.mdx +18 -0
  17. package/docs/agents/concepts.zh-CN.mdx +17 -0
  18. package/docs/agents/custom-agent.mdx +34 -0
  19. package/docs/agents/custom-agent.zh-CN.mdx +31 -0
  20. package/docs/agents/model.mdx +68 -0
  21. package/docs/agents/model.zh-CN.mdx +64 -0
  22. package/docs/agents/prompt.mdx +96 -0
  23. package/docs/agents/prompt.zh-CN.mdx +97 -0
  24. package/docs/agents/topics.mdx +7 -0
  25. package/docs/agents/topics.zh-CN.mdx +6 -0
  26. package/docs/common-errors/no-v1-suffix.mdx +18 -0
  27. package/docs/common-errors/no-v1-suffix.zh-CN.mdx +17 -0
  28. package/docs/common-errors/proxy-with-unable-to-verify-leaf-signature.mdx +70 -0
  29. package/docs/{Deployment/Common-Error.zh-CN.md → common-errors/proxy-with-unable-to-verify-leaf-signature.zh-CN.mdx} +8 -26
  30. package/docs/environment-variables/common.mdx +215 -0
  31. package/docs/environment-variables/common.zh-CN.mdx +214 -0
  32. package/docs/environment-variables/model-provider.mdx +135 -0
  33. package/docs/environment-variables/model-provider.zh-CN.mdx +133 -0
  34. package/docs/package.json +5 -0
  35. package/docs/plugins/basic-usage.mdx +40 -0
  36. package/docs/{Usage/Plugins.zh-CN.md → plugins/basic-usage.zh-CN.mdx} +7 -21
  37. package/docs/plugins/custom-plugin.mdx +27 -0
  38. package/docs/plugins/custom-plugin.zh-CN.mdx +26 -0
  39. package/docs/plugins/plugin-development.mdx +262 -0
  40. package/docs/{Plugins/Plugin-Development.zh-CN.md → plugins/plugin-development.zh-CN.mdx} +9 -33
  41. package/docs/plugins/plugin-store.mdx +10 -0
  42. package/docs/plugins/plugin-store.zh-CN.mdx +9 -0
  43. package/docs/self-hosting/analytics.mdx +20 -0
  44. package/docs/{Deployment/Analytics.zh-CN.md → self-hosting/analytics.zh-CN.mdx} +5 -8
  45. package/docs/self-hosting/authentication.mdx +94 -0
  46. package/docs/self-hosting/authentication.zh-CN.mdx +90 -0
  47. package/docs/self-hosting/deploy-with-azure-openai.mdx +48 -0
  48. package/docs/{Deployment/Deploy-with-Azure-OpenAI.zh-CN.md → self-hosting/deploy-with-azure-openai.zh-CN.mdx} +16 -21
  49. package/docs/self-hosting/docker-compose.mdx +121 -0
  50. package/docs/self-hosting/docker-compose.zh-CN.mdx +121 -0
  51. package/docs/self-hosting/docker.mdx +152 -0
  52. package/docs/self-hosting/docker.zh-CN.mdx +149 -0
  53. package/docs/self-hosting/environment-variable.mdx +340 -0
  54. package/docs/{Deployment/Environment-Variable.zh-CN.md → self-hosting/environment-variable.zh-CN.mdx} +43 -57
  55. package/docs/self-hosting/upstream-sync.mdx +66 -0
  56. package/docs/{Deployment/Upstream-Sync.zh-CN.md → self-hosting/upstream-sync.zh-CN.mdx} +23 -21
  57. package/docs/self-hosting/vercel.mdx +39 -0
  58. package/docs/self-hosting/vercel.zh-CN.mdx +39 -0
  59. package/docs/usage/agent-market.mdx +35 -0
  60. package/docs/usage/agent-market.zh-CN.mdx +32 -0
  61. package/docs/usage/mobile.mdx +8 -0
  62. package/docs/usage/mobile.zh-CN.mdx +7 -0
  63. package/docs/usage/more.mdx +21 -0
  64. package/docs/usage/more.zh-CN.mdx +19 -0
  65. package/docs/usage/plugin-system.mdx +84 -0
  66. package/docs/usage/plugin-system.zh-CN.mdx +77 -0
  67. package/docs/usage/pwa.mdx +21 -0
  68. package/docs/usage/pwa.zh-CN.mdx +21 -0
  69. package/docs/usage/text-to-image.mdx +5 -0
  70. package/docs/usage/text-to-image.zh-CN.mdx +6 -0
  71. package/docs/usage/theme.mdx +17 -0
  72. package/docs/usage/theme.zh-CN.mdx +15 -0
  73. package/docs/usage/tts.mdx +26 -0
  74. package/docs/usage/tts.zh-CN.mdx +24 -0
  75. package/docs/usage/vision.mdx +8 -0
  76. package/docs/usage/vision.zh-CN.mdx +7 -0
  77. package/locales/ar/common.json +1 -0
  78. package/locales/de-DE/common.json +1 -0
  79. package/locales/en-US/common.json +1 -0
  80. package/locales/es-ES/common.json +1 -0
  81. package/locales/fr-FR/common.json +1 -0
  82. package/locales/it-IT/common.json +1 -0
  83. package/locales/ja-JP/common.json +1 -0
  84. package/locales/ko-KR/common.json +1 -0
  85. package/locales/nl-NL/common.json +1 -0
  86. package/locales/pl-PL/common.json +1 -0
  87. package/locales/pt-BR/common.json +1 -0
  88. package/locales/ru-RU/common.json +1 -0
  89. package/locales/tr-TR/common.json +1 -0
  90. package/locales/vi-VN/common.json +1 -0
  91. package/locales/zh-CN/common.json +1 -0
  92. package/locales/zh-TW/common.json +1 -0
  93. package/next.config.mjs +5 -0
  94. package/package.json +6 -5
  95. package/scripts/docsWorkflow/const.ts +1 -1
  96. package/scripts/docsWorkflow/toc.ts +6 -6
  97. package/src/app/welcome/(desktop)/features/Footer.tsx +5 -3
  98. package/src/config/client.ts +6 -0
  99. package/src/const/url.ts +10 -1
  100. package/src/features/PluginStore/OnlineList.tsx +2 -16
  101. package/src/features/SideBar/BottomActions.tsx +11 -10
  102. package/src/locales/default/common.ts +1 -0
  103. package/docs/Deployment/Analytics.md +0 -20
  104. package/docs/Deployment/Authentication.md +0 -80
  105. package/docs/Deployment/Authentication.zh-CN.md +0 -80
  106. package/docs/Deployment/Common-Error.md +0 -87
  107. package/docs/Deployment/Deploy-with-Azure-OpenAI.md +0 -54
  108. package/docs/Deployment/Docker-Deployment.md +0 -219
  109. package/docs/Deployment/Docker-Deployment.zh-CN.md +0 -217
  110. package/docs/Deployment/Environment-Variable.md +0 -362
  111. package/docs/Deployment/Upstream-Sync.md +0 -62
  112. package/docs/Plugins/Plugin-Development.md +0 -287
  113. package/docs/Usage/Plugins.md +0 -53
  114. package/docs/Usage/Usage-Agents.md +0 -201
  115. package/docs/Usage/Usage-Agents.zh-CN.md +0 -202
  116. package/docs/Usage/Usage-Topics.md +0 -31
  117. package/docs/Usage/Usage-Topics.zh-CN.md +0 -31
  118. /package/{docs/Development → contributing/Basic}/Add-New-Authentication-Providers.md +0 -0
  119. /package/{docs/Development → contributing/Basic}/Add-New-Authentication-Providers.zh-CN.md +0 -0
  120. /package/{docs/Development → contributing/Basic}/Architecture.md +0 -0
  121. /package/{docs/Development → contributing/Basic}/Architecture.zh-CN.md +0 -0
  122. /package/{docs/Development → contributing/Basic}/Chat-API.md +0 -0
  123. /package/{docs/Development → contributing/Basic}/Chat-API.zh-CN.md +0 -0
  124. /package/{docs/Development → contributing/Basic}/Contributing-Guidelines.md +0 -0
  125. /package/{docs/Development → contributing/Basic}/Contributing-Guidelines.zh-CN.md +0 -0
  126. /package/{docs/Development → contributing/Basic}/Feature-Development-Frontend.md +0 -0
  127. /package/{docs/Development → contributing/Basic}/Feature-Development-Frontend.zh-CN.md +0 -0
  128. /package/{docs/Development → contributing/Basic}/Folder-Structure.md +0 -0
  129. /package/{docs/Development → contributing/Basic}/Folder-Structure.zh-CN.md +0 -0
  130. /package/{docs/Development → contributing/Basic}/Intro.md +0 -0
  131. /package/{docs/Development → contributing/Basic}/Resources.md +0 -0
  132. /package/{docs/Development → contributing/Basic}/Resources.zh-CN.md +0 -0
  133. /package/{docs/Development → contributing/Basic}/Setup-Development.md +0 -0
  134. /package/{docs/Development → contributing/Basic}/Setup-Development.zh-CN.md +0 -0
  135. /package/{docs/Development → contributing/Basic}/Test.md +0 -0
  136. /package/{docs/Development → contributing/Basic}/Test.zh-CN.md +0 -0
  137. /package/{docs/Development → contributing/Internationalization}/Add-New-Locale.md +0 -0
  138. /package/{docs/Development → contributing/Internationalization}/Add-New-Locale.zh-CN.md +0 -0
  139. /package/{docs/Development → contributing/Internationalization}/Internationalization-Implementation.md +0 -0
  140. /package/{docs → contributing}/Others/Lighthouse.md +0 -0
  141. /package/{docs → contributing}/Others/Lighthouse.zh-CN.md +0 -0
  142. /package/{docs/Development → contributing/State-Management}/State-Management-Intro.md +0 -0
  143. /package/{docs/Development → contributing/State-Management}/State-Management-Intro.zh-CN.md +0 -0
  144. /package/{docs/Development → contributing/State-Management}/State-Management-Selectors.md +0 -0
  145. /package/{docs/Development → contributing/State-Management}/State-Management-Selectors.zh-CN.md +0 -0
  146. /package/{docs → contributing}/_Footer.md +0 -0
@@ -1,54 +0,0 @@
1
- # Deploying with Azure OpenAI
2
-
3
- LobeChat supports using [Azure OpenAI][azure-openai-url] as the model service provider for OpenAI. This document will guide you through the configuration of Azure OpenAI.
4
-
5
- #### TOC
6
-
7
- - [Usage Limitations](#usage-limitations)
8
- - [Configuration in the Interface](#configuration-in-the-interface)
9
- - [Configuration at Deployment](#configuration-at-deployment)
10
-
11
- ## Usage Limitations
12
-
13
- Considering development costs ([#178][rfc]), the current version of LobeChat does not fully conform to Azure OpenAI's implementation model. Instead, it adopts a solution based on `openai` that is compatible with Azure OpenAI. This brings about the following limitations:
14
-
15
- - You can only choose one between OpenAI and Azure OpenAI. Once you enable Azure OpenAI, you will not be able to use OpenAI as the model service provider.
16
- - LobeChat requires deployment names to be the same as the model names in order to function properly. For example, the deployment name for the `gpt-35-turbo` model must be `gpt-35-turbo`, otherwise LobeChat will not be able to match the model correctly.
17
- ![](https://github-production-user-asset-6210df.s3.amazonaws.com/28616219/267082091-d89d53d3-1c8c-40ca-ba15-0a9af2a79264.png)
18
- - Due to the complexity of integrating the Azure OpenAI SDK, it is currently impossible to query the model list of configured resources.
19
-
20
- ## Configuration in the Interface
21
-
22
- Click on "Operation" - "Settings" in the bottom left corner, switch to the "Language Model" tab and enable the "Azure OpenAI" switch to start using Azure OpenAI.
23
-
24
- ![](https://github-production-user-asset-6210df.s3.amazonaws.com/28616219/267083420-422a3714-627e-4bef-9fbc-141a2a8ca916.png)
25
-
26
- You can fill in the corresponding configuration items as needed:
27
-
28
- - **APIKey**: The API key you applied for on the Azure OpenAI account page, which can be found in the "Keys and Endpoints" section.
29
- - **API Address**: Azure API address, which can be found in the "Keys and Endpoints" section when checking resources from the Azure portal.
30
- - **Azure Api Version**: The API version of Azure, which follows the YYYY-MM-DD format, refer to the [latest version][azure-api-version-url].
31
-
32
- After completing the above field configuration, click on "Check". If the prompt says "Check Passed", it means the configuration was successful.
33
-
34
- <br/>
35
-
36
- ## Configuration at Deployment
37
-
38
- If you want the deployed version to be directly configured with Azure OpenAI for end users to use immediately, you need to configure the following environment variables at deployment:
39
-
40
- | Environment Variable | Required | Description | Default Value | Example |
41
- | -------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -------------------------------------------------------------- |
42
- | `USE_AZURE_OPENAI` | Yes | Set this value to `1` to enable Azure OpenAI configuration | - | `1` |
43
- | `AZURE_API_KEY` | Yes | This is the API key you applied for on the Azure OpenAI account page | - | `c55168be3874490ef0565d9779ecd5a6` |
44
- | `OPENAI_PROXY_URL` | Yes | Azure API address, can be found in the "Keys and Endpoints" section | - | `https://docs-test-001.openai.azure.com` |
45
- | `AZURE_API_VERSION` | No | Azure's API version, follows the YYYY-MM-DD format | 2023-08-01-preview | `2023-05-15`, refer to [latest version][azure-api-version-url] |
46
- | `ACCESS_CODE` | No | Add a password to access this service; you can set a long password to avoid leaking. If this value contains a comma, it is a password array. | - | `awCT74` or `e3@09!` or `code1,code2,code3` |
47
-
48
- > \[!NOTE]
49
- >
50
- > When you enable `USE_AZURE_OPENAI` on the server side, users will not be able to modify and use the OpenAI key in the front-end configuration.
51
-
52
- [azure-api-version-url]: https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions
53
- [azure-openai-url]: https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models
54
- [rfc]: https://github.com/lobehub/lobe-chat/discussions/178
@@ -1,219 +0,0 @@
1
- # Docker Deployment Guide
2
-
3
- [![][docker-release-shield]][docker-release-link]
4
- [![][docker-size-shield]][docker-size-link]
5
- [![][docker-pulls-shield]][docker-pulls-link]
6
-
7
- We provide [Docker Images][docker-release-link] for you to deploy LobeChat service on your private device.
8
-
9
- #### TOC
10
-
11
- - [Install Docker container environment](#install-docker-container-environment)
12
- - [Deploy container image](#deploy-container-image)
13
- - [`A` Command deployment (recommended)](#a-command-deployment-recommended)
14
- - [`B` Docker Compose](#b-docker-compose)
15
-
16
- ## Install Docker container environment
17
-
18
- If already installed, skip this step.
19
-
20
- **Ubuntu:**
21
-
22
- ```fish
23
- $ apt install docker.io
24
- ```
25
-
26
- **CentOS:**
27
-
28
- ```fish
29
- $ yum install docker
30
- ```
31
-
32
- ## Deploy container image
33
-
34
- ### `A` Command deployment (recommended)
35
-
36
- Use the following command to start LobeChat service with one click:
37
-
38
- ```fish
39
- $ docker run -d -p 3210:3210 \
40
- -e OPENAI_API_KEY=sk-xxxx \
41
- -e ACCESS_CODE=lobe66 \
42
- --name lobe-chat \
43
- lobehub/lobe-chat
44
- ```
45
-
46
- > \[!NOTE]
47
- >
48
- > - The default mapped port is `3210`. Make sure it is not occupied or manually change the port mapping.
49
- > - Replace `sk-xxxx` in the above command with your own OpenAI API Key.
50
- > - The official Docker doesn't set password by default. Please add your own password to improve security.
51
- > - For a complete list of environment variables supported by LobeChat, please refer to the [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN) section.
52
-
53
- > \[!WARNING]
54
- >
55
- > If the architecture of your **deployed server differs from the container architecture**, you may need to perform cross-compilation for **Sharp**. For further details, please refer to the documentation on [Sharp Cross-platform](https://sharp.pixelplumbing.com/install#cross-platform).
56
-
57
- #### Use a proxy address
58
-
59
- If you need to use OpenAI service through a proxy, you can use the `OPENAI_PROXY_URL` environment variable to configure the proxy address:
60
-
61
- ```fish
62
- $ docker run -d -p 3210:3210 \
63
- -e OPENAI_API_KEY=sk-xxxx \
64
- -e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
65
- -e ACCESS_CODE=lobe66 \
66
- --name lobe-chat \
67
- lobehub/lobe-chat
68
- ```
69
-
70
- > \[!NOTE]
71
- >
72
- > As the official Docker image build takes about half an hour, if there is a "update available" prompt after updating deployment, wait for the image to finish building before deploying again.
73
-
74
- #### Crontab Auto-Update Script
75
-
76
- If you want to automatically get the latest images, you can do the following.
77
-
78
- First, create a `lobe.env` configuration file with various environment variables, for example:
79
-
80
- ```env
81
- OPENAI_API_KEY=sk-xxxx
82
- OPENAI_PROXY_URL=https://api-proxy.com/v1
83
- ACCESS_CODE=arthals2333
84
- CUSTOM_MODELS=-gpt-4,-gpt-4-32k,-gpt-3.5-turbo-16k,gpt-3.5-turbo-1106=gpt-3.5-turbo-16k,gpt-4-0125-preview=gpt-4-turbo,gpt-4-vision-preview=gpt-4-vision
85
- ```
86
-
87
- Then, you can use the following script to automatically update:
88
-
89
- ```bash
90
- #!/bin/bash
91
- # auto-update-lobe-chat.sh
92
-
93
- # Set proxy (optional)
94
- export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
95
-
96
- # Pull the latest image and store the output in a variable
97
- output=$(docker pull lobehub/lobe-chat:latest 2>&1)
98
-
99
- # Check if the pull command executed successfully
100
- if [ $? -ne 0 ]; then
101
- exit 1
102
- fi
103
-
104
- # Check if the output contains a specific string
105
- echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
106
-
107
- # If the image is already up to date, then do nothing
108
- if [ $? -eq 0 ]; then
109
- exit 0
110
- fi
111
-
112
- echo "Detected Lobe-Chat update"
113
-
114
- # Remove old container
115
- echo "Removed: $(docker rm -f Lobe-Chat)"
116
-
117
- # Run new container
118
- echo "Started: $(docker run -d --network=host --env-file /path/to/lobe.env --name=Lobe-Chat --restart=always lobehub/lobe-chat)"
119
-
120
- # Print the update time and version
121
- echo "Update time: $(date)"
122
- echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
123
-
124
- # Clean up unused images
125
- docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
126
- echo "Removed old images."
127
- ```
128
-
129
- This script can be used in Crontab, but make sure your Crontab can find the correct Docker command. It's recommended to use absolute paths.
130
-
131
- Configure Crontab to execute the script every 5 minutes:
132
-
133
- ```bash
134
- */5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
135
- ```
136
-
137
- ### `B` Docker Compose
138
-
139
- The configuration file for using `docker-compose` is as follows:
140
-
141
- ```yml
142
- version: '3.8'
143
-
144
- services:
145
- lobe-chat:
146
- image: lobehub/lobe-chat
147
- container_name: lobe-chat
148
- restart: always
149
- ports:
150
- - '3210:3210'
151
- environment:
152
- OPENAI_API_KEY: sk-xxxx
153
- OPENAI_PROXY_URL: https://api-proxy.com/v1
154
- ACCESS_CODE: lobe66
155
- ```
156
-
157
- #### Crontab Auto-Update Script
158
-
159
- Similarly, you can use the following script to update Lobe Chat automatically. When using `Docker Compose`, environment variables do not need additional configuration.
160
-
161
- ```bash
162
- #!/bin/bash
163
- # auto-update-lobe-chat.sh
164
-
165
- # Set proxy (optional)
166
- export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
167
-
168
- # Pull the latest image and store the output in a variable
169
- output=$(docker pull lobehub/lobe-chat:latest 2>&1)
170
-
171
- # Check if the pull command executed successfully
172
- if [ $? -ne 0 ]; then
173
- exit 1
174
- fi
175
-
176
- # Check if the output contains a specific string
177
- echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
178
-
179
- # If the image is already up to date, then do nothing
180
- if [ $? -eq 0 ]; then
181
- exit 0
182
- fi
183
-
184
- echo "Detected Lobe-Chat update"
185
-
186
- # Remove old container
187
- echo "Removed: $(docker rm -f Lobe-Chat)"
188
-
189
- # Maybe you need to enter the directory where `docker-compose.yml` is located first
190
- # cd /path/to/docker-compose-folder
191
-
192
- # Run new container
193
- echo "Started: $(docker-compose up)"
194
-
195
- # Print the update time and version
196
- echo "Update time: $(date)"
197
- echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
198
-
199
- # Clean up unused images
200
- docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
201
- echo "Removed old images."
202
- ```
203
-
204
- This script can also be used in Crontab, but make sure your Crontab can find the correct Docker command. It's recommended to use absolute paths.
205
-
206
- Configure Crontab to execute the script every 5 minutes:
207
-
208
- ```bash
209
- */5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
210
- ```
211
-
212
- <!-- LINK GROUP -->
213
-
214
- [docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
215
- [docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
216
- [docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
217
- [docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square
218
- [docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
219
- [docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
@@ -1,217 +0,0 @@
1
- # Docker 部署指引
2
-
3
- [![][docker-release-shield]][docker-release-link]
4
- [![][docker-size-shield]][docker-size-link]
5
- [![][docker-pulls-shield]][docker-pulls-link]
6
-
7
- 我们提供了 [Docker 镜像][docker-release-link],供你在自己的私有设备上部署 LobeChat 服务
8
-
9
- #### TOC
10
-
11
- - [安装 Docker 容器环境](#安装-docker-容器环境)
12
- - [部署容器镜像](#部署容器镜像)
13
- - [`A` 指令部署(推荐)](#a-指令部署推荐)
14
- - [`B` Docker Compose](#b-docker-compose)
15
-
16
- ## 安装 Docker 容器环境
17
-
18
- 如果已安装,请跳过此步
19
-
20
- **Ubuntu**
21
-
22
- ```fish
23
- $ apt install docker.io
24
- ```
25
-
26
- **CentOS**
27
-
28
- ```fish
29
- $ yum install docker
30
- ```
31
-
32
- ## 部署容器镜像
33
-
34
- ### `A` 指令部署(推荐)
35
-
36
- 使用以下命令即可使用一键启动 LobeChat 服务:
37
-
38
- ```fish
39
- $ docker run -d -p 3210:3210 \
40
- -e OPENAI_API_KEY=sk-xxxx \
41
- -e ACCESS_CODE=lobe66 \
42
- --name lobe-chat \
43
- lobehub/lobe-chat
44
- ```
45
-
46
- > \[!NOTE]
47
- >
48
- > - 默认映射端口为 `3210`, 请确保未被占用或手动更改端口映射
49
- > - 使用你的 OpenAI API Key 替换上述命令中的 `sk-xxxx`
50
- > - 官方 Docker 镜像中未设定密码,强烈建议添加密码以提升安全性,否则你可能会遇到 [My API Key was stolen!!!](https://github.com/lobehub/lobe-chat/issues/1123) 这样的情况
51
- > - LobeChat 支持的完整环境变量列表请参考 [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN) 部分
52
-
53
- > \[!WARNING]
54
- >
55
- > 注意,当**部署架构与镜像的不一致时**,需要对 **Sharp** 进行交叉编译,详见 [Sharp 交叉编译](https://sharp.pixelplumbing.com/install#cross-platform)
56
-
57
- #### 使用代理地址
58
-
59
- 如果你需要通过代理使用 OpenAI 服务,你可以使用 `OPENAI_PROXY_URL` 环境变量来配置代理地址:
60
-
61
- ```fish
62
- $ docker run -d -p 3210:3210 \
63
- -e OPENAI_API_KEY=sk-xxxx \
64
- -e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
65
- -e ACCESS_CODE=lobe66 \
66
- --name lobe-chat \
67
- lobehub/lobe-chat
68
- ```
69
-
70
- > \[!NOTE]
71
- >
72
- > 由于官方的 Docker 镜像构建大约需要半小时左右,如果在更新部署后会出现「存在更新」的提示,可以等待镜像构建完成后再次部署。
73
-
74
- #### Crontab 自动更新脚本
75
-
76
- 如果你想自动获得最新的镜像,你可以如下操作。
77
-
78
- 首先,新建一个 `lobe.env` 配置文件,内容为各种环境变量,例如:
79
-
80
- ```env
81
- OPENAI_API_KEY=sk-xxxx
82
- OPENAI_PROXY_URL=https://api-proxy.com/v1
83
- ACCESS_CODE=arthals2333
84
- CUSTOM_MODELS=-gpt-4,-gpt-4-32k,-gpt-3.5-turbo-16k,gpt-3.5-turbo-1106=gpt-3.5-turbo-16k,gpt-4-0125-preview=gpt-4-turbo,gpt-4-vision-preview=gpt-4-vision
85
- ```
86
-
87
- 然后,你可以使用以下脚本来自动更新:
88
-
89
- ```bash
90
- #!/bin/bash
91
- # auto-update-lobe-chat.sh
92
-
93
- # 设置代理(可选)
94
- export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
95
-
96
- # 拉取最新的镜像并将输出存储在变量中
97
- output=$(docker pull lobehub/lobe-chat:latest 2>&1)
98
-
99
- # 检查拉取命令是否成功执行
100
- if [ $? -ne 0 ]; then
101
- exit 1
102
- fi
103
-
104
- # 检查输出中是否包含特定的字符串
105
- echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
106
-
107
- # 如果镜像已经是最新的,则不执行任何操作
108
- if [ $? -eq 0 ]; then
109
- exit 0
110
- fi
111
-
112
- echo "Detected Lobe-Chat update"
113
-
114
- # 删除旧的容器
115
- echo "Removed: $(docker rm -f Lobe-Chat)"
116
-
117
- # 运行新的容器
118
- echo "Started: $(docker run -d --network=host --env-file /path/to/lobe.env --name=Lobe-Chat --restart=always lobehub/lobe-chat)"
119
-
120
- # 打印更新的时间和版本
121
- echo "Update time: $(date)"
122
- echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
123
-
124
- # 清理不再使用的镜像
125
- docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
126
- echo "Removed old images."
127
- ```
128
-
129
- 此脚本可以在 Crontab 中使用,但请确认你的 Crontab 可以找到正确的 Docker 命令。建议使用绝对路径。
130
-
131
- 配置 Crontab,每 5 分钟执行一次脚本:
132
-
133
- ```bash
134
- */5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
135
- ```
136
-
137
- ### `B` Docker Compose
138
-
139
- 使用 `docker-compose` 时配置文件如下:
140
-
141
- ```yml
142
- version: '3.8'
143
-
144
- services:
145
- lobe-chat:
146
- image: lobehub/lobe-chat
147
- container_name: lobe-chat
148
- restart: always
149
- ports:
150
- - '3210:3210'
151
- environment:
152
- OPENAI_API_KEY: sk-xxxx
153
- OPENAI_PROXY_URL: https://api-proxy.com/v1
154
- ACCESS_CODE: lobe66
155
- ```
156
-
157
- #### Crontab 自动更新脚本
158
-
159
- 类似地,你可以使用以下脚本来自动更新 Lobe Chat,使用 `Docker Compose` 时,环境变量无需额外配置。
160
-
161
- ```bash
162
- #!/bin/bash
163
- # auto-update-lobe-chat.sh
164
-
165
- # 设置代理(可选)
166
- export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
167
-
168
- # 拉取最新的镜像并将输出存储在变量中
169
- output=$(docker pull lobehub/lobe-chat:latest 2>&1)
170
-
171
- # 检查拉取命令是否成功执行
172
- if [ $? -ne 0 ]; then
173
- exit 1
174
- fi
175
-
176
- # 检查输出中是否包含特定的字符串
177
- echo "$output" | grep -q "Image is up to date for lobehub/lobe-chat:latest"
178
-
179
- # 如果镜像已经是最新的,则不执行任何操作
180
- if [ $? -eq 0 ]; then
181
- exit 0
182
- fi
183
-
184
- echo "Detected Lobe-Chat update"
185
-
186
- # 删除旧的容器
187
- echo "Removed: $(docker rm -f Lobe-Chat)"
188
-
189
- # 也许需要先进入 `docker-compose.yml` 所在的目录
190
- # cd /path/to/docker-compose-folder
191
-
192
- # 运行新的容器
193
- echo "Started: $(docker-compose up)"
194
-
195
- # 打印更新的时间和版本
196
- echo "Update time: $(date)"
197
- echo "Version: $(docker inspect lobehub/lobe-chat:latest | grep 'org.opencontainers.image.version' | awk -F'"' '{print $4}')"
198
-
199
- # 清理不再使用的镜像
200
- docker images | grep 'lobehub/lobe-chat' | grep -v 'latest' | awk '{print $3}' | xargs -r docker rmi > /dev/null 2>&1
201
- echo "Removed old images."
202
- ```
203
-
204
- 此脚本亦可以在 Crontab 中使用,但请确认你的 Crontab 可以找到正确的 Docker 命令。建议使用绝对路径。
205
-
206
- 配置 Crontab,每 5 分钟执行一次脚本:
207
-
208
- ```bash
209
- */5 * * * * /path/to/auto-update-lobe-chat.sh >> /path/to/auto-update-lobe-chat.log 2>&1
210
- ```
211
-
212
- [docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
213
- [docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
214
- [docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
215
- [docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square
216
- [docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
217
- [docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square