@lobehub/chat 0.89.3 → 0.89.5
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.
- package/CHANGELOG.md +51 -0
- package/README.md +61 -42
- package/README.zh-CN.md +46 -27
- package/docs/Development-Guide/Architecture.zh-CN.md +37 -0
- package/docs/Development-Guide/Chat-API.zh-CN.md +127 -0
- package/docs/Development-Guide/Feature-Development.zh-CN.md +118 -0
- package/docs/Development-Guide/Folder-Structure.zh-CN.md +4 -2
- package/docs/Development-Guide/Resources.zh-CN.md +19 -0
- package/docs/Development-Guide/Steup-Development.zh-CN.md +62 -0
- package/docs/Development-Guide/Test.zh-CN.md +79 -0
- package/docs/Docker-Deployment.md +60 -16
- package/docs/Docker-Deployment.zh-CN.md +54 -14
- package/docs/Home.md +1 -0
- package/docs/_Sidebar.md +1 -0
- package/package.json +2 -2
- package/src/app/api/openai/createChatCompletion.ts +8 -5
- package/src/app/settings/common/Common.tsx +4 -0
- package/src/locales/resources/index.ts +1 -0
- package/src/store/plugin/slices/plugin/action.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.89.5](https://github.com/lobehub/lobe-chat/compare/v0.89.4...v0.89.5)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-10-15**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix fallback to en when the locale is zh, fix reset button not clear plugin settings.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix fallback to en when the locale is zh ([ff2c00e](https://github.com/lobehub/lobe-chat/commit/ff2c00e))
|
|
21
|
+
- **misc**: Fix reset button not clear plugin settings ([aa1e657](https://github.com/lobehub/lobe-chat/commit/aa1e657))
|
|
22
|
+
|
|
23
|
+
</details>
|
|
24
|
+
|
|
25
|
+
<div align="right">
|
|
26
|
+
|
|
27
|
+
[](#readme-top)
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
### [Version 0.89.4](https://github.com/lobehub/lobe-chat/compare/v0.89.3...v0.89.4)
|
|
32
|
+
|
|
33
|
+
<sup>Released on **2023-10-15**</sup>
|
|
34
|
+
|
|
35
|
+
#### 🐛 Bug Fixes
|
|
36
|
+
|
|
37
|
+
- **misc**: Fix qwen, chatglm request failed.
|
|
38
|
+
|
|
39
|
+
<br/>
|
|
40
|
+
|
|
41
|
+
<details>
|
|
42
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
43
|
+
|
|
44
|
+
#### What's fixed
|
|
45
|
+
|
|
46
|
+
- **misc**: Fix qwen, chatglm request failed, closes [#318](https://github.com/lobehub/lobe-chat/issues/318) ([a5699e2](https://github.com/lobehub/lobe-chat/commit/a5699e2))
|
|
47
|
+
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+
<div align="right">
|
|
51
|
+
|
|
52
|
+
[](#readme-top)
|
|
53
|
+
|
|
54
|
+
</div>
|
|
55
|
+
|
|
5
56
|
### [Version 0.89.3](https://github.com/lobehub/lobe-chat/compare/v0.89.2...v0.89.3)
|
|
6
57
|
|
|
7
58
|
<sup>Released on **2023-10-12**</sup>
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<h1>Lobe Chat</h1>
|
|
10
10
|
|
|
11
|
-
LobeChat is
|
|
11
|
+
LobeChat is an open-source, extensible ([Function Calling][fc-link]) high-performance chatbot framework. <br/> It supports one-click free deployment of your private ChatGPT/LLM web application.
|
|
12
12
|
|
|
13
13
|
**English** · [简体中文](./README.zh-CN.md) · [Changelog](./CHANGELOG.md) · [Wiki][github-wiki-link] · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
|
|
14
14
|
|
|
@@ -49,8 +49,9 @@ LobeChat is a open-source, extensible ([Function Calling][fc-link]), high-perfor
|
|
|
49
49
|
- [📸 Snapshot](#-snapshot)
|
|
50
50
|
- [⚡️ Performance](#️-performance)
|
|
51
51
|
- [🛳 Self Hosting](#-self-hosting)
|
|
52
|
-
- [Deploying with Vercel](#deploying-with-vercel)
|
|
53
|
-
- [Deploying with Docker](#deploying-with-docker)
|
|
52
|
+
- [`A` Deploying with Vercel](#a-deploying-with-vercel)
|
|
53
|
+
- [`B` Deploying with Docker](#b-deploying-with-docker)
|
|
54
|
+
- [Environment Variable](#environment-variable)
|
|
54
55
|
- [📦 Ecosystem](#-ecosystem)
|
|
55
56
|
- [🧩 Plugins](#-plugins)
|
|
56
57
|
- [⌨️ Local Development](#️-local-development)
|
|
@@ -65,14 +66,14 @@ LobeChat is a open-source, extensible ([Function Calling][fc-link]), high-perfor
|
|
|
65
66
|
|
|
66
67
|
## 👋🏻 Getting Started & Join Our Community
|
|
67
68
|
|
|
68
|
-
Please be aware that LobeChat is currently under active development
|
|
69
|
+
Please be aware that LobeChat is currently under active development, and feedback is welcome for any [issues][issues-link] encountered.
|
|
69
70
|
|
|
70
71
|
| [![][vercel-shield-badge]][vercel-link] | No installation or registration necessary! Visit our website to experience it firsthand. |
|
|
71
72
|
| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
|
|
72
73
|
| [![][discord-shield-badge]][discord-link] | Join our Discord community! This is where you can connect with developers and other enthusiastic users of LobeHub. |
|
|
73
74
|
|
|
74
75
|
> **Important**\
|
|
75
|
-
> **Star Us
|
|
76
|
+
> **Star Us**, You will receive all release notifications from GitHub without any delay \~ ⭐️
|
|
76
77
|
|
|
77
78
|

|
|
78
79
|
|
|
@@ -85,12 +86,12 @@ Please be aware that LobeChat is currently under active development,feedback i
|
|
|
85
86
|
|
|
86
87
|
## ✨ Features
|
|
87
88
|
|
|
88
|
-
- [x] 💨 **Quick Deployment**: Using the Vercel platform, you can deploy with just one click and complete the process within 1 minute
|
|
89
|
+
- [x] 💨 **Quick Deployment**: Using the Vercel platform, you can deploy with just one click and complete the process within 1 minute without any complex configuration;
|
|
89
90
|
- [x] 💎 **Exquisite UI Design**: With a carefully designed interface, it offers an elegant appearance and smooth interaction. It supports light and dark themes and is mobile-friendly. PWA support provides a more native-like experience;
|
|
90
91
|
- [x] 🗣️ **Smooth Conversation Experience**: Fluid responses ensure a smooth conversation experience. It fully supports Markdown rendering, including code highlighting, LaTex formulas, Mermaid flowcharts, and more;
|
|
91
92
|
- [x] 🧩 **Plugin Support & Custom Plugin Development**: Conversations are extendable with plugins. Users can install and use various plugins, such as search engines, web extraction, etc. It also supports the development of custom plugins to meet custom needs;
|
|
92
93
|
- [x] 🔒 **Privacy Protection**: All data is stored locally in the user's browser, ensuring user privacy;
|
|
93
|
-
- [x] 🤖 **Customizable Agent Roles**: Users can create, share, and debug personalized dialogue agent roles according to their needs, providing more flexible and
|
|
94
|
+
- [x] 🤖 **Customizable Agent Roles**: Users can create, share, and debug personalized dialogue agent roles according to their needs, providing more flexible and customized dialogue functions;
|
|
94
95
|
- [x] 🌐 **Custom Domain**: If users have their own domain, they can bind it to the platform for quick access to the dialogue agent from anywhere.
|
|
95
96
|
- [x] 🏬 **Role Market**: A Role Market is provided where users can select their preferred dialogue agent roles, enriching the content and style of the dialogue;
|
|
96
97
|
|
|
@@ -109,7 +110,7 @@ Please be aware that LobeChat is currently under active development,feedback i
|
|
|
109
110
|
|
|
110
111
|
#### `1` Function Calling Plugin System
|
|
111
112
|
|
|
112
|
-
By building a
|
|
113
|
+
By building a robust plugin ecosystem, ChatGPT cannot only provide real-time news updates but can also assist you in efficiently querying documents and accessing various e-commerce data. This allows ChatGPT to play a vital role in a wider range of fields. If you are interested in writing plugins, we provide detailed component development documentation, SDKs, and template files in the [🧩 Plugin System](#-Plugin-System) section below. Let's work together to make ChatGPT more powerful and easier to use.
|
|
113
114
|
|
|
114
115
|
<br/>
|
|
115
116
|
|
|
@@ -117,7 +118,7 @@ By building a powerful plugin ecosystem, ChatGPT not only can provide real-time
|
|
|
117
118
|
|
|
118
119
|
#### `2` Prompt Agent Market
|
|
119
120
|
|
|
120
|
-
In our agent market, we have accumulated a large number of practical prompt agents that have been used in daily work and study. You can also share your agents here and iterate and optimize your prompt agents with more people. You can submit your agents through [🤖/🏪 Submit Agents][submit-agents-link], and our automated i18n workflow will automatically translate your agents into multiple languages, allowing users
|
|
121
|
+
In our agent market, we have accumulated a large number of practical, prompt agents that have been used in daily work and study. You can also share your agents here and iterate and optimize your prompt agents with more people. You can submit your agents through [🤖/🏪 Submit Agents][submit-agents-link], and our automated i18n workflow will automatically translate your agents into multiple languages, allowing users worldwide to enjoy your wisdom.
|
|
121
122
|
|
|
122
123
|
<br/>
|
|
123
124
|
|
|
@@ -175,56 +176,71 @@ We have carried out a series of optimization designs for mobile devices to enhan
|
|
|
175
176
|
|
|
176
177
|
## 🛳 Self Hosting
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
LobeChat provides [Self-Hosted Version][deploy-link] with Vercel and [Docker Image][docker-release-link]. This allows you to deploy your own chatbot within a few minutes without any prior knowledge.
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
<br/>
|
|
182
|
+
|
|
183
|
+
### `A` Deploying with Vercel
|
|
184
|
+
|
|
185
|
+
If you want to deploy this service yourself on Vercel, you can follow these steps:
|
|
181
186
|
|
|
182
187
|
- Prepare your [OpenAI API Key](https://platform.openai.com/account/api-keys).
|
|
183
|
-
- Click the button below to start deployment: Deploy with Vercel. Log in directly with your GitHub account and remember to fill in the API Key and access code CODE on the environment variable page;
|
|
188
|
+
- Click the button below to start deployment: Deploy with Vercel. Log in directly with your GitHub account, and remember to fill in the API Key and access code CODE on the environment variable page;
|
|
184
189
|
- After deployment, you can start using it;
|
|
185
|
-
- Bind a custom domain (optional): The DNS of the domain assigned by Vercel is polluted in some areas
|
|
186
|
-
|
|
187
|
-
<div align="center">
|
|
190
|
+
- Bind a custom domain (optional): The DNS of the domain assigned by Vercel is polluted in some areas; binding a custom domain can connect directly.
|
|
188
191
|
|
|
189
|
-
|
|
192
|
+
#### Keep Updated
|
|
190
193
|
|
|
191
|
-
|
|
194
|
+
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 detect updates accurately.
|
|
192
195
|
|
|
193
|
-
> **
|
|
194
|
-
>
|
|
195
|
-
|
|
196
|
-
| Environment Variable | Required | Description | Example |
|
|
197
|
-
| -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
198
|
-
| `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
|
|
199
|
-
| `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/v1`<br/>The default value is<br/>`https://api.openai.com/v1` |
|
|
200
|
-
| `ACCESS_CODE` | No | Add a password to access this service, the password should be a 6-digit number or letter | `awCT74` or `e3@09!` |
|
|
196
|
+
> **Important**\
|
|
197
|
+
> We suggest you redeploy using the following steps, [📘 Maintaining Updates with LobeChat Self-Deployment](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync).
|
|
201
198
|
|
|
202
|
-
|
|
199
|
+
<br/>
|
|
203
200
|
|
|
204
|
-
|
|
201
|
+
### `B` Deploying with Docker
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
[![][docker-release-shield]][docker-release-link]
|
|
204
|
+
[![][docker-size-shield]][docker-size-link]
|
|
205
|
+
[![][docker-pulls-shield]][docker-pulls-link]
|
|
207
206
|
|
|
208
|
-
We provide a Docker image for deploying the LobeChat service on your own private device. Use the following command to start the LobeChat service
|
|
207
|
+
We provide a Docker image for deploying the LobeChat service on your own private device. Use the following command to start the LobeChat service:
|
|
209
208
|
|
|
210
|
-
```
|
|
211
|
-
docker run -d -p 3210:3210 \
|
|
209
|
+
```fish
|
|
210
|
+
$ docker run -d -p 3210:3210 \
|
|
212
211
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
213
212
|
-e ACCESS_CODE=lobe66 \
|
|
214
213
|
lobehub/lobe-chat
|
|
215
214
|
```
|
|
216
215
|
|
|
217
|
-
|
|
216
|
+
> **Note**\
|
|
217
|
+
> If you need to use the OpenAI service through a proxy, you can configure the proxy address using the `OPENAI_PROXY_URL` environment variable:
|
|
218
218
|
|
|
219
|
-
```
|
|
220
|
-
docker run -d -p 3210:3210 \
|
|
219
|
+
```fish
|
|
220
|
+
$ docker run -d -p 3210:3210 \
|
|
221
221
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
222
222
|
-e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
|
|
223
223
|
-e ACCESS_CODE=lobe66 \
|
|
224
224
|
lobehub/lobe-chat
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
> **Note**\
|
|
228
|
+
> For detailed instructions on deploying with Docker, please refer to the [📘 Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment)
|
|
229
|
+
|
|
230
|
+
<br/>
|
|
231
|
+
|
|
232
|
+
### Environment Variable
|
|
233
|
+
|
|
234
|
+
This project provides some additional configuration items set with environment variables:
|
|
235
|
+
|
|
236
|
+
| Environment Variable | Required | Description | Example |
|
|
237
|
+
| -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
238
|
+
| `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
|
|
239
|
+
| `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/v1`<br/>The default value is<br/>`https://api.openai.com/v1` |
|
|
240
|
+
| `ACCESS_CODE` | No | Add a password to access this service; the password should be a 6-digit number or letter | `awCT74` or `e3@09!` |
|
|
241
|
+
|
|
242
|
+
> **Note**\
|
|
243
|
+
> The complete list of environment variables can be found in the [📘 Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable)
|
|
228
244
|
|
|
229
245
|
<div align="right">
|
|
230
246
|
|
|
@@ -248,12 +264,12 @@ For detailed instructions on deploying with Docker, please refer to the [📘 Do
|
|
|
248
264
|
|
|
249
265
|
## 🧩 Plugins
|
|
250
266
|
|
|
251
|
-
Plugins provide a means to extend the [Function Calling][fc-link] capabilities of LobeChat. They can be used to introduce new function calls
|
|
267
|
+
Plugins provide a means to extend the [Function Calling][fc-link] capabilities of LobeChat. They can be used to introduce new function calls and even new ways to render message results. If you are interested in plugin development, please refer to our [📘 Plugin Development Guide](https://github.com/lobehub/lobe-chat/wiki/Plugin-Development) in the Wiki.
|
|
252
268
|
|
|
253
269
|
- [lobe-chat-plugins][lobe-chat-plugins]: This is the plugin index for LobeChat. It accesses index.json from this repository to display a list of available plugins for LobeChat to the user.
|
|
254
270
|
- [chat-plugin-template][chat-plugin-template]: This is the plugin template for LobeChat plugin development.
|
|
255
271
|
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]: The LobeChat Plugin SDK assists you in creating exceptional chat plugins for Lobe Chat.
|
|
256
|
-
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]: The LobeChat Plugins Gateway is a backend service that
|
|
272
|
+
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]: The LobeChat Plugins Gateway is a backend service that provides a gateway for LobeChat plugins. We deploy this service using Vercel. The primary API POST /api/v1/runner is deployed as an Edge Function.
|
|
257
273
|
|
|
258
274
|
> **Note**\
|
|
259
275
|
> The plugin system is currently undergoing major development. You can learn more in the following issues:
|
|
@@ -284,7 +300,7 @@ Or clone it for local development:
|
|
|
284
300
|
|
|
285
301
|
[![][bun-shield]][bun-link]
|
|
286
302
|
|
|
287
|
-
```
|
|
303
|
+
```fish
|
|
288
304
|
$ git clone https://github.com/lobehub/lobe-chat.git
|
|
289
305
|
$ cd lobe-chat
|
|
290
306
|
$ bun install
|
|
@@ -299,7 +315,7 @@ $ bun dev
|
|
|
299
315
|
|
|
300
316
|
## 🤝 Contributing
|
|
301
317
|
|
|
302
|
-
Contributions of all types are more than welcome
|
|
318
|
+
Contributions of all types are more than welcome; if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] and [Projects][github-project-link] to get stuck in to show us what you’re made of.
|
|
303
319
|
|
|
304
320
|
[![][pr-welcome-shield]][pr-welcome-link]
|
|
305
321
|
[![][submit-agents-shield]][submit-agents-link]
|
|
@@ -315,9 +331,9 @@ Contributions of all types are more than welcome, if you are interested in contr
|
|
|
315
331
|
|
|
316
332
|
## 🔗 More Products
|
|
317
333
|
|
|
318
|
-
- **[🤯 Lobe Theme][lobe-theme]
|
|
334
|
+
- **[🤯 Lobe Theme][lobe-theme]:** The modern theme for stable diffusion webui, exquisite interface design, highly customizable UI, and efficiency-boosting features.
|
|
319
335
|
- **[🌏 Lobe i18n][lobe-i18n] :** Lobe i18n is an automation tool for the i18n (internationalization) translation process, powered by ChatGPT. It supports features such as automatic splitting of large files, incremental updates, and customization options for the OpenAI model, API proxy, and temperature.
|
|
320
|
-
- **[💌 Lobe Commit][lobe-commit]
|
|
336
|
+
- **[💌 Lobe Commit][lobe-commit]:** Lobe Commit is a CLI tool that leverages Langchain/ChatGPT to generate Gitmoji-based commit messages.
|
|
321
337
|
|
|
322
338
|
<div align="right">
|
|
323
339
|
|
|
@@ -355,13 +371,16 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
355
371
|
[codespaces-shield]: https://github.com/codespaces/badge.svg
|
|
356
372
|
[contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-chat
|
|
357
373
|
[contributors-link]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
|
358
|
-
[deploy-button-image]: https://vercel.com/button
|
|
359
374
|
[deploy-link]: https://vercel.com/new/clone?repository-link=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%20&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
|
|
360
375
|
[discord-link]: https://discord.gg/AYFPHvv2jT
|
|
361
376
|
[discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
|
|
362
377
|
[discord-shield-badge]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=for-the-badge
|
|
378
|
+
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
379
|
+
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
|
|
363
380
|
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
364
381
|
[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
|
|
382
|
+
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
383
|
+
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
|
|
365
384
|
[fc-link]: https://sspai.com/post/81986
|
|
366
385
|
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
|
367
386
|
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
package/README.zh-CN.md
CHANGED
|
@@ -49,8 +49,9 @@ LobeChat 是一个开源的、可扩展的([Function Calling][fc-link])高
|
|
|
49
49
|
- [📸 快照预览](#-快照预览)
|
|
50
50
|
- [⚡️ 性能测试](#️-性能测试)
|
|
51
51
|
- [🛳 开箱即用](#-开箱即用)
|
|
52
|
-
- [
|
|
53
|
-
- [使用 Docker 部署](
|
|
52
|
+
- [`A` 使用 Vercel 部署](#a-使用-vercel-部署)
|
|
53
|
+
- [`B` 使用 Docker 部署](#b-使用-docker-部署)
|
|
54
|
+
- [环境变量](#环境变量)
|
|
54
55
|
- [📦 生态系统](#-生态系统)
|
|
55
56
|
- [🧩 插件体系](#-插件体系)
|
|
56
57
|
- [⌨️ 本地开发](#️-本地开发)
|
|
@@ -177,56 +178,71 @@ LobeChat 提供了两种独特的主题模式 - 明亮模式和暗黑模式,
|
|
|
177
178
|
|
|
178
179
|
## 🛳 开箱即用
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
LobeChat 提供了 Vercel 的 [自托管版本][deploy-link] 和 [Docker 镜像][docker-release-link],这使你可以在几分钟内构建自己的聊天机器人,无需任何基础知识。
|
|
181
182
|
|
|
182
|
-
|
|
183
|
+
<br/>
|
|
184
|
+
|
|
185
|
+
### `A` 使用 Vercel 部署
|
|
186
|
+
|
|
187
|
+
如果想在 Vercel 上部署该服务,可以按照以下步骤进行操作:
|
|
183
188
|
|
|
184
189
|
- 准备好你的 [OpenAI API Key](https://platform.openai.com/account/api-keys) 。
|
|
185
190
|
- 点击下方按钮开始部署: Deploy with Vercel,直接使用 GitHub 账号登录即可,记得在环境变量页填入 API Key 和页面访问密码 CODE;
|
|
186
191
|
- 部署完毕后,即可开始使用;
|
|
187
192
|
- 绑定自定义域名(可选):Vercel 分配的域名 DNS 在某些区域被污染了,绑定自定义域名即可直连。
|
|
188
193
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
[![][deploy-button-image]][deploy-link]
|
|
192
|
-
|
|
193
|
-
</div>
|
|
194
|
+
#### 保持更新
|
|
194
195
|
|
|
195
|
-
|
|
196
|
-
> 本项目提供了一些额外的配置项,使用环境变量进行设置,完整环境变量可见 [📘环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN):
|
|
196
|
+
如果你根据 README 中的一键部署步骤部署了自己的项目,你可能会发现总是被提示 “有可用更新”。这是因为 Vercel 默认为你创建新项目而非 fork 本项目,这将导致无法准确检测更新。
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
| `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
|
|
201
|
-
| `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
|
|
202
|
-
| `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
|
|
198
|
+
> **Important**\
|
|
199
|
+
> 我们建议按照 [📘 LobeChat 自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN) 步骤重新部署。
|
|
203
200
|
|
|
204
|
-
|
|
201
|
+
<br/>
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
### `B` 使用 Docker 部署
|
|
207
204
|
|
|
208
|
-
|
|
205
|
+
[![][docker-release-shield]][docker-release-link]
|
|
206
|
+
[![][docker-size-shield]][docker-size-link]
|
|
207
|
+
[![][docker-pulls-shield]][docker-pulls-link]
|
|
209
208
|
|
|
210
209
|
我们提供了 Docker 镜像,供你在自己的私有设备上部署 LobeChat 服务。使用以下命令即可使用一键启动 LobeChat 服务:
|
|
211
210
|
|
|
212
|
-
```
|
|
213
|
-
docker run -d -p 3210:3210 \
|
|
211
|
+
```fish
|
|
212
|
+
$ docker run -d -p 3210:3210 \
|
|
214
213
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
215
214
|
-e ACCESS_CODE=lobe66 \
|
|
216
215
|
lobehub/lobe-chat
|
|
217
216
|
```
|
|
218
217
|
|
|
219
|
-
|
|
218
|
+
> **Note**\
|
|
219
|
+
> 如果你需要通过代理使用 OpenAI 服务,你可以使用 `OPENAI_PROXY_URL` 环境变量来配置代理地址:
|
|
220
220
|
|
|
221
|
-
```
|
|
222
|
-
docker run -d -p 3210:3210 \
|
|
221
|
+
```fish
|
|
222
|
+
$ docker run -d -p 3210:3210 \
|
|
223
223
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
224
224
|
-e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
|
|
225
225
|
-e ACCESS_CODE=lobe66 \
|
|
226
226
|
lobehub/lobe-chat
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
> **Note**\
|
|
230
|
+
> 有关 Docker 部署的详细说明,详见 [📘 使用 Docker 部署](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
|
|
231
|
+
|
|
232
|
+
<br/>
|
|
233
|
+
|
|
234
|
+
### 环境变量
|
|
235
|
+
|
|
236
|
+
本项目提供了一些额外的配置项,使用环境变量进行设置:
|
|
237
|
+
|
|
238
|
+
| 环境变量 | 类型 | 描述 | 示例 |
|
|
239
|
+
| ------------------ | ---- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
240
|
+
| `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
|
|
241
|
+
| `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
|
|
242
|
+
| `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
|
|
243
|
+
|
|
244
|
+
> **Note**\
|
|
245
|
+
> 完整环境变量可见 [📘环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
230
246
|
|
|
231
247
|
<div align="right">
|
|
232
248
|
|
|
@@ -286,7 +302,7 @@ docker run -d -p 3210:3210 \
|
|
|
286
302
|
|
|
287
303
|
[![][bun-shield]][bun-link]
|
|
288
304
|
|
|
289
|
-
```
|
|
305
|
+
```fish
|
|
290
306
|
$ git clone https://github.com/lobehub/lobe-chat.git
|
|
291
307
|
$ cd lobe-chat
|
|
292
308
|
$ bun install
|
|
@@ -357,13 +373,16 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
357
373
|
[codespaces-shield]: https://github.com/codespaces/badge.svg
|
|
358
374
|
[contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-chat
|
|
359
375
|
[contributors-link]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
|
360
|
-
[deploy-button-image]: https://vercel.com/button
|
|
361
376
|
[deploy-link]: https://vercel.com/new/clone?repository-link=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%20&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
|
|
362
377
|
[discord-link]: https://discord.gg/AYFPHvv2jT
|
|
363
378
|
[discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
|
|
364
379
|
[discord-shield-badge]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=for-the-badge
|
|
380
|
+
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
381
|
+
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
|
|
365
382
|
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
366
383
|
[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
|
|
384
|
+
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
385
|
+
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
|
|
367
386
|
[fc-link]: https://sspai.com/post/81986
|
|
368
387
|
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
|
369
388
|
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
## 架构设计
|
|
2
|
+
|
|
3
|
+
LobeChat 是一个基于 Next.js 框架构建的 AI 会话应用,旨在提供一个 AI 生产力平台,使用户能够与 AI 进行自然语言交互。以下是 LobeChat 的架构设计介稿:
|
|
4
|
+
|
|
5
|
+
## 应用架构概览
|
|
6
|
+
|
|
7
|
+
LobeChat 的整体架构由前端、EdgeRuntime API、Agents 市场、插件市场和独立插件组成。这些组件相互协作,以提供完整的 AI 体验。
|
|
8
|
+
|
|
9
|
+
## 前端架构
|
|
10
|
+
|
|
11
|
+
LobeChat 的前端采用 Next.js 框架,利用其强大的 SSR(服务器端渲染)能力和路由功能。前端使用了一系列技术栈,包括 antd 组件库和 lobe-ui AIGC 组件库、zustand 状态管理、swr 请求库、i18next 国际化库等。这些技术栈共同支持了 LobeChat 的功能和特性。
|
|
12
|
+
|
|
13
|
+
前端架构中的组件包括 app、components、config、const、features、helpers、hooks、layout、locales、migrations、prompts、services、store、styles、types 和 utils。每个组件都有特定的职责,并与其他组件协同工作,以实现不同的功能。
|
|
14
|
+
|
|
15
|
+
## Edge Runtime API
|
|
16
|
+
|
|
17
|
+
Edge Runtime API 是 LobeChat 的核心组件之一,负责处理 AI 会话的核心逻辑。它提供了与 AI 引擎的交互接口,包括自然语言处理、意图识别和回复生成等。EdgeRuntime API 与前端进行通信,接收用户的输入并返回相应的回复。
|
|
18
|
+
|
|
19
|
+
## Agents 市场
|
|
20
|
+
|
|
21
|
+
Agents 市场是 LobeChat 的一个重要组成部分,它提供了各种不同场景的 AI Agent,用于处理特定的任务和领域。Agents 市场还提供了使用和上传 Agent 的功能,使用户能够发现其他人制作的 Agent ,也可以一键分享自己的 Agent 到市场上。
|
|
22
|
+
|
|
23
|
+
## 插件市场
|
|
24
|
+
|
|
25
|
+
插件市场是 LobeChat 的另一个关键组件,它提供了各种插件,用于扩展 LobeChat 的功能和特性。插件可以是独立的功能模块,也可以与 Agents 市场的 Agent 进行集成。在会话中,助手将自动识别用户的输入,并识别适合的插件并传递给相应的插件进行处理,并返回处理结果。
|
|
26
|
+
|
|
27
|
+
## 安全性和性能优化
|
|
28
|
+
|
|
29
|
+
LobeChat 的安全性策略包括身份验证和权限管理。用户需要进行身份验证后才能使用 LobeChat,同时根据用户的权限进行相应的操作限制。
|
|
30
|
+
|
|
31
|
+
为了优化性能,LobeChat 使用了 Next.js 的 SSR 功能,实现了快速的页面加载和响应时间。此外,还采用了一系列的性能优化措施,包括代码分割、缓存和资源压缩等。
|
|
32
|
+
|
|
33
|
+
## 开发和部署流程
|
|
34
|
+
|
|
35
|
+
LobeChat 的开发流程包括版本控制、测试、持续集成和持续部署。开发团队使用版本控制系统进行代码管理,并进行单元测试和集成测试以确保代码质量。持续集成和持续部署流程确保了代码的快速交付和部署。
|
|
36
|
+
|
|
37
|
+
以上是 LobeChat 的架构设计介绍简介,详细解释了各个组件的职责和协作方式,以及设计决策对应用功能和性能的影响。
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# LobeChat 会话 API 实现逻辑
|
|
2
|
+
|
|
3
|
+
LobeChat 的大模型 AI 实现主要依赖于 OpenAI 的 API,包括后端的核心会话 API 和前端的集成 API。接下来,我们将分别介绍后端和前端的实现思路和代码。
|
|
4
|
+
|
|
5
|
+
## 后端实现
|
|
6
|
+
|
|
7
|
+
以下代码中移除了鉴权、错误处理等逻辑,仅保留了核心的主要功能逻辑。
|
|
8
|
+
|
|
9
|
+
### 核心会话 API
|
|
10
|
+
|
|
11
|
+
在 `src/app/api/openai/chat/handler.ts` 文件中,我们定义了 `POST` 方法,该方法首先从请求中解析出 payload 数据(即客户端发送的会话内容),然后从请求中获取 OpenAI 的授权信息。之后,我们创建一个 `openai` 对象,并调用 `createChatCompletion` 方法,该方法负责发送会话请求到 OpenAI 并返回结果。
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
export const POST = async (req: Request) => {
|
|
15
|
+
const payload = await req.json();
|
|
16
|
+
|
|
17
|
+
const { apiKey, endpoint } = getOpenAIAuthFromRequest(req);
|
|
18
|
+
|
|
19
|
+
const openai = createOpenai(apiKey, endpoint);
|
|
20
|
+
|
|
21
|
+
return createChatCompletion({ openai, payload });
|
|
22
|
+
};
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 会话结果处理
|
|
26
|
+
|
|
27
|
+
在 `src/app/api/openai/chat/createChatCompletion.ts` 文件中,我们定义了 `createChatCompletion` 方法,该方法首先对 payload 数据进行预处理,然后调用 OpenAI 的 `chat.completions.create` 方法发送请求,并使用 [Vercel AI SDK](https://sdk.vercel.ai/docs) 中的 `OpenAIStream` 将返回的结果转化为流式响应。
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
|
31
|
+
|
|
32
|
+
export const createChatCompletion = async ({ payload, openai }: CreateChatCompletionOptions) => {
|
|
33
|
+
const { messages, ...params } = payload;
|
|
34
|
+
|
|
35
|
+
const formatMessages = messages.map((m) => ({
|
|
36
|
+
content: m.content,
|
|
37
|
+
name: m.name,
|
|
38
|
+
role: m.role,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
const response = await openai.chat.completions.create(
|
|
42
|
+
{
|
|
43
|
+
messages: formatMessages,
|
|
44
|
+
...params,
|
|
45
|
+
stream: true,
|
|
46
|
+
},
|
|
47
|
+
{ headers: { Accept: '*/*' } },
|
|
48
|
+
);
|
|
49
|
+
const stream = OpenAIStream(response);
|
|
50
|
+
return new StreamingTextResponse(stream);
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 前端实现
|
|
55
|
+
|
|
56
|
+
### 前端集成
|
|
57
|
+
|
|
58
|
+
在 `src/services/chatModel.ts` 文件中,我们定义了 `fetchChatModel` 方法,该方法首先对 payload 数据进行前置处理,然后发送 POST 请求到后端的 `/chat` 接口,并将请求结果返回。
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
export const fetchChatModel = (
|
|
62
|
+
{ plugins: enabledPlugins, ...params }: Partial<OpenAIStreamPayload>,
|
|
63
|
+
options?: FetchChatModelOptions,
|
|
64
|
+
) => {
|
|
65
|
+
const payload = merge(
|
|
66
|
+
{
|
|
67
|
+
model: initialLobeAgentConfig.model,
|
|
68
|
+
stream: true,
|
|
69
|
+
...initialLobeAgentConfig.params,
|
|
70
|
+
},
|
|
71
|
+
params,
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const filterFunctions: ChatCompletionFunctions[] = pluginSelectors.enabledSchema(enabledPlugins)(
|
|
75
|
+
usePluginStore.getState(),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const functions = filterFunctions.length === 0 ? undefined : filterFunctions;
|
|
79
|
+
|
|
80
|
+
return fetch(OPENAI_URLS.chat, {
|
|
81
|
+
body: JSON.stringify({ ...payload, functions }),
|
|
82
|
+
headers: createHeaderWithOpenAI({ 'Content-Type': 'application/json' }),
|
|
83
|
+
method: 'POST',
|
|
84
|
+
signal: options?.signal,
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 使用流式获取结果
|
|
90
|
+
|
|
91
|
+
在 `src/utils/fetch.ts` 文件中,我们定义了 `fetchSSE` 方法,该方法使用流式方法获取数据,当读取到新的数据块时,会调用 `onMessageHandle` 回调函数处理数据块,进而实现打字机输出效果。
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
export const fetchSSE = async (fetchFn: () => Promise<Response>, options: FetchSSEOptions = {}) => {
|
|
95
|
+
const response = await fetchFn();
|
|
96
|
+
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const chatMessageError = await getMessageError(response);
|
|
99
|
+
|
|
100
|
+
options.onErrorHandle?.(chatMessageError);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const returnRes = response.clone();
|
|
105
|
+
|
|
106
|
+
const data = response.body;
|
|
107
|
+
|
|
108
|
+
if (!data) return;
|
|
109
|
+
|
|
110
|
+
const reader = data.getReader();
|
|
111
|
+
const decoder = new TextDecoder();
|
|
112
|
+
|
|
113
|
+
let done = false;
|
|
114
|
+
|
|
115
|
+
while (!done) {
|
|
116
|
+
const { value, done: doneReading } = await reader.read();
|
|
117
|
+
done = doneReading;
|
|
118
|
+
const chunkValue = decoder.decode(value);
|
|
119
|
+
|
|
120
|
+
options.onMessageHandle?.(chunkValue);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return returnRes;
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
以上就是 LobeChat 会话 API 的核心实现。在理解了这些核心代码的基础上,便可以进一步扩展和优化 LobeChat 的 AI 功能。
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
## 如何开发一个新功能
|
|
2
|
+
|
|
3
|
+
LobeChat 基于 Next.js 框架构建,使用 TypeScript 作为主要开发语言。在开发新功能时,我们需要遵循一定的开发流程,以确保代码的质量和稳定性。大致的流程分为以下五步:
|
|
4
|
+
|
|
5
|
+
1. 路由:定义路由 (`src/app`)
|
|
6
|
+
2. 数据结构: 定义数据结构 ( `src/types` )
|
|
7
|
+
3. 业务功能实现: zustand store (`src/store`)
|
|
8
|
+
4. 页面展示:书写静态组件 / 页面 (`src/app/<new-page>/features/<new-feature>.tsx`)
|
|
9
|
+
5. 功能绑定:绑定 store 与页面的触发 (`const [state,function]= useNewStore(s=>[s.state,s.function])`)
|
|
10
|
+
|
|
11
|
+
我们以 "会话消息" 功能为例,以下是实现这个功能的简要步骤:
|
|
12
|
+
|
|
13
|
+
## 1. 定义路由
|
|
14
|
+
|
|
15
|
+
在 `src/app` 目录下,我们需要定义一个新的路由来承载 "会话消息" 页面。一般来说,我们会在 `src/app` 下创建一个新的文件夹,例如 `chat`,并且在这个文件夹中创建 `page.tsx`文件,在该文件中导出 React 组件作为页面的主体。
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// src/app/chat/page.tsx
|
|
19
|
+
import ChatPage from './features/chat';
|
|
20
|
+
|
|
21
|
+
export default ChatPage;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 2. 定义数据结构
|
|
25
|
+
|
|
26
|
+
在 `src/types` 目录下,我们需要定义 "会话消息" 的数据结构。例如,我们创建一个 `chat.ts` 文件,并在其中定义 `ChatMessage` 类型:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
// src/types/chat.ts
|
|
30
|
+
|
|
31
|
+
export type ChatMessage = {
|
|
32
|
+
id: string;
|
|
33
|
+
content: string;
|
|
34
|
+
timestamp: number;
|
|
35
|
+
sender: 'user' | 'bot';
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 3. 创建 Zustand Store
|
|
40
|
+
|
|
41
|
+
在 `src/store` 目录下,我们需要创建一个新的 Zustand Store 来管理 "会话消息" 的状态。例如,我们创建一个 `chatStore.ts` 文件,并在其中定义一个 Zustand Store:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// src/store/chatStore.ts
|
|
45
|
+
import create from 'zustand';
|
|
46
|
+
|
|
47
|
+
type ChatState = {
|
|
48
|
+
messages: ChatMessage[];
|
|
49
|
+
addMessage: (message: ChatMessage) => void;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const useChatStore = create<ChatState>((set) => ({
|
|
53
|
+
messages: [],
|
|
54
|
+
addMessage: (message) => set((state) => ({ messages: [...state.messages, message] })),
|
|
55
|
+
}));
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 4. 创建页面与组件
|
|
59
|
+
|
|
60
|
+
在 `src/app/<new-page>/features/<new-feature>.tsx` 中,我们需要创建一个新的页面或组件来显示 "会话消息"。在这个文件中,我们可以使用上面创建的 Zustand Store,以及 Ant Design 的组件来构建 UI:
|
|
61
|
+
|
|
62
|
+
```jsx
|
|
63
|
+
// src/features/chat/index.tsx
|
|
64
|
+
import { List, Typography } from 'antd';
|
|
65
|
+
import { useChatStore } from 'src/store/chatStore';
|
|
66
|
+
|
|
67
|
+
const ChatPage = () => {
|
|
68
|
+
const messages = useChatStore((state) => state.messages);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<List
|
|
72
|
+
dataSource={messages}
|
|
73
|
+
renderItem={(message) => (
|
|
74
|
+
<List.Item>
|
|
75
|
+
<Typography.Text>{message.content}</Typography.Text>
|
|
76
|
+
</List.Item>
|
|
77
|
+
)}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default ChatPage;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 5. 功能绑定
|
|
86
|
+
|
|
87
|
+
在页面或组件中,我们需要将 Zustand Store 的状态和方法绑定到 UI 上。在上面的示例中,我们已经将 `messages` 状态绑定到了列表的 `dataSource` 属性上。现在,我们还需要一个方法来添加新的消息。我们可以在 Zustand Store 中定义这个方法,然后在页面或组件中使用它:
|
|
88
|
+
|
|
89
|
+
```jsx
|
|
90
|
+
import { Button } from 'antd';
|
|
91
|
+
|
|
92
|
+
const ChatPage = () => {
|
|
93
|
+
const messages = useChatStore((state) => state.messages);
|
|
94
|
+
const addMessage = useChatStore((state) => state.addMessage);
|
|
95
|
+
|
|
96
|
+
const handleSend = () => {
|
|
97
|
+
addMessage({ id: '1', content: 'Hello, world!', timestamp: Date.now(), sender: 'user' });
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<>
|
|
102
|
+
<List
|
|
103
|
+
dataSource={messages}
|
|
104
|
+
renderItem={(message) => (
|
|
105
|
+
<List.Item>
|
|
106
|
+
<Typography.Text>{message.content}</Typography.Text>
|
|
107
|
+
</List.Item>
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
<Button onClick={handleSend}>Send</Button>
|
|
111
|
+
</>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default ChatPage;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
以上就是在 LobeChat 中实现 "会话消息" 功能的步骤。当然,在 LobeChat 的实际开发中,真实场景所面临的业务诉求和场景远比上述 demo 复杂,请根据实际情况进行开发。
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# 目录架构
|
|
2
|
+
|
|
1
3
|
LobeChat 的文件夹目录架构如下:
|
|
2
4
|
|
|
3
5
|
```bash
|
|
@@ -18,10 +20,10 @@ src
|
|
|
18
20
|
|
|
19
21
|
## app
|
|
20
22
|
|
|
21
|
-
在 `app` 文件夹中,我们将每个路由页面按照 app router 的 [Route Groups](https://nextjs.org/docs/app/building-your-application/routing/route-groups)
|
|
23
|
+
在 `app` 文件夹中,我们将每个路由页面按照 app router 的 [Route Groups](https://nextjs.org/docs/app/building-your-application/routing/route-groups) 进行组织,以此来分别处理桌面端和移动端的代码实现。以 `welcome` 页面的文件结构为例:
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
|
|
26
|
+
welcome
|
|
25
27
|
├── (desktop) # 桌面端实现
|
|
26
28
|
│ ├── features # 桌面端特有的功能
|
|
27
29
|
│ ├── index.tsx # 桌面端的主入口文件
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 资源与参考
|
|
2
|
+
|
|
3
|
+
LobeChat 的设计和开发离不开社区和生态中的优秀项目。我们在设计和开发过程中使用或参考了一些优秀的资源和指南。以下是一些主要的参考资源,供开发者在开发和学习过程中参考:
|
|
4
|
+
|
|
5
|
+
1. **OpenAI API 指南**:我们使用 OpenAI 的 API 来获取和处理 AI 的会话数据。你可以查看 [OpenAI API 指南](https://platform.openai.com/docs/api-reference/introduction) 了解更多详情。
|
|
6
|
+
|
|
7
|
+
2. **OpenAI SDK**:我们使用 OpenAI 的 Node.js SDK 来与 OpenAI 的 API 交互。你可以在 [OpenAI SDK](https://github.com/openai/openai-node) 的 GitHub 仓库中查看源码和文档。
|
|
8
|
+
|
|
9
|
+
3. **AI SDK**:我们使用 Vercel 的 AI SDK 来获取和处理 AI 的会话数据。你可以查看 [AI SDK](https://sdk.vercel.ai/docs) 的文档来了解更多详情。
|
|
10
|
+
|
|
11
|
+
4. **LangChain**:我们早期的会话功能是基于 LangChain 实现的。你可以访问 [LangChain](https://langchain.com) 来了解更多关于它的信息。
|
|
12
|
+
|
|
13
|
+
5. **Chat-Next-Web**:Chat Next Web 是一个优秀的项目,LobeChat 的部分功能、Workflow 等参考了它的实现。你可以在 [Chat-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web) 的 GitHub 仓库中查看源码和文档。
|
|
14
|
+
|
|
15
|
+
6. **Next.js 文档**:我们的项目是基于 Next.js 构建的,你可以查看 [Next.js 文档](https://nextjs.org/docs) 来了解更多关于 Next.js 的信息。
|
|
16
|
+
|
|
17
|
+
7. **FlowGPT**:FlowGPT 是目前全球最大的 Prompt 社区,LobeChat 中的一些 Agent 来自 FlowGPT 的活跃作者。你可以访问 [FlowGPT](https://flowgpt.com/) 来了解更多关于它的信息。
|
|
18
|
+
|
|
19
|
+
我们会持续更新和补充这个列表,为开发者提供更多的参考资源。
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# LobeChat 环境设置指南
|
|
2
|
+
|
|
3
|
+
欢迎阅读 LobeChat 的开发环境设置指南。
|
|
4
|
+
|
|
5
|
+
## 在线开发
|
|
6
|
+
|
|
7
|
+
如果你有 GitHub Codespaces 的使用权限,可以点击下方按钮一键进入在线开发环境:
|
|
8
|
+
|
|
9
|
+
[![][codespaces-shield]][codespaces-link]
|
|
10
|
+
|
|
11
|
+
## 本地开发
|
|
12
|
+
|
|
13
|
+
在开始开发 LobeChat 之前,你需要在本地环境中安装和配置一些必要的软件和工具。本文档将指导你完成这些步骤。
|
|
14
|
+
|
|
15
|
+
### 开发环境需求
|
|
16
|
+
|
|
17
|
+
首先,你需要安装以下软件:
|
|
18
|
+
|
|
19
|
+
- Node.js:LobeChat 是基于 Node.js 构建的,因此你需要安装 Node.js。我们建议安装最新的稳定版。
|
|
20
|
+
- Bun:我们使用 Bun 作为首选包管理器。你可以从 Bun 的官方网站上下载并安装。
|
|
21
|
+
- PNPM:我们使用 PNPM 作为辅助包管理器。你可以从 pnpm 的官方网站上下载并安装。
|
|
22
|
+
- Git:我们使用 Git 进行版本控制。你可以从 Git 的官方网站上下载并安装。
|
|
23
|
+
- IDE:你可以选择你喜欢的集成开发环境(IDE)。我们推荐使用 WebStorm,它是一款功能强大的 IDE,特别适合 TypeScript 开发。
|
|
24
|
+
|
|
25
|
+
### 项目设置
|
|
26
|
+
|
|
27
|
+
完成上述软件的安装后,你可以开始设置 LobeChat 项目了。
|
|
28
|
+
|
|
29
|
+
1. **获取代码**:首先,你需要从 GitHub 上克隆 LobeChat 的代码库。在终端中运行以下命令:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/lobehub/lobe-chat.git
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. **安装依赖**:然后,进入项目目录,并使用 bun 安装项目的依赖包:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cd lobe-chat
|
|
39
|
+
bun i
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
如果你使用 pnpm ,可以执行:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cd lobe-chat
|
|
46
|
+
pnpm i
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **启动开发服务器**:安装完依赖后,你可以启动开发服务器:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bun run dev
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
现在,你可以在浏览器中打开 `http://localhost:3010`,你应该能看到 LobeChat 的欢迎页面。这表明你已经成功地设置了开发环境。
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
在开发过程中,如果你在环境设置上遇到任何问题,或者有任何关于 LobeChat 开发的问题,欢迎随时向我们提问。我们期待看到你的贡献!
|
|
60
|
+
|
|
61
|
+
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
|
|
62
|
+
[codespaces-shield]: https://github.com/codespaces/badge.svg
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# LobeChat 测试指南
|
|
2
|
+
|
|
3
|
+
LobeChat 的测试策略包括单元测试和端到端 (E2E) 测试。下面是每种测试的详细说明:
|
|
4
|
+
|
|
5
|
+
## 单元测试
|
|
6
|
+
|
|
7
|
+
单元测试用于测试应用中的独立单元(如组件、函数、工具函数等)的功能。我们使用 [vitest][vitest-url] 进行单元测试。
|
|
8
|
+
|
|
9
|
+
要运行单元测试,可以使用以下命令:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
npm run test
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
这将运行所有的单元测试,并生成测试报告。
|
|
16
|
+
|
|
17
|
+
我们鼓励开发者在编写代码时,同时编写对应的单元测试,以确保代码的质量和稳定性。
|
|
18
|
+
|
|
19
|
+
## 🚧 端到端测试
|
|
20
|
+
|
|
21
|
+
端到端测试用于测试应用在真实环境中的功能和性能。它模拟用户的真实操作,并验证应用在不同场景下的表现。
|
|
22
|
+
|
|
23
|
+
在 LobeChat 中,目前暂时没有集成端到端测试,我们会在后续迭代中逐步引入端到端测试。
|
|
24
|
+
|
|
25
|
+
## 开发测试
|
|
26
|
+
|
|
27
|
+
### 1. 单元测试
|
|
28
|
+
|
|
29
|
+
单元测试是针对应用中的最小可测试单元进行的测试,通常是针对函数、组件或模块进行的测试。在 LobeChat 中,我们使用 [vitest][vitest-url] 进行单元测试。
|
|
30
|
+
|
|
31
|
+
#### 编写测试用例
|
|
32
|
+
|
|
33
|
+
在编写单元测试之前,您需要创建一个与被测试文件相同的目录,并将测试文件命名为 `<filename>.test.ts`。例如,如果要测试 `src/utils/formatDate.ts` 文件,测试文件应命名为 `src/utils/formatDate.test.ts`。
|
|
34
|
+
|
|
35
|
+
在测试文件中,您可以使用 `describe` 和 `it` 函数来组织和编写测试用例。`describe` 函数用于创建测试套件,`it` 函数用于编写具体的测试用例。
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { formatNumber } from './formatNumber';
|
|
39
|
+
|
|
40
|
+
describe('formatNumber', () => {
|
|
41
|
+
it('should format number with comma separator', () => {
|
|
42
|
+
const result = formatNumber(1000);
|
|
43
|
+
expect(result).toBe('1,000');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should return the same number if it is less than 1000', () => {
|
|
47
|
+
const result = formatNumber(500);
|
|
48
|
+
expect(result).toBe('500');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
在测试用例中,您可以使用 `expect` 函数来断言测试结果是否符合预期。`expect` 函数可以与各种匹配器(matchers)一起使用,例如 `toBe`、`toEqual`、`toBeTruthy` 等。
|
|
54
|
+
|
|
55
|
+
#### 运行单元测试
|
|
56
|
+
|
|
57
|
+
通过运行以下命令来执行单元测试:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
npm run test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
这将运行所有的单元测试,并输出测试结果。
|
|
64
|
+
|
|
65
|
+
## 测试策略
|
|
66
|
+
|
|
67
|
+
为了编写有效的测试用例,您可以考虑以下测试策略:
|
|
68
|
+
|
|
69
|
+
- **边界条件测试**:测试输入的边界条件,例如最小值、最大值、空值等。
|
|
70
|
+
- **异常情况测试**:测试处理异常情况的代码,例如错误处理、异常情况下的回退等。
|
|
71
|
+
- **功能测试**:测试应用的各个功能模块是否正常工作,包括用户交互、数据处理等。
|
|
72
|
+
- **兼容性测试**:测试应用在不同浏览器和设备上的兼容性。
|
|
73
|
+
- **性能测试**:测试应用在不同负载下的性能表现,例如响应时间、资源占用等。
|
|
74
|
+
|
|
75
|
+
同时,请确保您的测试用例具有良好的覆盖率,覆盖到应用中的关键代码和功能。
|
|
76
|
+
|
|
77
|
+
通过合理编写和执行单元测试、集成测试和端到端测试,您可以提高应用的质量和稳定性,并及时发现和修复潜在的问题。
|
|
78
|
+
|
|
79
|
+
[vitest-url]: https://vitest.dev/
|
|
@@ -1,42 +1,86 @@
|
|
|
1
|
-
# Deployment
|
|
1
|
+
# Docker Deployment Guide
|
|
2
2
|
|
|
3
3
|
[![][docker-release-shield]][docker-release-link]
|
|
4
|
+
[![][docker-size-shield]][docker-size-link]
|
|
5
|
+
[![][docker-pulls-shield]][docker-pulls-link]
|
|
4
6
|
|
|
5
|
-
We provide Docker
|
|
7
|
+
We provide [Docker Images][docker-release-link] for you to deploy LobeChat service on your private device.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Install Docker container environment
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
If already installed, skip this step.
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
**Ubuntu:**
|
|
12
14
|
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
+
```fish
|
|
16
|
+
$ apt install docker.io
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**CentOS:**
|
|
20
|
+
|
|
21
|
+
```fish
|
|
22
|
+
$ yum install docker
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Deploy container image
|
|
26
|
+
|
|
27
|
+
### `A` Command deployment (recommended)
|
|
28
|
+
|
|
29
|
+
Use the following command to start LobeChat service with one click:
|
|
30
|
+
|
|
31
|
+
```fish
|
|
32
|
+
$ docker run -d -p 3210:3210 \
|
|
15
33
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
16
34
|
-e ACCESS_CODE=lobe66 \
|
|
17
35
|
lobehub/lobe-chat
|
|
18
36
|
```
|
|
19
37
|
|
|
20
|
-
|
|
38
|
+
> **Note**
|
|
39
|
+
>
|
|
40
|
+
> - The default mapped port is `3210`. Make sure it is not occupied or manually change the port mapping.
|
|
41
|
+
> - Replace `sk-xxxx` in the above command with your own OpenAI API Key.
|
|
42
|
+
> - The password set in the official Docker image is `lobe66` by default. Replace it with your own password to improve security.
|
|
43
|
+
> - 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.
|
|
44
|
+
|
|
45
|
+
#### Use a proxy address
|
|
21
46
|
|
|
22
|
-
If you need to use OpenAI
|
|
47
|
+
If you need to use OpenAI service through a proxy, you can use the `OPENAI_PROXY_URL` environment variable to configure the proxy address:
|
|
23
48
|
|
|
24
|
-
```
|
|
25
|
-
docker run -d -p 3210:3210 \
|
|
49
|
+
```fish
|
|
50
|
+
$ docker run -d -p 3210:3210 \
|
|
26
51
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
27
52
|
-e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
|
|
28
53
|
-e ACCESS_CODE=lobe66 \
|
|
29
54
|
lobehub/lobe-chat
|
|
30
55
|
```
|
|
31
56
|
|
|
32
|
-
For a complete list of environment variables for LobeChat, please refer to the [Environment Variables](./Environment-Variable.md) section.
|
|
33
|
-
|
|
34
57
|
> **Note**\
|
|
35
|
-
>
|
|
58
|
+
> 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.
|
|
59
|
+
|
|
60
|
+
### `B` Docker Compose
|
|
36
61
|
|
|
37
|
-
|
|
62
|
+
The configuration file for using `docker-compose` is as follows:
|
|
63
|
+
|
|
64
|
+
```yml
|
|
65
|
+
version: '3.8'
|
|
66
|
+
|
|
67
|
+
services:
|
|
68
|
+
lobe-chat:
|
|
69
|
+
image: lobehub/lobe-chat
|
|
70
|
+
container_name: lobe-chat
|
|
71
|
+
ports:
|
|
72
|
+
- '3210:3210'
|
|
73
|
+
environment:
|
|
74
|
+
OPENAI_API_KEY: sk-xxxx
|
|
75
|
+
OPENAI_PROXY_URL: https://api-proxy.com/v1
|
|
76
|
+
ACCESS_CODE: lobe66
|
|
77
|
+
```
|
|
38
78
|
|
|
39
|
-
|
|
79
|
+
<!-- LINK GROUP -->
|
|
40
80
|
|
|
81
|
+
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
82
|
+
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
|
|
41
83
|
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
42
84
|
[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
|
|
85
|
+
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
86
|
+
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
|
|
@@ -1,44 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Docker 部署指引
|
|
2
2
|
|
|
3
3
|
[![][docker-release-shield]][docker-release-link]
|
|
4
|
+
[![][docker-size-shield]][docker-size-link]
|
|
5
|
+
[![][docker-pulls-shield]][docker-pulls-link]
|
|
4
6
|
|
|
5
|
-
我们提供了 Docker
|
|
7
|
+
我们提供了 [Docker 镜像][docker-release-link],供你在自己的私有设备上部署 LobeChat 服务
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## 安装 Docker 容器环境
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
如果已安装,请跳过此步
|
|
12
|
+
|
|
13
|
+
**Ubuntu**
|
|
14
|
+
|
|
15
|
+
```fish
|
|
16
|
+
$ apt install docker.io
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**CentOS**
|
|
20
|
+
|
|
21
|
+
```fish
|
|
22
|
+
$ yum install docker
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 部署容器镜像
|
|
26
|
+
|
|
27
|
+
### `A` 指令部署(推荐)
|
|
10
28
|
|
|
11
29
|
使用以下命令即可使用一键启动 LobeChat 服务:
|
|
12
30
|
|
|
13
|
-
```
|
|
14
|
-
docker run -d -p 3210:3210 \
|
|
31
|
+
```fish
|
|
32
|
+
$ docker run -d -p 3210:3210 \
|
|
15
33
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
16
34
|
-e ACCESS_CODE=lobe66 \
|
|
17
35
|
lobehub/lobe-chat
|
|
18
36
|
```
|
|
19
37
|
|
|
20
|
-
|
|
38
|
+
> **Note**
|
|
39
|
+
>
|
|
40
|
+
> - 默认映射端口为 `3210`, 请确保未被占用或手动更改端口映射
|
|
41
|
+
> - 使用你的 OpenAI API Key 替换上述命令中的 `sk-xxxx`
|
|
42
|
+
> - 官方 Docker 镜像中设定的密码默认为 `lobe66`,请将其替换为自己的密码以提升安全性
|
|
43
|
+
> - LobeChat 支持的完整环境变量列表请参考 [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN) 部分
|
|
21
44
|
|
|
22
|
-
|
|
45
|
+
#### 使用代理地址
|
|
23
46
|
|
|
24
47
|
如果你需要通过代理使用 OpenAI 服务,你可以使用 `OPENAI_PROXY_URL` 环境变量来配置代理地址:
|
|
25
48
|
|
|
26
|
-
```
|
|
27
|
-
docker run -d -p 3210:3210 \
|
|
49
|
+
```fish
|
|
50
|
+
$ docker run -d -p 3210:3210 \
|
|
28
51
|
-e OPENAI_API_KEY=sk-xxxx \
|
|
29
52
|
-e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
|
|
30
53
|
-e ACCESS_CODE=lobe66 \
|
|
31
54
|
lobehub/lobe-chat
|
|
32
55
|
```
|
|
33
56
|
|
|
34
|
-
LobeChat 支持的完整环境变量列表请参考 [环境变量](./Environment-Variable.zh-CN.md) 部分。
|
|
35
|
-
|
|
36
57
|
> **Note**\
|
|
37
58
|
> 由于官方的 Docker 镜像构建大约需要半小时左右,如果在更新部署后会出现「存在更新」的提示,可以等待镜像构建完成后再次部署。
|
|
38
59
|
|
|
39
|
-
###
|
|
60
|
+
### `B` Docker Compose
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
使用 `docker-compose` 时配置文件如下:
|
|
63
|
+
|
|
64
|
+
```yml
|
|
65
|
+
version: '3.8'
|
|
66
|
+
|
|
67
|
+
services:
|
|
68
|
+
lobe-chat:
|
|
69
|
+
image: lobehub/lobe-chat
|
|
70
|
+
container_name: lobe-chat
|
|
71
|
+
ports:
|
|
72
|
+
- '3210:3210'
|
|
73
|
+
environment:
|
|
74
|
+
OPENAI_API_KEY: sk-xxxx
|
|
75
|
+
OPENAI_PROXY_URL: https://api-proxy.com/v1
|
|
76
|
+
ACCESS_CODE: lobe66
|
|
77
|
+
```
|
|
42
78
|
|
|
79
|
+
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
80
|
+
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square
|
|
43
81
|
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
44
82
|
[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
|
|
83
|
+
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
84
|
+
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
|
package/docs/Home.md
CHANGED
|
@@ -17,6 +17,7 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
|
|
|
17
17
|
- [Environment Variables](Environment-Variable) | [环境变量](Environment-Variable.zh-CN)
|
|
18
18
|
- [Maintaining Updates with LobeChat Self-Deployment](Upstream-Sync) | [自部署保持更新](Upstream-Sync.zh-CN)
|
|
19
19
|
- [Deploying with Azure OpenAI](Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](Deploy-with-Azure-OpenAI.zh-CN)
|
|
20
|
+
- [Docker Deployment Guide](Docker-Deployment) | [Docker 部署指引](Docker-Deployment.zh-CN)
|
|
20
21
|
- [Lighthouse Report](Lighthouse) | [性能测试](Lighthouse.zh-CN)
|
|
21
22
|
|
|
22
23
|
---
|
package/docs/_Sidebar.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- [Environment Variables](Environment-Variable) | [中文](Environment-Variable.zh-CN)
|
|
10
10
|
- [Upstream Sync](Upstream-Sync) | [中文](Upstream-Sync.zh-CN)
|
|
11
11
|
- [Deploying with Azure OpenAI](Deploy-with-Azure-OpenAI) | [中文](Deploy-with-Azure-OpenAI.zh-CN)
|
|
12
|
+
- [Docker Deployment Guide](Docker-Deployment) | [中文](Docker-Deployment.zh-CN)
|
|
12
13
|
- [Lighthouse Report](Lighthouse) | [中文](Lighthouse.zh-CN)
|
|
13
14
|
|
|
14
15
|
#### 🤖 Agents
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.89.
|
|
3
|
+
"version": "0.89.5",
|
|
4
4
|
"description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@ant-design/
|
|
68
|
+
"@ant-design/icons": "^5",
|
|
69
69
|
"@emoji-mart/data": "^1",
|
|
70
70
|
"@emoji-mart/react": "^1",
|
|
71
71
|
"@icons-pack/react-simple-icons": "^9",
|
|
@@ -23,11 +23,14 @@ export const createChatCompletion = async ({ payload, openai }: CreateChatComple
|
|
|
23
23
|
// ============ 2. send api ============ //
|
|
24
24
|
|
|
25
25
|
try {
|
|
26
|
-
const response = await openai.chat.completions.create(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const response = await openai.chat.completions.create(
|
|
27
|
+
{
|
|
28
|
+
messages: formatMessages,
|
|
29
|
+
...params,
|
|
30
|
+
stream: true,
|
|
31
|
+
},
|
|
32
|
+
{ headers: { Accept: '*/*' } },
|
|
33
|
+
);
|
|
31
34
|
const stream = OpenAIStream(response);
|
|
32
35
|
return new StreamingTextResponse(stream);
|
|
33
36
|
} catch (error) {
|
|
@@ -11,6 +11,7 @@ import { DEFAULT_SETTINGS } from '@/const/settings';
|
|
|
11
11
|
import AvatarWithUpload from '@/features/AvatarWithUpload';
|
|
12
12
|
import { localeOptions } from '@/locales/options';
|
|
13
13
|
import { settingsSelectors, useGlobalStore } from '@/store/global';
|
|
14
|
+
import { usePluginStore } from '@/store/plugin';
|
|
14
15
|
import { useSessionStore } from '@/store/session';
|
|
15
16
|
import { switchLang } from '@/utils/switchLang';
|
|
16
17
|
|
|
@@ -22,6 +23,7 @@ const Common = memo(() => {
|
|
|
22
23
|
const { t } = useTranslation('setting');
|
|
23
24
|
const [form] = AntForm.useForm();
|
|
24
25
|
const clearSessions = useSessionStore((s) => s.clearSessions);
|
|
26
|
+
const resetPluginSettings = usePluginStore((s) => s.resetPluginSettings);
|
|
25
27
|
|
|
26
28
|
const settings = useGlobalStore(settingsSelectors.currentSettings, isEqual);
|
|
27
29
|
const [setThemeMode, setSettings, resetSettings] = useGlobalStore((s) => [
|
|
@@ -45,6 +47,7 @@ const Common = memo(() => {
|
|
|
45
47
|
title: t('danger.reset.confirm'),
|
|
46
48
|
});
|
|
47
49
|
}, []);
|
|
50
|
+
|
|
48
51
|
const handleClear = useCallback(() => {
|
|
49
52
|
modal.confirm({
|
|
50
53
|
cancelText: t('cancel', { ns: 'common' }),
|
|
@@ -55,6 +58,7 @@ const Common = memo(() => {
|
|
|
55
58
|
okText: t('ok', { ns: 'common' }),
|
|
56
59
|
onOk: () => {
|
|
57
60
|
clearSessions();
|
|
61
|
+
resetPluginSettings();
|
|
58
62
|
message.success(t('danger.clear.success'));
|
|
59
63
|
},
|
|
60
64
|
title: t('danger.clear.confirm'),
|
|
@@ -20,13 +20,14 @@ import { PluginDispatch, pluginManifestReducer } from './reducers/manifest';
|
|
|
20
20
|
const t = setNamespace('plugin');
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* 插件接口
|
|
24
24
|
*/
|
|
25
25
|
export interface PluginAction {
|
|
26
26
|
checkLocalEnabledPlugins: (sessions: LobeSessions) => void;
|
|
27
27
|
deletePluginSettings: (id: string) => void;
|
|
28
28
|
dispatchPluginManifest: (payload: PluginDispatch) => void;
|
|
29
29
|
fetchPluginManifest: (identifier: string) => Promise<void>;
|
|
30
|
+
resetPluginSettings: () => void;
|
|
30
31
|
updateManifestLoadingState: (key: string, value: boolean | undefined) => void;
|
|
31
32
|
updatePluginSettings: <T>(id: string, settings: Partial<T>) => void;
|
|
32
33
|
useFetchPluginList: () => SWRResponse<LobeChatPluginsMarketIndex>;
|
|
@@ -71,7 +72,6 @@ export const createPluginSlice: StateCreator<
|
|
|
71
72
|
|
|
72
73
|
set({ pluginManifestMap: nextManifest }, false, t('dispatchPluginManifest', payload));
|
|
73
74
|
},
|
|
74
|
-
|
|
75
75
|
fetchPluginManifest: async (name) => {
|
|
76
76
|
const plugin = pluginSelectors.getPluginMetaById(name)(get());
|
|
77
77
|
// 1. 校验文件
|
|
@@ -113,6 +113,9 @@ export const createPluginSlice: StateCreator<
|
|
|
113
113
|
// 4. 存储 manifest 信息
|
|
114
114
|
get().dispatchPluginManifest({ id: plugin.identifier, plugin: data, type: 'addManifest' });
|
|
115
115
|
},
|
|
116
|
+
resetPluginSettings: () => {
|
|
117
|
+
set({ pluginsSettings: {} }, false, t('resetPluginSettings'));
|
|
118
|
+
},
|
|
116
119
|
updateManifestLoadingState: (key, value) => {
|
|
117
120
|
set(
|
|
118
121
|
produce((draft) => {
|