@lobehub/chat 0.68.1 → 0.69.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.
- package/.github/workflows/wiki-sync.yml +18 -0
- package/.i18nrc.js +1 -1
- package/CHANGELOG.md +25 -0
- package/README-zh_CN.md +44 -90
- package/README.md +30 -76
- package/docs/Home.md +26 -0
- package/docs/Plugin-Development.en-US.md +262 -0
- package/docs/Plugin-Development.zh-CN.md +261 -0
- package/docs/_Footer.md +1 -0
- package/docs/_Sidebar.md +16 -0
- package/package.json +1 -1
- package/src/components/EmojiPicker/style.ts +3 -1
- package/src/components/Empty/index.tsx +6 -3
- package/src/components/Empty/style.ts +3 -0
- package/src/features/AvatarWithUpload/index.tsx +3 -1
- package/src/features/PluginDevModal/index.tsx +1 -1
- package/src/pages/_document.page.tsx +5 -6
- package/src/pages/chat/SessionList/Header.tsx +2 -0
- package/src/pages/welcome/Footer/index.tsx +3 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Wiki Sync
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
paths:
|
|
6
|
+
- 'docs/**'
|
|
7
|
+
branches:
|
|
8
|
+
- main
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
update-wiki:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
name: wiki sync
|
|
14
|
+
steps:
|
|
15
|
+
- uses: OrlovM/Wiki-Action@v1
|
|
16
|
+
with:
|
|
17
|
+
path: 'docs'
|
|
18
|
+
token: ${{ secrets.GH_TOKEN }}
|
package/.i18nrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.69.0](https://github.com/lobehub/lobe-chat/compare/v0.68.1...v0.69.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-09-06**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Add new import statement for "Flexbox" component in "Empty" component.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Add new import statement for "Flexbox" component in "Empty" component ([68db626](https://github.com/lobehub/lobe-chat/commit/68db626))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.68.1](https://github.com/lobehub/lobe-chat/compare/v0.68.0...v0.68.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-09-03**</sup>
|
package/README-zh_CN.md
CHANGED
|
@@ -53,8 +53,8 @@ LobeChat 是一个开源的、可扩展的([Function Calling][fc-url])高性
|
|
|
53
53
|
|
|
54
54
|
我们是一群充满热情的设计工程师,希望为 AIGC 提供现代化的设计组件和工具,并以开源的方式分享,以促进它们在更广泛的社区中的发展和采用,LobeChat 目前正在积极开发中,有需求或者问题,欢迎提交 [issues][issues-url]
|
|
55
55
|
|
|
56
|
-
| [![][official-shield]][official-url] | 无需安装或注册!访问我们的网站,快速体验
|
|
57
|
-
| :----------------------------------- |
|
|
56
|
+
| [![][official-shield]][official-url] | 无需安装或注册!访问我们的网站,快速体验 |
|
|
57
|
+
| :----------------------------------- | :--------------------------------------------------------------------------- |
|
|
58
58
|
| [![][discord-shield]][discord-url] | 加入我们的 Discord 社区!这是你可以与开发者和其他 LobeHub 热衷用户交流的地方 |
|
|
59
59
|
|
|
60
60
|

|
|
@@ -93,11 +93,11 @@ LobeChat 提供了 Vercel 的 [自托管版本][deploy-url]。这使你可以在
|
|
|
93
93
|
|
|
94
94
|
> **👉 提示:** 本项目提供了一些额外的配置项,使用环境变量进行设置:
|
|
95
95
|
|
|
96
|
-
| 环境变量
|
|
97
|
-
| ------------------ |
|
|
98
|
-
| `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥
|
|
96
|
+
| 环境变量 | 类型 | 描述 | 示例 |
|
|
97
|
+
| ------------------ | ---- | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
98
|
+
| `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
|
|
99
99
|
| `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn`<br/>默认值:<br/>`https://api.openai.com` |
|
|
100
|
-
| `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母
|
|
100
|
+
| `ACCESS_CODE` | 可选 | 添加访问此服务的密码,密码应为 6 位数字或字母 | `awCT74` 或 `e3@09!` |
|
|
101
101
|
|
|
102
102
|
<div align="right">
|
|
103
103
|
|
|
@@ -107,11 +107,11 @@ LobeChat 提供了 Vercel 的 [自托管版本][deploy-url]。这使你可以在
|
|
|
107
107
|
|
|
108
108
|
## 📦 生态系统
|
|
109
109
|
|
|
110
|
-
| NPM | 代码库
|
|
111
|
-
| ------------------------------ | ------------------------------------- |
|
|
112
|
-
| [@lobehub/ui][lobe-ui-url] | [lobehub/lobe-ui][lobe-ui-github] | Lobe UI 是一个专为构建 AIGC 网页应用程序而设计的开源 UI 组件库。
|
|
110
|
+
| NPM | 代码库 | 描述 | 版本 |
|
|
111
|
+
| ------------------------------ | ------------------------------------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------- |
|
|
112
|
+
| [@lobehub/ui][lobe-ui-url] | [lobehub/lobe-ui][lobe-ui-github] | Lobe UI 是一个专为构建 AIGC 网页应用程序而设计的开源 UI 组件库。 | [![][lobe-ui-shield]][lobe-ui-url] |
|
|
113
113
|
| [@lobehub/lint][lobe-lint-url] | [lobehub/lobe-lint][lobe-lint-github] | LobeLint 为 LobeHub 提供 ESlint,Stylelint,Commitlint,Prettier,Remark 和 Semantic Release 的配置。 | [![][lobe-lint-shield]][lobe-lint-url] |
|
|
114
|
-
| @lobehub/assets | [lobehub/assets][lobe-assets-github] | LobeHub 的 Logo 资源、favicon、网页字体。
|
|
114
|
+
| @lobehub/assets | [lobehub/assets][lobe-assets-github] | LobeHub 的 Logo 资源、favicon、网页字体。 | |
|
|
115
115
|
|
|
116
116
|
<div align="right">
|
|
117
117
|
|
|
@@ -129,11 +129,11 @@ LobeChat 提供了 Vercel 的 [自托管版本][deploy-url]。这使你可以在
|
|
|
129
129
|
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]:LobeChat 插件 SDK 可帮助您创建出色的 Lobe Chat 插件。
|
|
130
130
|
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]:LobeChat 插件网关是一个后端服务,作为 LobeChat 插件的网关。我们使用 Vercel 部署此服务。主要的 API POST /api/v1/runner 被部署为 Edge Function。
|
|
131
131
|
|
|
132
|
-
| 官方插件 | 描述
|
|
133
|
-
|
|
|
134
|
-
| [搜索引擎][chat-plugin-search-engine] | 此插件允许使用 SerpApi 搜索引擎。
|
|
132
|
+
| 官方插件 | 描述 |
|
|
133
|
+
| ---------------------------------------- | ---------------------------------------------------------------------------- |
|
|
134
|
+
| [搜索引擎][chat-plugin-search-engine] | 此插件允许使用 SerpApi 搜索引擎。 |
|
|
135
135
|
| [实时天气][chat-plugin-realtime-weather] | 此插件通过获取实时天气数据提供实用的天气信息,并可以根据用户的位置自动更新。 |
|
|
136
|
-
| [网站爬虫][chat-plugin-web-crawler] | 此插件自动爬取指定 URL 网页的主要内容,并将其用作上下文输入。
|
|
136
|
+
| [网站爬虫][chat-plugin-web-crawler] | 此插件自动爬取指定 URL 网页的主要内容,并将其用作上下文输入。 |
|
|
137
137
|
|
|
138
138
|
<div align="right">
|
|
139
139
|
|
|
@@ -215,92 +215,46 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
215
215
|
|
|
216
216
|
<!-- LINK GROUP -->
|
|
217
217
|
|
|
218
|
-
[official-shield]: https://img.shields.io/website?down_message=offline&label=🤯%20Try%20LobeChat&up_message=online&url=https%3A%2F%2Flobe-chat.vercel.app&style=for-the-badge
|
|
219
|
-
[official-url]: https://lobe-chat.vercel.app
|
|
220
|
-
[discord-shield]: https://dcbadge.vercel.app/api/server/AYFPHvv2jT?style=for-the-badge
|
|
221
|
-
[discord-url]: https://discord.gg/AYFPHvv2jT
|
|
222
|
-
[fc-url]: https://sspai.com/post/81986
|
|
223
|
-
[profile-url]: https://github.com/lobehub
|
|
224
|
-
[issues-url]: https://github.com/lobehub/lobe-chat/issues/new/choose
|
|
225
|
-
[project-url]: https://github.com/lobehub/lobe-chat/projects
|
|
226
|
-
[gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-chat
|
|
227
|
-
|
|
228
|
-
<!-- SHIELD LINK GROUP -->
|
|
229
|
-
|
|
230
218
|
[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
|
|
237
|
-
<!-- releaseDate -->
|
|
238
|
-
|
|
239
|
-
[release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?style=flat
|
|
240
|
-
[release-date-url]: https://github.com/lobehub/lobe-chat/releases
|
|
241
|
-
|
|
242
|
-
<!-- ciTest -->
|
|
243
|
-
|
|
244
|
-
[ci-test-shield]: https://github.com/lobehub/lobe-chat/workflows/Test%20CI/badge.svg
|
|
245
|
-
[ci-test-url]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
|
|
246
|
-
|
|
247
|
-
<!-- ciRelease -->
|
|
248
|
-
|
|
219
|
+
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
|
|
220
|
+
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
|
221
|
+
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
|
|
222
|
+
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
|
|
223
|
+
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
|
249
224
|
[ci-release-shield]: https://github.com/lobehub/lobe-chat/workflows/Release%20CI/badge.svg
|
|
250
225
|
[ci-release-url]: https://github.com/lobehub/lobe-chat/actions?query=workflow%3ARelease%20CI
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
226
|
+
[ci-test-shield]: https://github.com/lobehub/lobe-chat/workflows/Test%20CI/badge.svg
|
|
227
|
+
[ci-test-url]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
|
|
254
228
|
[contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-chat.svg?style=flat
|
|
255
229
|
[contributors-url]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
230
|
+
[deploy-button-image]: https://vercel.com/button
|
|
231
|
+
[deploy-url]: https://vercel.com/new/clone?repository-url=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
|
|
232
|
+
[discord-shield]: https://dcbadge.vercel.app/api/server/AYFPHvv2jT?style=for-the-badge
|
|
233
|
+
[discord-url]: https://discord.gg/AYFPHvv2jT
|
|
234
|
+
[fc-url]: https://sspai.com/post/81986
|
|
259
235
|
[forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-chat.svg?style=flat
|
|
260
236
|
[forks-url]: https://github.com/lobehub/lobe-chat/network/members
|
|
261
|
-
|
|
262
|
-
<!-- stargazers -->
|
|
263
|
-
|
|
264
|
-
[stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat.svg?style=flat
|
|
265
|
-
[stargazers-url]: https://github.com/lobehub/lobe-chat/stargazers
|
|
266
|
-
|
|
267
|
-
<!-- issues -->
|
|
268
|
-
|
|
237
|
+
[gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-chat
|
|
269
238
|
[issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
|
270
239
|
[issues-url]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
|
271
|
-
|
|
272
|
-
<!-- deploy -->
|
|
273
|
-
|
|
274
|
-
[deploy-button-image]: https://vercel.com/button
|
|
275
|
-
[deploy-url]: https://vercel.com/new/clone?repository-url=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
|
|
276
|
-
|
|
277
|
-
<!-- @lobe/assets -->
|
|
278
|
-
|
|
279
240
|
[lobe-assets-github]: https://github.com/lobehub/lobe-assets
|
|
280
|
-
|
|
281
|
-
<!-- @lobehub/ui -->
|
|
282
|
-
|
|
283
|
-
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
|
|
284
|
-
[lobe-ui-url]: https://www.npmjs.com/package/@lobehub/ui
|
|
285
|
-
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
|
286
|
-
|
|
287
|
-
<!-- @lobehub/lint -->
|
|
288
|
-
|
|
289
|
-
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?label=%F0%9F%A4%AF%20NPM
|
|
290
|
-
[lobe-lint-url]: https://www.npmjs.com/package/@lobehub/lint
|
|
291
|
-
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
|
292
|
-
|
|
293
|
-
<!-- plugins -->
|
|
294
|
-
|
|
295
241
|
[lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
|
|
296
|
-
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
|
297
|
-
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
|
298
|
-
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
|
|
299
|
-
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
|
|
300
|
-
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
|
|
301
|
-
|
|
302
|
-
<!-- products -->
|
|
303
|
-
|
|
304
|
-
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
|
305
242
|
[lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
|
|
306
243
|
[lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
|
|
244
|
+
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
|
245
|
+
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?label=%F0%9F%A4%AF%20NPM
|
|
246
|
+
[lobe-lint-url]: https://www.npmjs.com/package/@lobehub/lint
|
|
247
|
+
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
|
248
|
+
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
|
249
|
+
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
|
|
250
|
+
[lobe-ui-url]: https://www.npmjs.com/package/@lobehub/ui
|
|
251
|
+
[official-shield]: https://img.shields.io/website?down_message=offline&label=🤯%20Try%20LobeChat&up_message=online&url=https%3A%2F%2Flobe-chat.vercel.app&style=for-the-badge
|
|
252
|
+
[official-url]: https://lobe-chat.vercel.app
|
|
253
|
+
[profile-url]: https://github.com/lobehub
|
|
254
|
+
[project-url]: https://github.com/lobehub/lobe-chat/projects
|
|
255
|
+
[release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?style=flat
|
|
256
|
+
[release-date-url]: https://github.com/lobehub/lobe-chat/releases
|
|
257
|
+
[release-shield]: https://img.shields.io/npm/v/@lobehub/chat?label=%F0%9F%A4%AF%20Chat
|
|
258
|
+
[release-url]: https://www.npmjs.com/package/@lobehub/chat
|
|
259
|
+
[stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat.svg?style=flat
|
|
260
|
+
[stargazers-url]: https://github.com/lobehub/lobe-chat/stargazers
|
package/README.md
CHANGED
|
@@ -215,92 +215,46 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
215
215
|
|
|
216
216
|
<!-- LINK GROUP -->
|
|
217
217
|
|
|
218
|
-
[official-shield]: https://img.shields.io/website?down_message=offline&label=🤯%20Try%20LobeChat&up_message=online&url=https%3A%2F%2Flobe-chat.vercel.app&style=for-the-badge
|
|
219
|
-
[official-url]: https://lobe-chat.vercel.app
|
|
220
|
-
[discord-shield]: https://dcbadge.vercel.app/api/server/AYFPHvv2jT?style=for-the-badge
|
|
221
|
-
[discord-url]: https://discord.gg/AYFPHvv2jT
|
|
222
|
-
[fc-url]: https://sspai.com/post/81986
|
|
223
|
-
[profile-url]: https://github.com/lobehub
|
|
224
|
-
[issues-url]: https://github.com/lobehub/lobe-chat/issues/new/choose
|
|
225
|
-
[project-url]: https://github.com/lobehub/lobe-chat/projects
|
|
226
|
-
[gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-chat
|
|
227
|
-
|
|
228
|
-
<!-- SHIELD LINK GROUP -->
|
|
229
|
-
|
|
230
218
|
[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
[
|
|
235
|
-
[
|
|
236
|
-
|
|
237
|
-
<!-- releaseDate -->
|
|
238
|
-
|
|
239
|
-
[release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?style=flat
|
|
240
|
-
[release-date-url]: https://github.com/lobehub/lobe-chat/releases
|
|
241
|
-
|
|
242
|
-
<!-- ciTest -->
|
|
243
|
-
|
|
244
|
-
[ci-test-shield]: https://github.com/lobehub/lobe-chat/workflows/Test%20CI/badge.svg
|
|
245
|
-
[ci-test-url]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
|
|
246
|
-
|
|
247
|
-
<!-- ciRelease -->
|
|
248
|
-
|
|
219
|
+
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
|
|
220
|
+
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
|
221
|
+
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
|
|
222
|
+
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
|
|
223
|
+
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
|
249
224
|
[ci-release-shield]: https://github.com/lobehub/lobe-chat/workflows/Release%20CI/badge.svg
|
|
250
225
|
[ci-release-url]: https://github.com/lobehub/lobe-chat/actions?query=workflow%3ARelease%20CI
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
226
|
+
[ci-test-shield]: https://github.com/lobehub/lobe-chat/workflows/Test%20CI/badge.svg
|
|
227
|
+
[ci-test-url]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
|
|
254
228
|
[contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-chat.svg?style=flat
|
|
255
229
|
[contributors-url]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
230
|
+
[deploy-button-image]: https://vercel.com/button
|
|
231
|
+
[deploy-url]: https://vercel.com/new/clone?repository-url=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
|
|
232
|
+
[discord-shield]: https://dcbadge.vercel.app/api/server/AYFPHvv2jT?style=for-the-badge
|
|
233
|
+
[discord-url]: https://discord.gg/AYFPHvv2jT
|
|
234
|
+
[fc-url]: https://sspai.com/post/81986
|
|
259
235
|
[forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-chat.svg?style=flat
|
|
260
236
|
[forks-url]: https://github.com/lobehub/lobe-chat/network/members
|
|
261
|
-
|
|
262
|
-
<!-- stargazers -->
|
|
263
|
-
|
|
264
|
-
[stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat.svg?style=flat
|
|
265
|
-
[stargazers-url]: https://github.com/lobehub/lobe-chat/stargazers
|
|
266
|
-
|
|
267
|
-
<!-- issues -->
|
|
268
|
-
|
|
237
|
+
[gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-chat
|
|
269
238
|
[issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
|
270
239
|
[issues-url]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
|
271
|
-
|
|
272
|
-
<!-- deploy -->
|
|
273
|
-
|
|
274
|
-
[deploy-button-image]: https://vercel.com/button
|
|
275
|
-
[deploy-url]: https://vercel.com/new/clone?repository-url=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
|
|
276
|
-
|
|
277
|
-
<!-- @lobe/assets -->
|
|
278
|
-
|
|
279
240
|
[lobe-assets-github]: https://github.com/lobehub/lobe-assets
|
|
280
|
-
|
|
281
|
-
<!-- @lobehub/ui -->
|
|
282
|
-
|
|
283
|
-
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
|
|
284
|
-
[lobe-ui-url]: https://www.npmjs.com/package/@lobehub/ui
|
|
285
|
-
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
|
286
|
-
|
|
287
|
-
<!-- @lobehub/lint -->
|
|
288
|
-
|
|
289
|
-
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?label=%F0%9F%A4%AF%20NPM
|
|
290
|
-
[lobe-lint-url]: https://www.npmjs.com/package/@lobehub/lint
|
|
291
|
-
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
|
292
|
-
|
|
293
|
-
<!-- plugins -->
|
|
294
|
-
|
|
295
241
|
[lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
|
|
296
|
-
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
|
297
|
-
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
|
298
|
-
[chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
|
|
299
|
-
[chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
|
|
300
|
-
[chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
|
|
301
|
-
|
|
302
|
-
<!-- products -->
|
|
303
|
-
|
|
304
|
-
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
|
305
242
|
[lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
|
|
306
243
|
[lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
|
|
244
|
+
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
|
245
|
+
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?label=%F0%9F%A4%AF%20NPM
|
|
246
|
+
[lobe-lint-url]: https://www.npmjs.com/package/@lobehub/lint
|
|
247
|
+
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
|
248
|
+
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
|
249
|
+
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?label=%F0%9F%A4%AF%20NPM
|
|
250
|
+
[lobe-ui-url]: https://www.npmjs.com/package/@lobehub/ui
|
|
251
|
+
[official-shield]: https://img.shields.io/website?down_message=offline&label=🤯%20Try%20LobeChat&up_message=online&url=https%3A%2F%2Flobe-chat.vercel.app&style=for-the-badge
|
|
252
|
+
[official-url]: https://lobe-chat.vercel.app
|
|
253
|
+
[profile-url]: https://github.com/lobehub
|
|
254
|
+
[project-url]: https://github.com/lobehub/lobe-chat/projects
|
|
255
|
+
[release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?style=flat
|
|
256
|
+
[release-date-url]: https://github.com/lobehub/lobe-chat/releases
|
|
257
|
+
[release-shield]: https://img.shields.io/npm/v/@lobehub/chat?label=%F0%9F%A4%AF%20Chat
|
|
258
|
+
[release-url]: https://www.npmjs.com/package/@lobehub/chat
|
|
259
|
+
[stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat.svg?style=flat
|
|
260
|
+
[stargazers-url]: https://github.com/lobehub/lobe-chat/stargazers
|
package/docs/Home.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
|
4
|
+
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
|
5
|
+
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/robot.webp">
|
|
6
|
+
|
|
7
|
+
<h1>Lobe Chat Wiki</h1>
|
|
8
|
+
|
|
9
|
+
LobeChat is a open-source, extensible (Function Calling), high-performance chatbot framework. <br/> It supports one-click free deployment of your private ChatGPT/LLM web application.
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
<br/>
|
|
16
|
+
|
|
17
|
+
## 🤖 Agents
|
|
18
|
+
|
|
19
|
+
- [Agent Index](https://github.com/lobehub/lobe-chat-agents)
|
|
20
|
+
|
|
21
|
+
## 🧩 Plugins
|
|
22
|
+
|
|
23
|
+
- [Plugin Index](https://github.com/lobehub/lobe-chat-plugins)
|
|
24
|
+
- [Plugin Development](Plugin-Development.en-US)
|
|
25
|
+
- [English](Plugin-Development.en-US)
|
|
26
|
+
- [简体中文](Plugin-Development.zh-CN)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# LobeChat Plugin Development
|
|
2
|
+
|
|
3
|
+
#### TOC
|
|
4
|
+
|
|
5
|
+
- [Plugin Composition](#plugin-composition)
|
|
6
|
+
|
|
7
|
+
- [Custom Plugin Workflow](#custom-plugin-workflow)
|
|
8
|
+
|
|
9
|
+
- [1. Create and Start a Plugin Project](#1-create-and-start-a-plugin-project)
|
|
10
|
+
- [2. Add the Local Plugin in LobeChat Role Settings](#2-add-the-local-plugin-in-lobechat-role-settings)
|
|
11
|
+
- [3. Test the Plugin Functionality in a Session](#3-test-the-plugin-functionality-in-a-session)
|
|
12
|
+
|
|
13
|
+
- [Local Plugin Development](#local-plugin-development)
|
|
14
|
+
|
|
15
|
+
- [Manifest](#manifest)
|
|
16
|
+
- [Project Structure](#project-structure)
|
|
17
|
+
- [Server-side](#server-side)
|
|
18
|
+
- [Plugin UI Interface](#plugin-ui-interface)
|
|
19
|
+
|
|
20
|
+
- [Plugin Deployment and Publication](#plugin-deployment-and-publication)
|
|
21
|
+
|
|
22
|
+
## Plugin Composition
|
|
23
|
+
|
|
24
|
+
A LobeChat plugin consists of the following components:
|
|
25
|
+
|
|
26
|
+
1. **Plugin Index**: Used to display basic information about the plugin, including the plugin name, description, author, version, and a link to the plugin manifest. The official plugin index can be found at [lobe-chat-plugins](https://github.com/lobehub/lobe-chat-plugins). To submit a plugin to the official plugin marketplace, you need to submit a PR to this repository.
|
|
27
|
+
2. **Plugin Manifest**: Used to describe the functionality of the plugin, including the server-side description, frontend display information, and version number. For more details about the manifest, please refer to the [manifest][manifest-docs-url].
|
|
28
|
+
3. **Plugin Services**: Used to implement the server-side and frontend modules described in the manifest:
|
|
29
|
+
|
|
30
|
+
- **Server-side**: Implement the API capabilities described in the manifest.
|
|
31
|
+
- **Frontend UI** (optional): Implement the interface described in the manifest, which will be displayed in plugin messages to provide richer information display than plain text.
|
|
32
|
+
|
|
33
|
+
## Custom Plugin Workflow
|
|
34
|
+
|
|
35
|
+
To integrate a plugin into LobeChat, you need to add and use a custom plugin in LobeChat. This section will guide you through the process.
|
|
36
|
+
|
|
37
|
+
### 1. Create and Start a Plugin Project
|
|
38
|
+
|
|
39
|
+
First, you need to create a plugin project locally. You can use the [lobe-chat-plugin-template][lobe-chat-plugin-template-url] template we have prepared:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
$ git clone https://github.com/lobehub/chat-plugin-template.git
|
|
43
|
+
$ cd chat-plugin-template
|
|
44
|
+
$ npm i
|
|
45
|
+
$ npm run dev
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
When you see `ready started server on 0.0.0.0:3400, url: http://localhost:3400`, it means that the plugin service has been successfully started locally.
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
### 2. Add the Local Plugin in LobeChat Role Settings
|
|
53
|
+
|
|
54
|
+
Next, go to LobeChat, create a new assistant, and go to its session settings page:
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
Click the "Add" button on the right side of "Plugin List" to open the custom plugin add dialog:
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
Enter `http://localhost:3400/manifest-dev.json` in the "Plugin Manifest URL" field, which is the URL of the locally started plugin manifest.
|
|
63
|
+
|
|
64
|
+
At this point, you should see that the identifier of the plugin has been automatically recognized as `chat-plugin-template`. Then fill in the remaining form fields (only the title is required) and click the "Save" button to complete the custom plugin addition.
|
|
65
|
+
|
|
66
|
+

|
|
67
|
+
|
|
68
|
+
After adding the plugin, you can see the newly added plugin in the plugin list. If you need to modify the plugin's configuration, you can click the "Settings" button to make changes.
|
|
69
|
+
|
|
70
|
+

|
|
71
|
+
|
|
72
|
+
### 3. Test the Plugin Functionality in a Session
|
|
73
|
+
|
|
74
|
+
Next, we need to test the functionality of the custom plugin.
|
|
75
|
+
|
|
76
|
+
Click the "Back" button to go back to the session area, and then send a message to the assistant: "What should I wear?" The assistant will try to ask you about your gender and current mood.
|
|
77
|
+
|
|
78
|
+

|
|
79
|
+
|
|
80
|
+
After answering, the assistant will make a plugin call to retrieve recommended clothing data based on your gender and mood from the server and push it to you. Finally, it will summarize the information in a text response.
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
After completing these steps, you have learned the basic process of adding and using a custom plugin in LobeChat.
|
|
85
|
+
|
|
86
|
+
## Local Plugin Development
|
|
87
|
+
|
|
88
|
+
In the previous workflow, we have learned how to add and use a plugin. Now let's focus on the development process of custom plugins.
|
|
89
|
+
|
|
90
|
+
### Manifest
|
|
91
|
+
|
|
92
|
+
The manifest aggregates information about how the plugin's functionality is implemented. The core fields are `api` and `ui`, which describe the server-side API capabilities and the frontend rendering interface address of the plugin, respectively.
|
|
93
|
+
|
|
94
|
+
Taking the manifest in our template as an example:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"api": [
|
|
99
|
+
{
|
|
100
|
+
"url": "http://localhost:3400/api/clothes",
|
|
101
|
+
"name": "recommendClothes",
|
|
102
|
+
"description": "Recommend clothes based on the user's mood",
|
|
103
|
+
"parameters": {
|
|
104
|
+
"properties": {
|
|
105
|
+
"mood": {
|
|
106
|
+
"description": "The user's current mood, with optional values: happy, sad, anger, fear, surprise, disgust",
|
|
107
|
+
"enums": ["happy", "sad", "anger", "fear", "surprise", "disgust"],
|
|
108
|
+
"type": "string"
|
|
109
|
+
},
|
|
110
|
+
"gender": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"enum": ["man", "woman"],
|
|
113
|
+
"description": "The gender of the user, which needs to be asked before knowing this information"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"required": ["mood", "gender"],
|
|
117
|
+
"type": "object"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"gateway": "http://localhost:3400/api/gateway",
|
|
122
|
+
"identifier": "chat-plugin-template",
|
|
123
|
+
"ui": {
|
|
124
|
+
"url": "http://localhost:3400",
|
|
125
|
+
"height": 200
|
|
126
|
+
},
|
|
127
|
+
"version": "1"
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
In this manifest, the following parts are included:
|
|
132
|
+
|
|
133
|
+
1. `identifier`: This is the unique identifier of the plugin, used to distinguish different plugins. This field needs to be globally unique.
|
|
134
|
+
2. `api`: This is an array that contains all the API interface information provided by the plugin. Each interface includes the `url`, `name`, `description`, and `parameters` fields, all of which are required. The `description` and `parameters` fields will be sent to GPT as the `functions` parameter of the [Function Call](https://sspai.com/post/81986). The parameters need to comply with the [JSON Schema](https://json-schema.org/) specification. In this example, the API interface is named `recommendClothes`, which recommends clothes based on the user's mood and gender. The parameters of the interface include the user's mood and gender, both of which are required.
|
|
135
|
+
3. `ui`: This field contains information about the plugin's user interface, indicating where LobeChat loads the frontend interface of the plugin from. Since the plugin interface loading in LobeChat is implemented based on `iframe`, you can specify the height and width of the plugin interface as needed.
|
|
136
|
+
4. `gateway`: This field specifies the gateway for LobeChat to query API interfaces. The default plugin gateway in LobeChat is a cloud service, but for custom plugins, the requests need to be sent to the local service. Therefore, by specifying the gateway in the manifest, LobeChat will directly request this address and access the local plugin service. The gateway field does not need to be specified for plugins published online.
|
|
137
|
+
5. `version`: This is the version number of the plugin, which is currently not used.
|
|
138
|
+
|
|
139
|
+
In actual development, you can modify the plugin's manifest according to your needs to declare the functionality you want to implement. For a complete introduction to each field in the manifest, please refer to: [manifest][manifest-docs-url].
|
|
140
|
+
|
|
141
|
+
### Project Structure
|
|
142
|
+
|
|
143
|
+
The [lobe-chat-plugin-template][lobe-chat-plugin-template-url] template project uses Next.js as the development framework. Its core directory structure is as follows:
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
➜ chat-plugin-template
|
|
147
|
+
├── public
|
|
148
|
+
│ └── manifest-dev.json # Manifest file
|
|
149
|
+
├── src
|
|
150
|
+
│ └── pages
|
|
151
|
+
│ │ ├── api # Next.js server-side folder
|
|
152
|
+
│ │ │ ├── clothes.ts # Implementation of the recommendClothes interface
|
|
153
|
+
│ │ │ └── gateway.ts # Local plugin proxy gateway
|
|
154
|
+
│ │ └── index.tsx # Frontend display interface
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Of course, using Next.js as the development framework in the template is just because we are familiar with Next.js and it is convenient for development. You can use any frontend framework and programming language you are familiar with as long as it can implement the functionality described in the manifest.
|
|
158
|
+
|
|
159
|
+
We also welcome contributions of plugin templates in more frameworks and languages.
|
|
160
|
+
|
|
161
|
+
### Server-side
|
|
162
|
+
|
|
163
|
+
The server-side only needs to implement the API interfaces described in the manifest. In the template, we use Vercel's [Edge Runtime](https://nextjs.org/docs/pages/api-reference/edge) as the server, which eliminates the need for operational maintenance.
|
|
164
|
+
|
|
165
|
+
#### API Implementation
|
|
166
|
+
|
|
167
|
+
For Edge Runtime, we provide the `createErrorResponse` method in `@lobehub/chat-plugin-sdk` to quickly return error responses. The currently provided error types can be found at: [PluginErrorType][plugin-error-type-url].
|
|
168
|
+
|
|
169
|
+
Here is an example of the clothes API implementation in the template:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
export default async (req: Request) => {
|
|
173
|
+
if (req.method !== 'POST') return createErrorResponse(PluginErrorType.MethodNotAllowed);
|
|
174
|
+
|
|
175
|
+
const { gender, mood } = (await req.json()) as RequestData;
|
|
176
|
+
|
|
177
|
+
const clothes = gender === 'man' ? manClothes : womanClothes;
|
|
178
|
+
|
|
179
|
+
const result: ResponseData = {
|
|
180
|
+
clothes: clothes[mood] || [],
|
|
181
|
+
mood,
|
|
182
|
+
today: Date.now(),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return new Response(JSON.stringify(result));
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
In this example, `manClothes` and `womanClothes` are hardcoded mock data. In actual scenarios, they can be replaced with database queries.
|
|
190
|
+
|
|
191
|
+
#### Gateway
|
|
192
|
+
|
|
193
|
+
Since the default plugin gateway in LobeChat is a cloud service (<https://chat.lobehub.com/api/plugins>), which sends requests to the API addresses specified in the manifest to solve the cross-origin issue.
|
|
194
|
+
|
|
195
|
+
For custom plugins, the requests need to be sent to the local service. Therefore, by specifying the gateway in the manifest (<http://localhost:3400/api/gateway>), LobeChat will directly request this address. Then you only need to create a gateway implementation at this address.
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import { createLobeChatPluginGateway } from '@lobehub/chat-plugins-gateway';
|
|
199
|
+
|
|
200
|
+
export const config = {
|
|
201
|
+
runtime: 'edge',
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default async createLobeChatPluginGateway();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
[`@lobehub/chat-plugins-gateway`](https://github.com/lobehub/chat-plugins-gateway) includes the implementation of the plugin gateway in LobeChat, which you can use to create a gateway. This allows LobeChat to access the local plugin service.
|
|
208
|
+
|
|
209
|
+
### Plugin UI Interface
|
|
210
|
+
|
|
211
|
+
For a plugin, the UI interface is optional. For example, the [Web Crawler](https://github.com/lobehub/chat-plugin-web-crawler) plugin does not provide a corresponding user interface.
|
|
212
|
+
|
|
213
|
+

|
|
214
|
+
|
|
215
|
+
If you want to display richer information in plugin messages or include some rich interactions, you can define a user interface for the plugin. For example, the following image shows the user interface of a search engine plugin.
|
|
216
|
+
|
|
217
|
+

|
|
218
|
+
|
|
219
|
+
#### Plugin UI Interface Implementation
|
|
220
|
+
|
|
221
|
+
LobeChat uses `iframe` + `postMessage` to load and communicate with plugin UI. Therefore, the implementation of the plugin UI is the same as normal web development. You can use any frontend framework and programming language you are familiar with.
|
|
222
|
+
|
|
223
|
+

|
|
224
|
+
|
|
225
|
+
In our template, we use React + Next.js + antd as the frontend framework. You can find the implementation of the user interface in `src/pages/index.tsx`.
|
|
226
|
+
|
|
227
|
+
Regarding plugin communication, we provide related methods in [`@lobehub/chat-plugin-sdk`](https://github.com/lobehub/chat-plugin-sdk) to simplify the communication between the plugin and LobeChat. You can use the `fetchPluginMessage` method to actively retrieve the data of the current message from LobeChat. For a detailed description of this method, please refer to: [fetchPluginMessage][fetch-plugin-message-url].
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { fetchPluginMessage } from '@lobehub/chat-plugin-sdk';
|
|
231
|
+
import { memo, useEffect, useState } from 'react';
|
|
232
|
+
|
|
233
|
+
import { ResponseData } from '@/type';
|
|
234
|
+
|
|
235
|
+
const Render = memo(() => {
|
|
236
|
+
const [data, setData] = useState<ResponseData>();
|
|
237
|
+
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
// Retrieve the current plugin message from LobeChat
|
|
240
|
+
fetchPluginMessage().then((e: ResponseData) => {
|
|
241
|
+
setData(e);
|
|
242
|
+
});
|
|
243
|
+
}, []);
|
|
244
|
+
|
|
245
|
+
return <>...</>;
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
export default Render;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Plugin Deployment and Publication
|
|
252
|
+
|
|
253
|
+
After completing the plugin development, you can deploy the plugin using your preferred method. For example, you can use Vercel or package it as a Docker image for publication.
|
|
254
|
+
|
|
255
|
+
If you want more people to use your plugin, you are welcome to submit it for review in the plugin marketplace.
|
|
256
|
+
|
|
257
|
+
<!-- LINK GROUP -->
|
|
258
|
+
|
|
259
|
+
[fetch-plugin-message-url]: https://github.com/lobehub/chat-plugin-template
|
|
260
|
+
[lobe-chat-plugin-template-url]: https://github.com/lobehub/chat-plugin-template
|
|
261
|
+
[manifest-docs-url]: https://github.com/lobehub/chat-plugin-sdk/tree/master/docs/manifest.zh-CN.md
|
|
262
|
+
[plugin-error-type-url]: https://github.com/lobehub/chat-plugin-template
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# LobeChat 插件开发
|
|
2
|
+
|
|
3
|
+
#### TOC
|
|
4
|
+
|
|
5
|
+
- [插件构成](#插件构成)
|
|
6
|
+
|
|
7
|
+
- [自定义插件流程](#自定义插件流程)
|
|
8
|
+
|
|
9
|
+
- [1. 创建并启动插件项目](#1-创建并启动插件项目)
|
|
10
|
+
- [2. 在 LobeChat 角色设置中添加本地插件](#2-在-lobechat-角色设置中添加本地插件)
|
|
11
|
+
- [3. 会话测试插件功能](#3-会话测试插件功能)
|
|
12
|
+
|
|
13
|
+
- [本地插件开发](#本地插件开发)
|
|
14
|
+
|
|
15
|
+
- [manifest](#manifest)
|
|
16
|
+
- [项目结构](#项目结构)
|
|
17
|
+
- [服务端](#服务端)
|
|
18
|
+
- [插件 UI 界面](#插件-ui-界面)
|
|
19
|
+
|
|
20
|
+
- [插件部署与发布](#插件部署与发布)
|
|
21
|
+
|
|
22
|
+
## 插件构成
|
|
23
|
+
|
|
24
|
+
一个 LobeChat 的插件由以下几个部分组成:
|
|
25
|
+
|
|
26
|
+
1. **插件索引**:用于展示插件的基本信息,包括插件名称、描述、作者、版本、插件描述清单的链接,官方的插件索引地址:[lobe-chat-plugins](https://github.com/lobehub/lobe-chat-plugins)。若想上架插件到官方插件市场,需要[提交 PR](https://github.com/lobehub/lobe-chat-plugins/pulls) 到该仓库;
|
|
27
|
+
2. **插件描述清单 (manifest)**:用于描述插件的功能实现,包含了插件的服务端描述、前端展示信息、版本号等。关于 manifest 的详细介绍,详见 [manifest][manifest-docs-url];
|
|
28
|
+
3. **插件服务**:用于实现插件描述清单中所描述的服务端和前端模块,分别如下:
|
|
29
|
+
- **服务端**:需要实现 manifest 中描述的 `api` 部分的接口能力;
|
|
30
|
+
- **前端 UI**(可选):需要实现 manifest 中描述的 `ui` 部分的界面,该界面将会在插件消息中透出,进而实现比文本更加丰富地信息展示方式。
|
|
31
|
+
|
|
32
|
+
## 自定义插件流程
|
|
33
|
+
|
|
34
|
+
插件开发需要将插件集成进 LobeChat 中,因此本部分将会介绍如何在 LobeChat 中添加和使用一个自定义插件。
|
|
35
|
+
|
|
36
|
+
### 1. 创建并启动插件项目
|
|
37
|
+
|
|
38
|
+
你需要先在本地创建一个插件项目,可以使用我们准备好的 [lobe-chat-plugin-template][lobe-chat-plugin-template-url] 模板;
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
$ git clone https://github.com/lobehub/chat-plugin-template.git
|
|
42
|
+
$ cd chat-plugin-template
|
|
43
|
+
$ npm i
|
|
44
|
+
$ npm run dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
当出现 `ready started server on 0.0.0.0:3400, url: http://localhost:3400` 时,说明插件服务已经在本地启动成功。
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. 在 LobeChat 角色设置中添加本地插件
|
|
52
|
+
|
|
53
|
+
接下来进入到 LobeChat 中,创建一个新的助手,并进入它的会话设置页:
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
点击「插件列表」右侧的「添加」按钮,打开自定义插件添加弹窗:
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
在 「插件描述文件 Url 地址」中填入 `http://localhost:3400/manifest-dev.json` ,这是我们本地启动的插件描述清单地址。
|
|
62
|
+
|
|
63
|
+
此时,你应该可以看到看到插件的标识符一栏已经被自动识别为 `chat-plugin-template`。接下来你需要填写剩下的表单字段(只有标题必填),然后点击「保存」按钮,即可完成自定义插件添加。
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
完成添加后,即可在插件列表中看到刚刚添加的插件,如果需要修改插件的配置,可以点击「设置」按钮进行修改。
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
### 3. 会话测试插件功能
|
|
72
|
+
|
|
73
|
+
接来下我们需要测试下这个自定义插件的功能是否正常。
|
|
74
|
+
|
|
75
|
+
点击「返回」按钮回到会话区,然后向助手发送消息:「我应该穿什么? 」此时助手将会尝试向你询问,了解你的性别与当前的心情。
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
当回答完毕后,助手将会发起插件的调用,根据你的性别、心情,从服务端获取推荐的衣服数据,并推送给你。最后基于这些信息做一轮文本总结。
|
|
80
|
+
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
当完成这些操作后,你已经了解了添加自定义插件,并在 LobeChat 中使用的基础流程。
|
|
84
|
+
|
|
85
|
+
## 本地插件开发
|
|
86
|
+
|
|
87
|
+
在上述流程中,我们已经了解插件的添加和使用的方式,接下来重点介绍自定义插件开发的过程。
|
|
88
|
+
|
|
89
|
+
### manifest
|
|
90
|
+
|
|
91
|
+
manifest 聚合了插件功能如何实现的信息。核心的字段为 `api` 与 `ui`,分别描述了插件的服务端接口能力与前端渲染的界面地址。
|
|
92
|
+
|
|
93
|
+
以我们提供的模板中的 manifest 为例:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"api": [
|
|
98
|
+
{
|
|
99
|
+
"url": "http://localhost:3400/api/clothes",
|
|
100
|
+
"name": "recommendClothes",
|
|
101
|
+
"description": "根据用户的心情,给用户推荐他有的衣服",
|
|
102
|
+
"parameters": {
|
|
103
|
+
"properties": {
|
|
104
|
+
"mood": {
|
|
105
|
+
"description": "用户当前的心情,可选值有:开心(happy), 难过(sad),生气 (anger),害怕(fear),惊喜( surprise),厌恶 (disgust)",
|
|
106
|
+
"enums": ["happy", "sad", "anger", "fear", "surprise", "disgust"],
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"gender": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"enum": ["man", "woman"],
|
|
112
|
+
"description": "对话用户的性别,需要询问用户后才知道这个信息"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"required": ["mood", "gender"],
|
|
116
|
+
"type": "object"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"gateway": "http://localhost:3400/api/gateway",
|
|
121
|
+
"identifier": "chat-plugin-template",
|
|
122
|
+
"ui": {
|
|
123
|
+
"url": "http://localhost:3400",
|
|
124
|
+
"height": 200
|
|
125
|
+
},
|
|
126
|
+
"version": "1"
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
在这份 manifest 中,主要包含了以下几个部分:
|
|
131
|
+
|
|
132
|
+
1. `identifier`:这是插件的唯一标识符,用来区分不同的插件,这个字段需要全局唯一。
|
|
133
|
+
2. `api`:这是一个数组,包含了插件所提供的所有 API 接口信息。每个接口都包含了url、name、description和 parameters 字段,均为必填项。其中 `description` 和 `parameters` 两个字段,将会作为 [Function Call](https://sspai.com/post/81986) 的 `functions` 参数发送给 gpt, parameters 需要符合 [JSON Schema](https://json-schema.org/) 规范。 在这个例子中,api 接口名为 `recommendClothes` ,这个接口的功能是根据用户的心情和性别来推荐衣服。接口的参数包括用户的心情和性别,这两个参数都是必填项。
|
|
134
|
+
3. `ui`:这个字段包含了插件的用户界面信息,指明了 LobeChat 从哪个地址加载插件的前端界面。由于 LobeChat 插件界面加载是基于 iframe 实现的,因此可以按需指定插件界面的高度、宽度。
|
|
135
|
+
4. `gateway`:这个字段指定了 LobeChat 查询 api 接口的网关。LobeChat 默认的插件网关是云端服务,而自定义插件的请求需要发送给本地服务的,因此通过在 manifest 中指定网关,LobeChat 将会直接请求这个地址,进而访问到本地的插件服务,发布到线上的插件可以不用指定该字段。
|
|
136
|
+
5. `version`:这是插件的版本号,现阶段暂时没有作用;
|
|
137
|
+
|
|
138
|
+
在实际开发中,你可以根据自己的需求,修改插件的描述清单,声明自己想要实现的功能。 关于 manifest 各个字段的完整介绍,参见:[manifest][manifest-docs-url]。
|
|
139
|
+
|
|
140
|
+
### 项目结构
|
|
141
|
+
|
|
142
|
+
[lobe-chat-plugin-template][lobe-chat-plugin-template-url] 这个模板项目使用了 Next.js 作为开发框架,它的核心目录结构如下:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
➜ chat-plugin-template
|
|
146
|
+
├── public
|
|
147
|
+
│ └── manifest-dev.json # 描述清单文件
|
|
148
|
+
├── src
|
|
149
|
+
│ └── pages
|
|
150
|
+
│ │ ├── api # nextjs 服务端文件夹
|
|
151
|
+
│ │ │ ├── clothes.ts # recommendClothes 接口实现
|
|
152
|
+
│ │ │ └── gateway.ts # 本地插件代理网关
|
|
153
|
+
│ │ └── index.tsx # 前端展示界面
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
当然,模板使用 Next.js 作为开发框架,只是因为我们熟悉 Next.js,开发方便。你可以使用任何你熟悉的开发框架与开发语言,只要能够实现 manifest 中描述的功能即可。
|
|
157
|
+
|
|
158
|
+
同时也欢迎贡献更多框架与语言的插件模板。
|
|
159
|
+
|
|
160
|
+
### 服务端
|
|
161
|
+
|
|
162
|
+
服务端只需要实现 manifest 中描述的 api 接口即可。在模板中,我们使用了 vercel 的 [Edge Runtime](https://nextjs.org/docs/pages/api-reference/edge) 作为服务,免去运维成本。
|
|
163
|
+
|
|
164
|
+
#### api 实现
|
|
165
|
+
|
|
166
|
+
针对 Edge Runtime ,我们在 `@lobehub/chat-plugin-sdk` 提供了 `createErrorResponse` 方法,用于快速返回错误响应。目前提供的错误类型详见:[PluginErrorType][plugin-error-type-url]。
|
|
167
|
+
|
|
168
|
+
模板中的 clothes 接口实现如下:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
export default async (req: Request) => {
|
|
172
|
+
if (req.method !== 'POST') return createErrorResponse(PluginErrorType.MethodNotAllowed);
|
|
173
|
+
|
|
174
|
+
const { gender, mood } = (await req.json()) as RequestData;
|
|
175
|
+
|
|
176
|
+
const clothes = gender === 'man' ? manClothes : womanClothes;
|
|
177
|
+
|
|
178
|
+
const result: ResponseData = {
|
|
179
|
+
clothes: clothes[mood] || [],
|
|
180
|
+
mood,
|
|
181
|
+
today: Date.now(),
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return new Response(JSON.stringify(result));
|
|
185
|
+
};
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
其中 `maniClothes` 和 `womanClothes` 是写死的 mock 数据,在实际场景中,可以替换为数据库请求。
|
|
189
|
+
|
|
190
|
+
#### gateway
|
|
191
|
+
|
|
192
|
+
由于 LobeChat 默认的插件网关是云端服务(<https://chat.lobehub.com/api/plugins>),云端服务通过 manifest 上的 api 地址发送请求,以解决跨域问题。
|
|
193
|
+
|
|
194
|
+
而针对自定义插件,插件的请求需要发送给本地服务的, 因此通过在 manifest 中指定网关 (<http://localhost:3400/api/gateway>),LobeChat 将会直接请求该地址,然后只需要在该地址下创建一个网关实现即可。
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
import { createLobeChatPluginGateway } from '@lobehub/chat-plugins-gateway';
|
|
198
|
+
|
|
199
|
+
export const config = {
|
|
200
|
+
runtime: 'edge',
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export default async createLobeChatPluginGateway();
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
[`@lobehub/chat-plugins-gateway`](https://github.com/lobehub/chat-plugins-gateway) 包含了 LobeChat 中插件网关的[实现](https://github.com/lobehub/lobe-chat/blob/main/src/pages/api/plugins.api.ts),你可以直接使用该包创建网关,进而让 LobeChat 访问到本地的插件服务。
|
|
207
|
+
|
|
208
|
+
### 插件 UI 界面
|
|
209
|
+
|
|
210
|
+
对于一个插件而言,UI 界面是一个可选项。例如 [「网页内容提取」插件](https://github.com/lobehub/chat-plugin-web-crawler),就没有实现相应的用户界面。
|
|
211
|
+
|
|
212
|
+

|
|
213
|
+
|
|
214
|
+
如果你希望在插件消息中展示更加丰富的信息,或者包含一些富交互,可以为插件定义一个用户界面。例如下图,则为搜索引擎插件的用户界面。
|
|
215
|
+
|
|
216
|
+

|
|
217
|
+
|
|
218
|
+
#### 插件 UI 界面实现
|
|
219
|
+
|
|
220
|
+
LobeChat 通过 `iframe` + `postMessage` 实现插件 ui 的加载与通信。因此, 插件 UI 的实现方式与普通的网页开发一致,你可以使用任何你熟悉的前端框架与开发语言。
|
|
221
|
+
|
|
222
|
+

|
|
223
|
+
|
|
224
|
+
在我们提供的模板中,我们使用了 React + Next.js + antd 作为前端界面框架,你可以在 `src/pages/index.tsx` 中找到用户界面的实现。
|
|
225
|
+
|
|
226
|
+
其中关于插件通信,我们在 [`@lobehub/chat-plugin-sdk`](https://github.com/lobehub/chat-plugin-sdk) 提供了相关方法,用于简化插件与 LobeChat 的通信。你可以通过 `fetchPluginMessage` 方法主动向 LobeChat 获取当前消息的数据。关于该方法的详细介绍,参见:[fetchPluginMessage][fetch-plugin-message-url]。
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
import { fetchPluginMessage } from '@lobehub/chat-plugin-sdk';
|
|
230
|
+
import { memo, useEffect, useState } from 'react';
|
|
231
|
+
|
|
232
|
+
import { ResponseData } from '@/type';
|
|
233
|
+
|
|
234
|
+
const Render = memo(() => {
|
|
235
|
+
const [data, setData] = useState<ResponseData>();
|
|
236
|
+
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
// 从 LobeChat 获取当前插件的消息
|
|
239
|
+
fetchPluginMessage().then((e: ResponseData) => {
|
|
240
|
+
setData(e);
|
|
241
|
+
});
|
|
242
|
+
}, []);
|
|
243
|
+
|
|
244
|
+
return <>...</>;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
export default Render;
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## 插件部署与发布
|
|
251
|
+
|
|
252
|
+
当你完成插件的开发后,你可以使用你习惯的方式进行插件的部署。例如使用 vercel ,或者打包成 docker 发布等等。
|
|
253
|
+
|
|
254
|
+
如果你希望插件被更多人使用,欢迎将你的插件 [提交上架](https://github.com/lobehub/lobe-chat-plugins) 到插件市场。
|
|
255
|
+
|
|
256
|
+
<!-- LINK GROUP -->
|
|
257
|
+
|
|
258
|
+
[fetch-plugin-message-url]: https://github.com/lobehub/chat-plugin-template
|
|
259
|
+
[lobe-chat-plugin-template-url]: https://github.com/lobehub/chat-plugin-template
|
|
260
|
+
[manifest-docs-url]: https://github.com/lobehub/chat-plugin-sdk/tree/master/docs/manifest.zh-CN.md
|
|
261
|
+
[plugin-error-type-url]: https://github.com/lobehub/chat-plugin-template
|
package/docs/_Footer.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is the **🤯 / 🤖 Lobe Chat** wiki. [Wiki Home](https://github.com/lobehub/lobe-chat/wiki)
|
package/docs/_Sidebar.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Lobe Chat Wiki
|
|
2
|
+
|
|
3
|
+
### 🏠 Home
|
|
4
|
+
|
|
5
|
+
- [TOC](Home)
|
|
6
|
+
|
|
7
|
+
### 🤖 Agents
|
|
8
|
+
|
|
9
|
+
- [Agent Index](https://github.com/lobehub/lobe-chat-agents)
|
|
10
|
+
|
|
11
|
+
### 🧩 Plugins
|
|
12
|
+
|
|
13
|
+
- [Plugin Index](https://github.com/lobehub/lobe-chat-plugins)
|
|
14
|
+
- [Plugin Development](Plugin-Development.en-US)
|
|
15
|
+
- [English](Plugin-Development.en-US)
|
|
16
|
+
- [简体中文](Plugin-Development.zh-CN)
|
package/package.json
CHANGED
|
@@ -4,7 +4,9 @@ import chroma from 'chroma-js';
|
|
|
4
4
|
export const useStyles = createStyles(({ css, token, prefixCls }) => ({
|
|
5
5
|
avatar: css`
|
|
6
6
|
border-radius: 50%;
|
|
7
|
-
transition:
|
|
7
|
+
transition:
|
|
8
|
+
scale 400ms ${token.motionEaseOut},
|
|
9
|
+
box-shadow 100ms ${token.motionEaseOut};
|
|
8
10
|
|
|
9
11
|
&:hover {
|
|
10
12
|
box-shadow: 0 0 0 3px ${token.colorText};
|
|
@@ -2,6 +2,7 @@ import { ActionIcon, DivProps } from '@lobehub/ui';
|
|
|
2
2
|
import { X } from 'lucide-react';
|
|
3
3
|
import Image from 'next/image';
|
|
4
4
|
import { memo } from 'react';
|
|
5
|
+
import { Flexbox } from 'react-layout-kit';
|
|
5
6
|
import useMergeState from 'use-merge-value';
|
|
6
7
|
|
|
7
8
|
import { useStyles } from './style';
|
|
@@ -40,19 +41,21 @@ const Empty = memo<EmptyProps>(
|
|
|
40
41
|
const { styles } = useStyles();
|
|
41
42
|
if (!value) return null;
|
|
42
43
|
return (
|
|
43
|
-
<
|
|
44
|
+
<Flexbox className={styles.container} {...props}>
|
|
44
45
|
<ActionIcon
|
|
45
46
|
className={styles.close}
|
|
46
47
|
icon={X}
|
|
47
48
|
onClick={() => setValue(false)}
|
|
48
49
|
size={{ blockSize: 24, fontSize: 16 }}
|
|
49
50
|
/>
|
|
50
|
-
{cover &&
|
|
51
|
+
{cover && (
|
|
52
|
+
<Image alt={alt} className={styles.image} height={height} src={cover} width={width} />
|
|
53
|
+
)}
|
|
51
54
|
<div className={styles.content}>
|
|
52
55
|
{title && <h3>{title}</h3>}
|
|
53
56
|
{desc && <p className={styles.desc}>{desc}</p>}
|
|
54
57
|
</div>
|
|
55
|
-
</
|
|
58
|
+
</Flexbox>
|
|
56
59
|
);
|
|
57
60
|
},
|
|
58
61
|
);
|
|
@@ -10,7 +10,9 @@ const useStyle = createStyles(
|
|
|
10
10
|
({ css, token }) => css`
|
|
11
11
|
cursor: pointer;
|
|
12
12
|
border-radius: 50%;
|
|
13
|
-
transition:
|
|
13
|
+
transition:
|
|
14
|
+
scale 400ms ${token.motionEaseOut},
|
|
15
|
+
box-shadow 100ms ${token.motionEaseOut};
|
|
14
16
|
|
|
15
17
|
&:hover {
|
|
16
18
|
box-shadow: 0 0 0 3px ${token.colorText};
|
|
@@ -5,12 +5,11 @@ import Document, { DocumentContext, Head, Html, Main, NextScript } from 'next/do
|
|
|
5
5
|
class MyDocument extends Document {
|
|
6
6
|
static async getInitialProps(ctx: DocumentContext) {
|
|
7
7
|
const page = await ctx.renderPage({
|
|
8
|
-
enhanceApp: (App) => (props) =>
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
),
|
|
8
|
+
enhanceApp: (App) => (props) => (
|
|
9
|
+
<StyleProvider cache={extractStaticStyle.cache}>
|
|
10
|
+
<App {...props} />
|
|
11
|
+
</StyleProvider>
|
|
12
|
+
),
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
const styles = extractStaticStyle(page.html).map((item) => item.style);
|
|
@@ -63,8 +63,10 @@ const Header = memo<{ mobile?: 'navbar' | 'search' }>(({ mobile }) => {
|
|
|
63
63
|
</Flexbox>
|
|
64
64
|
<SearchBar
|
|
65
65
|
allowClear
|
|
66
|
+
enableShortKey
|
|
66
67
|
onChange={(e) => useSessionStore.setState({ searchKeywords: e.target.value })}
|
|
67
68
|
placeholder={t('searchAgentPlaceholder')}
|
|
69
|
+
shortKey={'k'}
|
|
68
70
|
spotlight
|
|
69
71
|
type={'ghost'}
|
|
70
72
|
value={keywords}
|
|
@@ -11,7 +11,9 @@ const Footer = memo(() => {
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<Flexbox align={'center'} horizontal justify={'space-between'} style={{ padding: 16 }}>
|
|
14
|
-
<span style={{ color: theme.colorTextDescription }}
|
|
14
|
+
<span style={{ color: theme.colorTextDescription }}>
|
|
15
|
+
©{new Date().getFullYear()} LobeHub
|
|
16
|
+
</span>
|
|
15
17
|
<Flexbox horizontal>
|
|
16
18
|
<ActionIcon
|
|
17
19
|
icon={DiscordIcon}
|