@lobehub/chat 0.129.1 → 0.129.3
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 +50 -0
- package/README.md +154 -85
- package/README.zh-CN.md +155 -80
- package/contributing/Basic/Add-New-Authentication-Providers.md +108 -0
- package/contributing/Basic/Add-New-Authentication-Providers.zh-CN.md +109 -0
- package/docs/self-hosting/examples/ollama.mdx +21 -0
- package/docs/self-hosting/examples/ollama.zh-CN.mdx +21 -0
- package/docs/usage/features/agent-market.mdx +9 -3
- package/docs/usage/features/agent-market.zh-CN.mdx +7 -1
- package/docs/usage/features/local-llm.mdx +5 -1
- package/docs/usage/features/local-llm.zh-CN.mdx +5 -1
- package/docs/usage/features/mobile.mdx +5 -1
- package/docs/usage/features/mobile.zh-CN.mdx +5 -1
- package/docs/usage/features/multi-ai-providers.mdx +5 -1
- package/docs/usage/features/multi-ai-providers.zh-CN.mdx +5 -1
- package/docs/usage/features/plugin-system.mdx +8 -7
- package/docs/usage/features/plugin-system.zh-CN.mdx +8 -7
- package/docs/usage/features/pwa.mdx +5 -1
- package/docs/usage/features/pwa.zh-CN.mdx +5 -1
- package/docs/usage/features/text-to-image.mdx +7 -1
- package/docs/usage/features/text-to-image.zh-CN.mdx +7 -1
- package/docs/usage/features/theme.mdx +5 -1
- package/docs/usage/features/theme.zh-CN.mdx +5 -1
- package/docs/usage/features/tts.mdx +7 -1
- package/docs/usage/features/tts.zh-CN.mdx +7 -1
- package/docs/usage/features/vision.mdx +7 -1
- package/docs/usage/features/vision.zh-CN.mdx +7 -1
- package/docs/usage/plugins/basic-usage.mdx +3 -10
- package/docs/usage/plugins/basic-usage.zh-CN.mdx +1 -7
- package/docs/usage/plugins/custom-plugin.mdx +2 -9
- package/docs/usage/plugins/custom-plugin.zh-CN.mdx +1 -7
- package/docs/usage/providers/ollama.mdx +80 -0
- package/docs/usage/providers/ollama.zh-CN.mdx +80 -0
- package/package.json +4 -4
- package/src/app/api/auth/next-auth.ts +28 -0
- package/src/components/ModelIcon/index.tsx +2 -0
- package/src/components/ModelTag/ModelIcon.tsx +2 -0
- package/src/config/modelProviders/ollama.ts +22 -0
package/README.zh-CN.md
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
<a name="readme-top"></a>
|
|
1
|
+
<div align="center"><a name="readme-top"></a>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
|
|
6
|
-
<img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
|
|
7
|
-
<img height="120" src="https://registry.npmmirror.com/@lobehub/assets-emoji-anim/1.0.0/files/assets/robot.webp">
|
|
3
|
+
[![][image-banner]][vercel-link]
|
|
8
4
|
|
|
9
5
|
<h1>Lobe Chat</h1>
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
开源、现代化设计的 ChatGPT/LLMs 聊天应用与开发框架<br/>
|
|
8
|
+
支持语音合成、多模态、可扩展的([function call][docs-functionc-call])插件系统<br/>
|
|
9
|
+
一键**免费**拥有你自己的 ChatGPT/Gemini/Ollama 应用
|
|
12
10
|
|
|
13
11
|
[English](./README.md) · **简体中文** · [更新日志](./CHANGELOG.md) · [文档][github-document-link] · [报告问题][github-issues-link] · [请求功能][github-issues-link]
|
|
14
12
|
|
|
@@ -42,8 +40,7 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
|
|
|
42
40
|
|
|
43
41
|
[![][github-trending-shield]][github-trending-url]
|
|
44
42
|
|
|
45
|
-
![]
|
|
46
|
-

|
|
43
|
+
[![][image-overview]][vercel-link]
|
|
47
44
|
|
|
48
45
|
</div>
|
|
49
46
|
|
|
@@ -54,6 +51,17 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
|
|
|
54
51
|
|
|
55
52
|
- [👋🏻 开始使用 & 交流](#-开始使用--交流)
|
|
56
53
|
- [✨ 特性一览](#-特性一览)
|
|
54
|
+
- [`1` 多模型服务商支持](#1-多模型服务商支持)
|
|
55
|
+
- [`2` 支持本地大语言模型 (LLM)](#2-支持本地大语言模型-llm)
|
|
56
|
+
- [`3` 模型视觉识别 (Model Visual)](#3-模型视觉识别-model-visual)
|
|
57
|
+
- [`4` TTS & STT 语音会话](#4-tts--stt-语音会话)
|
|
58
|
+
- [`5` Text to Image 文生图](#5-text-to-image-文生图)
|
|
59
|
+
- [`6` 插件系统 (Function Calling)](#6-插件系统-function-calling)
|
|
60
|
+
- [`7` 助手市场 (GPTs)](#7-助手市场-gpts)
|
|
61
|
+
- [`8` 渐进式 Web 应用 (PWA)](#8-渐进式-web-应用-pwa)
|
|
62
|
+
- [`9` 移动设备适配](#9-移动设备适配)
|
|
63
|
+
- [`10` 自定义主题](#10-自定义主题)
|
|
64
|
+
- [更多特性](#更多特性)
|
|
57
65
|
- [⚡️ 性能测试](#️-性能测试)
|
|
58
66
|
- [🛳 开箱即用](#-开箱即用)
|
|
59
67
|
- [`A` 使用 Vercel、Zeabur 或 Sealos 部署](#a-使用-vercelzeabur-或-sealos-部署)
|
|
@@ -64,7 +72,7 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
|
|
|
64
72
|
- [🧩 插件体系](#-插件体系)
|
|
65
73
|
- [⌨️ 本地开发](#️-本地开发)
|
|
66
74
|
- [🤝 参与贡献](#-参与贡献)
|
|
67
|
-
- [
|
|
75
|
+
- [❤ 社区赞助](#-社区赞助)
|
|
68
76
|
- [🔗 更多工具](#-更多工具)
|
|
69
77
|
|
|
70
78
|
####
|
|
@@ -75,8 +83,10 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
|
|
|
75
83
|
|
|
76
84
|
## 👋🏻 开始使用 & 交流
|
|
77
85
|
|
|
78
|
-
我们是一群充满热情的设计工程师,希望为 AIGC
|
|
79
|
-
|
|
86
|
+
我们是一群充满热情的设计工程师,希望为 AIGC 提供现代化的设计组件和工具,并以开源的方式分享。
|
|
87
|
+
同时通过 Bootstrapping 的方式,我们希望能够为开发者和用户提供一个更加开放、更加透明友好的产品生态。
|
|
88
|
+
|
|
89
|
+
不论普通用户与专业开发者 LobeHub 旨在成为所有人的 AI Agent 实验场,LobeChat 目前正在积极开发中,有需求或者问题,欢迎提交 [issues][issues-link]
|
|
80
90
|
|
|
81
91
|
| [![][vercel-shield-badge]][vercel-link] | 无需安装或注册!访问我们的网站,快速体验 |
|
|
82
92
|
| :---------------------------------------- | :--------------------------------------------------------------------------- |
|
|
@@ -86,7 +96,7 @@ LobeHub 旨在成为所有人的 AI Agent 实验场,LobeChat 目前正在积
|
|
|
86
96
|
>
|
|
87
97
|
> **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
|
|
88
98
|
|
|
89
|
-
![]
|
|
99
|
+
[![][image-star]][github-stars-link]
|
|
90
100
|
|
|
91
101
|
<details><summary><kbd>Star History</kbd></summary>
|
|
92
102
|
<picture>
|
|
@@ -97,9 +107,50 @@ LobeHub 旨在成为所有人的 AI Agent 实验场,LobeChat 目前正在积
|
|
|
97
107
|
|
|
98
108
|
## ✨ 特性一览
|
|
99
109
|
|
|
100
|
-
![]
|
|
110
|
+
[![][image-feat-privoder]][docs-feat-provider]
|
|
111
|
+
|
|
112
|
+
### `1` [多模型服务商支持][docs-feat-provider]
|
|
113
|
+
|
|
114
|
+
在 LobeChat 的不断发展过程中,我们深刻理解到在提供 AI 会话服务时模型服务商的多样性对于满足社区需求的重要性。因此,我们不再局限于单一的模型服务商,而是拓展了对多种模型服务商的支持,以便为用户提供更为丰富和多样化的会话选择。
|
|
115
|
+
|
|
116
|
+
通过这种方式,LobeChat 能够更灵活地适应不同用户的需求,同时也为开发者提供了更为广泛的选择空间。
|
|
117
|
+
|
|
118
|
+
#### 已支持的模型服务商
|
|
119
|
+
|
|
120
|
+
我们已经实现了对以下模型服务商的支持:
|
|
121
|
+
|
|
122
|
+
- **AWS Bedrock**:集成了 AWS Bedrock 服务,支持了 **Claude / LLama2** 等模型,提供了强大的自然语言处理能力。[了解更多](https://aws.amazon.com/cn/bedrock)
|
|
123
|
+
- **Google AI (Gemini Pro、Gemini Vision)**:接入了 Google 的 **Gemini** 系列模型,包括 Gemini 和 Gemini Pro,以支持更高级的语言理解和生成。[了解更多](https://deepmind.google/technologies/gemini/)
|
|
124
|
+
- **ChatGLM**:加入了智谱的 **ChatGLM** 系列模型(GLM-4/GLM-4-vision/GLM-3-turbo),为用户提供了另一种高效的会话模型选择。[了解更多](https://www.zhipuai.cn/)
|
|
125
|
+
- **Moonshot AI (月之暗面)**:集成了 Moonshot 系列模型,这是一家来自中国的创新性 AI 创业公司,旨在提供更深层次的会话理解。[了解更多](https://www.moonshot.cn/)
|
|
126
|
+
|
|
127
|
+
同时,我们也在计划支持更多的模型服务商,如 Replicate 和 Perplexity 等,以进一步丰富我们的服务商库。如果你希望让 LobeChat 支持你喜爱的服务商,欢迎加入我们的[社区讨论](https://github.com/lobehub/lobe-chat/discussions/1284)。
|
|
128
|
+
|
|
129
|
+
<div align="right">
|
|
130
|
+
|
|
131
|
+
[![][back-to-top]](#readme-top)
|
|
132
|
+
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
[![][image-feat-local]][docs-feat-local]
|
|
136
|
+
|
|
137
|
+
### `2` [支持本地大语言模型 (LLM)][docs-feat-local]
|
|
138
|
+
|
|
139
|
+
为了满足特定用户的需求,LobeChat 还基于 [Ollama](https://ollama.ai) 支持了本地模型的使用,让用户能够更灵活地使用自己的或第三方的模型。
|
|
140
|
+
|
|
141
|
+
> \[!TIP]
|
|
142
|
+
>
|
|
143
|
+
> 查阅 [📘 在 LobeChat 中使用 Ollama][docs-usage-ollama] 获得更多信息
|
|
144
|
+
|
|
145
|
+
<div align="right">
|
|
146
|
+
|
|
147
|
+
[![][back-to-top]](#readme-top)
|
|
148
|
+
|
|
149
|
+
</div>
|
|
101
150
|
|
|
102
|
-
|
|
151
|
+
[![][image-feat-vision]][docs-feat-vision]
|
|
152
|
+
|
|
153
|
+
### `3` [模型视觉识别 (Model Visual)][docs-feat-vision]
|
|
103
154
|
|
|
104
155
|
LobeChat 已经支持 OpenAI 最新的 [`gpt-4-vision`](https://platform.openai.com/docs/guides/vision) 支持视觉识别的模型,这是一个具备视觉识别能力的多模态智能。
|
|
105
156
|
用户可以轻松上传图片或者拖拽图片到对话框中,助手将能够识别图片内容,并在此基础上进行智能对话,构建更智能、更多元化的聊天场景。
|
|
@@ -112,32 +163,24 @@ LobeChat 已经支持 OpenAI 最新的 [`gpt-4-vision`](https://platform.openai.
|
|
|
112
163
|
|
|
113
164
|
</div>
|
|
114
165
|
|
|
115
|
-
![]
|
|
166
|
+
[![][image-feat-tts]][docs-feat-tts]
|
|
116
167
|
|
|
117
|
-
|
|
168
|
+
### `4` [TTS & STT 语音会话][docs-feat-tts]
|
|
118
169
|
|
|
119
170
|
LobeChat 支持文字转语音(Text-to-Speech,TTS)和语音转文字(Speech-to-Text,STT)技术,我们的应用能够将文本信息转化为清晰的语音输出,用户可以像与真人交谈一样与我们的对话代理进行交流。
|
|
120
171
|
用户可以从多种声音中选择,给助手搭配合适的音源。 同时,对于那些倾向于听觉学习或者想要在忙碌中获取信息的用户来说,TTS 提供了一个极佳的解决方案。
|
|
121
172
|
|
|
122
173
|
在 LobeChat 中,我们精心挑选了一系列高品质的声音选项 (OpenAI Audio, Microsoft Edge Speech),以满足不同地域和文化背景用户的需求。用户可以根据个人喜好或者特定场景来选择合适的语音,从而获得个性化的交流体验。
|
|
123
174
|
|
|
124
|
-
> \[!NOTE]
|
|
125
|
-
>
|
|
126
|
-
> 我们在实现该功能过程中,发现市面上并没有一款很好的 TTS 前端库。因此我们实现上耗费了很多精力,包括数据转换、音频进度管理、语音可视化等。
|
|
127
|
-
> 于是我们决定把这套实现打磨并开源出来,希望能帮助到想要实现 TTS 的开发者们,[@lobehub/tts][lobe-tts-link] 是一个使用 TS 语言开发的,高质量 TTS 工具包,支持在服务端和浏览器中使用。
|
|
128
|
-
>
|
|
129
|
-
> - **服务端**:只要使用 15 行代码,即可实现对标 OpenAI TTS 服务的高质量语音生成能力。目前支持 EdgeSpeechTTS 与 MicrosoftTTS 与 OpenAITTS、OpenAISTT。
|
|
130
|
-
> - **浏览器**:提供了高质量的 React Hooks 与可视化音频组件,支持加载、播放、暂停、拖动时间轴等常用功能,且提供了非常丰富的音轨样式调整能力。
|
|
131
|
-
|
|
132
175
|
<div align="right">
|
|
133
176
|
|
|
134
177
|
[![][back-to-top]](#readme-top)
|
|
135
178
|
|
|
136
179
|
</div>
|
|
137
180
|
|
|
138
|
-
![]
|
|
181
|
+
[![][image-feat-t2i]][docs-feat-t2i]
|
|
139
182
|
|
|
140
|
-
|
|
183
|
+
### `5` [Text to Image 文生图][docs-feat-t2i]
|
|
141
184
|
|
|
142
185
|
支持最新的文本到图片生成技术,LobeChat 现在能够让用户在与助手对话中直接调用文成图工具进行创作。
|
|
143
186
|
通过利用 [`DALL-E 3`](https://openai.com/dall-e-3)、[`MidJourney`](https://www.midjourney.com/) 和 [`Pollinations`](https://pollinations.ai/) 等 AI 工具的能力, 助手们现在可以将你的想法转化为图像。
|
|
@@ -149,25 +192,19 @@ LobeChat 支持文字转语音(Text-to-Speech,TTS)和语音转文字(Spe
|
|
|
149
192
|
|
|
150
193
|
</div>
|
|
151
194
|
|
|
152
|
-
![]
|
|
195
|
+
[![][image-feat-plugin]][docs-feat-plugin]
|
|
153
196
|
|
|
154
|
-
|
|
197
|
+
### `6` [插件系统 (Function Calling)][docs-feat-plugin]
|
|
155
198
|
|
|
156
|
-
LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地增强了 ChatGPT
|
|
157
|
-
此外,这些插件不仅局限于新闻聚合,还可以扩展到其他实用的功能,如快速检索文档、获取电商平台数据、以及其他各式各样的第三方服务。
|
|
158
|
-
|
|
159
|
-
> 通过文档了解更多 [📘 插件使用](https://chat-docs.lobehub.com/zh/usage/plugins/basic)
|
|
199
|
+
LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地增强了 ChatGPT 的实用性和灵活性。
|
|
160
200
|
|
|
161
201
|
<video controls src="https://github.com/lobehub/lobe-chat/assets/28616219/f29475a3-f346-4196-a435-41a6373ab9e2" muted="false"></video>
|
|
162
202
|
|
|
163
|
-
|
|
164
|
-
>
|
|
165
|
-
> 为了帮助开发者更好地参与到这个生态中来,我们在 [🧩 插件体系](#-插件体系) 部分提供了全面的开发资源。
|
|
166
|
-
> 这包括详尽的组件开发文档、功能齐全的软件开发工具包(SDK),以及样板文件,这些都是为了简化开发过程,降低开发者的入门门槛。
|
|
203
|
+
通过利用插件,ChatGPT 能够实现实时信息的获取和处理,例如自动获取最新新闻头条,为用户提供即时且相关的资讯。
|
|
167
204
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
>
|
|
205
|
+
此外,这些插件不仅局限于新闻聚合,还可以扩展到其他实用的功能,如快速检索文档、获取电商平台数据、以及其他各式各样的第三方服务。
|
|
206
|
+
|
|
207
|
+
> 通过文档了解更多 [📘 插件使用][docs-usage-plugin]
|
|
171
208
|
|
|
172
209
|
<!-- PLUGIN LIST -->
|
|
173
210
|
|
|
@@ -188,9 +225,9 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
188
225
|
|
|
189
226
|
</div>
|
|
190
227
|
|
|
191
|
-
![]
|
|
228
|
+
[![][image-feat-agent]][docs-feat-agent]
|
|
192
229
|
|
|
193
|
-
|
|
230
|
+
### `7` [助手市场 (GPTs)][docs-feat-agent]
|
|
194
231
|
|
|
195
232
|
在 LobeChat 的助手市场中,创作者们可以发现一个充满活力和创新的社区,它汇聚了众多精心设计的助手,这些助手不仅在工作场景中发挥着重要作用,也在学习过程中提供了极大的便利。
|
|
196
233
|
我们的市场不仅是一个展示平台,更是一个协作的空间。在这里,每个人都可以贡献自己的智慧,分享个人开发的助手。
|
|
@@ -206,12 +243,12 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
206
243
|
|
|
207
244
|
<!-- AGENT LIST -->
|
|
208
245
|
|
|
209
|
-
| 最近新增
|
|
210
|
-
|
|
|
211
|
-
| [
|
|
212
|
-
| [
|
|
213
|
-
| [
|
|
214
|
-
| [
|
|
246
|
+
| 最近新增 | 助手说明 |
|
|
247
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
248
|
+
| [LobeChat 技术文档专家](https://chat-preview.lobehub.com/market?agent=lobe-chat-developer-document-writer)<br/><sup>By **[arvinxx](https://github.com/arvinxx)** on **2024-02-22**</sup> | LobeChat 是一个 Next.js 框架构建的 AI 会话应用,我将会帮你一起书写 LobeChat 的开发文档<br/>`开发文档` `技术介绍` `next-js` `react` `lobe-chat` |
|
|
249
|
+
| [Facebook 广告撰写专家](https://chat-preview.lobehub.com/market?agent=facebook-advertising-writing-expert)<br/><sup>By **[pllz7](https://github.com/pllz7)** on **2024-02-19**</sup> | 专注于创建引人注目的标题、引人入胜的主体文本和有效的广告文案<br/>`facebook` `advertising` `writing` `expert` `ecommerce` |
|
|
250
|
+
| [Jira 故事协助工具](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-19**</sup> | 专注于将功能点子转化为全面的 Jira 故事<br/>`技术产品管理` `故事创建` `jira` |
|
|
251
|
+
| [ThinkTank360](https://chat-preview.lobehub.com/market?agent=think-tank-business-strategy)<br/><sup>By **[mikelix](https://github.com/mikelix)** on **2024-02-19**</sup> | 熟练的顾问,汲取史蒂夫・乔布斯、埃隆・马斯克、马云、柏拉图和雷・达里奥的智慧,用于决策审查、判断和建议。<br/>`创新` `智慧` `智囊团` `商业策略` |
|
|
215
252
|
|
|
216
253
|
> 📊 Total agents: [<kbd>**181**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
217
254
|
|
|
@@ -223,9 +260,9 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
223
260
|
|
|
224
261
|
</div>
|
|
225
262
|
|
|
226
|
-
![]
|
|
263
|
+
[![][image-feat-pwa]][docs-feat-pwa]
|
|
227
264
|
|
|
228
|
-
|
|
265
|
+
### `8` [渐进式 Web 应用 (PWA)][docs-feat-pwa]
|
|
229
266
|
|
|
230
267
|
我们利深知在当今多设备环境下为用户提供无缝体验的重要性。为此,我们采用了渐进式 Web 应用 [PWA](https://support.google.com/chrome/answer/9658361) 技术,
|
|
231
268
|
这是一种能够将网页应用提升至接近原生应用体验的现代 Web 技术。通过 PWA,LobeChat 能够在桌面和移动设备上提供高度优化的用户体验,同时保持轻量级和高性能的特点。
|
|
@@ -246,9 +283,9 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
246
283
|
|
|
247
284
|
</div>
|
|
248
285
|
|
|
249
|
-
![]
|
|
286
|
+
[![][image-feat-mobile]][docs-feat-mobile]
|
|
250
287
|
|
|
251
|
-
|
|
288
|
+
### `9` [移动设备适配][docs-feat-mobile]
|
|
252
289
|
|
|
253
290
|
针对移动设备进行了一系列的优化设计,以提升用户的移动体验。目前,我们正在对移动端的用户体验进行版本迭代,以实现更加流畅和直观的交互。如果您有任何建议或想法,我们非常欢迎您通过 GitHub Issues 或者 Pull Requests 提供反馈。
|
|
254
291
|
|
|
@@ -258,9 +295,9 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
258
295
|
|
|
259
296
|
</div>
|
|
260
297
|
|
|
261
|
-
![]
|
|
298
|
+
[![][image-feat-theme]][docs-feat-theme]
|
|
262
299
|
|
|
263
|
-
|
|
300
|
+
### `10` [自定义主题][docs-feat-theme]
|
|
264
301
|
|
|
265
302
|
作为设计工程师出身 LobeChat 在界面设计上十分考虑用户的个性化体验,因此引入了灵活多变的主题模式,其中包括日间的亮色模式和夜间的深色模式。
|
|
266
303
|
除了主题模式的切换,提供了一系列的颜色定制选项,允许用户根据自己的喜好来调整应用的主题色彩。无论是想要沉稳的深蓝,还是希望活泼的桃粉,或者是专业的灰白,用户都能够在 LobeChat 中找到匹配自己风格的颜色选择。
|
|
@@ -275,7 +312,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
275
312
|
|
|
276
313
|
</div>
|
|
277
314
|
|
|
278
|
-
|
|
315
|
+
### 更多特性
|
|
279
316
|
|
|
280
317
|
除了上述功能特性以外,我们的所具有的设计和技术能力将为你带来了更多使用保障:
|
|
281
318
|
|
|
@@ -303,7 +340,7 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
303
340
|
|
|
304
341
|
> \[!NOTE]
|
|
305
342
|
>
|
|
306
|
-
> 完整测试报告可见 [📘 Lighthouse 性能测试]
|
|
343
|
+
> 完整测试报告可见 [📘 Lighthouse 性能测试][docs-lighthouse]
|
|
307
344
|
|
|
308
345
|
| Desktop | Mobile |
|
|
309
346
|
| :-------------------------------------------: | :------------------------------------------: |
|
|
@@ -320,7 +357,9 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
320
357
|
|
|
321
358
|
LobeChat 提供了 Vercel 的 自托管版本 和 [Docker 镜像][docker-release-link],这使你可以在几分钟内构建自己的聊天机器人,无需任何基础知识。
|
|
322
359
|
|
|
323
|
-
|
|
360
|
+
> \[!TIP]
|
|
361
|
+
>
|
|
362
|
+
> 完整教程请查阅 [📘 构建属于自己的 Lobe Chat][docs-self-hosting]
|
|
324
363
|
|
|
325
364
|
### `A` 使用 Vercel、Zeabur 或 Sealos 部署
|
|
326
365
|
|
|
@@ -345,7 +384,7 @@ LobeChat 提供了 Vercel 的 自托管版本 和 [Docker 镜像][docker-release
|
|
|
345
384
|
|
|
346
385
|
> \[!TIP]
|
|
347
386
|
>
|
|
348
|
-
> 我们建议按照 [📘
|
|
387
|
+
> 我们建议按照 [📘 自动同步更新][docs-upstream-sync] 步骤重新部署。
|
|
349
388
|
|
|
350
389
|
<br/>
|
|
351
390
|
|
|
@@ -380,7 +419,7 @@ $ docker run -d -p 3210:3210 \
|
|
|
380
419
|
|
|
381
420
|
> \[!NOTE]
|
|
382
421
|
>
|
|
383
|
-
> 有关 Docker 部署的详细说明,详见 [📘 使用 Docker 部署]
|
|
422
|
+
> 有关 Docker 部署的详细说明,详见 [📘 使用 Docker 部署][docs-docker]
|
|
384
423
|
|
|
385
424
|
<br/>
|
|
386
425
|
|
|
@@ -397,7 +436,7 @@ $ docker run -d -p 3210:3210 \
|
|
|
397
436
|
|
|
398
437
|
> \[!NOTE]
|
|
399
438
|
>
|
|
400
|
-
> 完整环境变量可见 [
|
|
439
|
+
> 完整环境变量可见 [📘 环境变量][docs-env-var]
|
|
401
440
|
|
|
402
441
|
<br/>
|
|
403
442
|
|
|
@@ -449,12 +488,12 @@ API Key 是使用 LobeChat 进行大语言模型会话的必要信息,本节
|
|
|
449
488
|
|
|
450
489
|
## 📦 生态系统
|
|
451
490
|
|
|
452
|
-
| NPM
|
|
453
|
-
|
|
|
454
|
-
| [@lobehub/ui][lobe-ui-link]
|
|
455
|
-
| [@lobehub/
|
|
456
|
-
| [@lobehub/
|
|
457
|
-
| @lobehub/
|
|
491
|
+
| NPM | 仓库 | 描述 | 版本 |
|
|
492
|
+
| --------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
493
|
+
| [@lobehub/ui][lobe-ui-link] | [lobehub/lobe-ui][lobe-ui-github] | 构建 AIGC 网页应用程序而设计的开源 UI 组件库 | [![][lobe-ui-shield]][lobe-ui-link] |
|
|
494
|
+
| [@lobehub/icons][lobe-icons-link] | [lobehub/lobe-icons][lobe-icons-github] | 主流 AI / LLM 模型和公司 SVG Logo 与 Icon 合集 | [![][lobe-icons-shield]][lobe-icons-link] |
|
|
495
|
+
| [@lobehub/tts][lobe-tts-link] | [lobehub/lobe-tts][lobe-tts-github] | AI TTS / STT 语音合成 / 识别 React Hooks 库 | [![][lobe-tts-shield]][lobe-tts-link] |
|
|
496
|
+
| [@lobehub/lint][lobe-lint-link] | [lobehub/lobe-lint][lobe-lint-github] | LobeHub 代码样式规范 ESlint,Stylelint,Commitlint,Prettier,Remark 和 Semantic Release | [![][lobe-lint-shield]][lobe-lint-link] |
|
|
458
497
|
|
|
459
498
|
<div align="right">
|
|
460
499
|
|
|
@@ -464,12 +503,12 @@ API Key 是使用 LobeChat 进行大语言模型会话的必要信息,本节
|
|
|
464
503
|
|
|
465
504
|
## 🧩 插件体系
|
|
466
505
|
|
|
467
|
-
插件提供了扩展 LobeChat [Function Calling][
|
|
506
|
+
插件提供了扩展 LobeChat [Function Calling][docs-functionc-call] 能力的方法。可以用于引入新的 Function Calling,甚至是新的消息结果渲染方式。如果你对插件开发感兴趣,请在 Wiki 中查阅我们的 [📘 插件开发指引][docs-plugin-dev] 。
|
|
468
507
|
|
|
469
|
-
- [lobe-chat-plugins][lobe-chat-plugins]
|
|
470
|
-
- [chat-plugin-template][chat-plugin-template]
|
|
471
|
-
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]
|
|
472
|
-
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]
|
|
508
|
+
- [lobe-chat-plugins][lobe-chat-plugins]:插件索引从该仓库的 index.json 中获取插件列表并显示给用户。
|
|
509
|
+
- [chat-plugin-template][chat-plugin-template]:插件开发模版,你可以通过项目模版快速新建插件项目。
|
|
510
|
+
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]:插件 SDK 可帮助您创建出色的 Lobe Chat 插件。
|
|
511
|
+
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]:插件网关是一个后端服务,作为 LobeChat 插件的网关。我们使用 Vercel 部署此服务。主要的 API POST /api/v1/runner 被部署为 Edge Function。
|
|
473
512
|
|
|
474
513
|
> \[!NOTE]
|
|
475
514
|
>
|
|
@@ -477,7 +516,7 @@ API Key 是使用 LobeChat 进行大语言模型会话的必要信息,本节
|
|
|
477
516
|
>
|
|
478
517
|
> - [x] [**插件一期**](https://github.com/lobehub/lobe-chat/issues/73): 实现插件与主体分离,将插件拆分为独立仓库维护,并实现插件的动态加载
|
|
479
518
|
> - [x] [**插件二期**](https://github.com/lobehub/lobe-chat/issues/97): 插件的安全性与使用的稳定性,更加精准地呈现异常状态,插件架构的可维护性与开发者友好
|
|
480
|
-
> - [
|
|
519
|
+
> - [x] [**插件三期**](https://github.com/lobehub/lobe-chat/issues/149):更高阶与完善的自定义能力,支持插件鉴权与示例
|
|
481
520
|
|
|
482
521
|
<div align="right">
|
|
483
522
|
|
|
@@ -500,7 +539,7 @@ $ pnpm install
|
|
|
500
539
|
$ pnpm run dev
|
|
501
540
|
```
|
|
502
541
|
|
|
503
|
-
如果你希望了解更多详情,欢迎可以查阅我们的 [📘 开发指南]
|
|
542
|
+
如果你希望了解更多详情,欢迎可以查阅我们的 [📘 开发指南][docs-dev-guide]
|
|
504
543
|
|
|
505
544
|
<div align="right">
|
|
506
545
|
|
|
@@ -561,7 +600,7 @@ $ pnpm run dev
|
|
|
561
600
|
|
|
562
601
|
</div>
|
|
563
602
|
|
|
564
|
-
##
|
|
603
|
+
## ❤ 社区赞助
|
|
565
604
|
|
|
566
605
|
每一分支持都珍贵无比,汇聚成我们支持的璀璨银河!你就像一颗划破夜空的流星,瞬间点亮我们前行的道路。感谢你对我们的信任 —— 你的支持笔就像星辰导航,一次又一次地为项目指明前进的光芒。
|
|
567
606
|
|
|
@@ -580,9 +619,10 @@ $ pnpm run dev
|
|
|
580
619
|
|
|
581
620
|
## 🔗 更多工具
|
|
582
621
|
|
|
583
|
-
- [
|
|
584
|
-
- [
|
|
585
|
-
- [
|
|
622
|
+
- **[🅰️ Lobe SD Theme][lobe-theme]:** Stable Diffusion WebUI 的现代主题,精致的界面设计,高度可定制的 UI,以及提高效率的功能。
|
|
623
|
+
- **[⛵️ Lobe Midjourney WebUI][lobe-midjourney-webui]:** Midjourney WebUI, 能够根据文本提示快速生成丰富多样的图像,激发创造力,增强对话交流。
|
|
624
|
+
- **[🌏 Lobe i18n][lobe-i18n]:** Lobe i18n 是一个由 ChatGPT 驱动的 i18n(国际化)翻译过程的自动化工具。它支持自动分割大文件、增量更新,以及为 OpenAI 模型、API 代理和温度提供定制选项的功能。
|
|
625
|
+
- **[💌 Lobe Commit][lobe-commit]:** Lobe Commit 是一个 CLI 工具,它利用 Langchain/ChatGPT 生成基于 Gitmoji 的提交消息。
|
|
586
626
|
|
|
587
627
|
<div align="right">
|
|
588
628
|
|
|
@@ -630,7 +670,26 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
630
670
|
[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
|
|
631
671
|
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat
|
|
632
672
|
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat?color=369eff&labelColor=black&style=flat-square
|
|
633
|
-
[
|
|
673
|
+
[docs-dev-guide]: https://github.com/lobehub/lobe-chat/wiki/index
|
|
674
|
+
[docs-docker]: https://chat-docs.lobehub.com/zh/self-hosting/platform/docker
|
|
675
|
+
[docs-env-var]: https://chat-docs.lobehub.com/zh/self-hosting/environment-variables
|
|
676
|
+
[docs-feat-agent]: https://chat-docs.lobehub.com/zh/usage/features/agent-market
|
|
677
|
+
[docs-feat-local]: https://chat-docs.lobehub.com/zh/usage/features/local-llm
|
|
678
|
+
[docs-feat-mobile]: https://chat-docs.lobehub.com/zh/usage/features/mobile
|
|
679
|
+
[docs-feat-plugin]: https://chat-docs.lobehub.com/zh/usage/features/plugin-system
|
|
680
|
+
[docs-feat-provider]: https://chat-docs.lobehub.com/zh/usage/features/multi-ai-providers
|
|
681
|
+
[docs-feat-pwa]: https://chat-docs.lobehub.com/zh/usage/features/pwa
|
|
682
|
+
[docs-feat-t2i]: https://chat-docs.lobehub.com/zh/usage/features/text-to-image
|
|
683
|
+
[docs-feat-theme]: https://chat-docs.lobehub.com/zh/usage/features/theme
|
|
684
|
+
[docs-feat-tts]: https://chat-docs.lobehub.com/zh/usage/features/tts
|
|
685
|
+
[docs-feat-vision]: https://chat-docs.lobehub.com/zh/usage/features/vision
|
|
686
|
+
[docs-functionc-call]: https://platform.openai.com/docs/guides/function-calling
|
|
687
|
+
[docs-lighthouse]: https://github.com/lobehub/lobe-chat/wiki/Lighthouse.zh-CN
|
|
688
|
+
[docs-plugin-dev]: https://chat-docs.lobehub.com/zh/usage/plugins/development
|
|
689
|
+
[docs-self-hosting]: https://chat-docs.lobehub.com/zh/self-hosting/start
|
|
690
|
+
[docs-upstream-sync]: https://chat-docs.lobehub.com/zh/self-hosting/advanced/upstream-sync
|
|
691
|
+
[docs-usage-ollama]: https://chat-docs.lobehub.com/zh/usage/providers/ollama
|
|
692
|
+
[docs-usage-plugin]: https://chat-docs.lobehub.com/zh/usage/plugins/basic
|
|
634
693
|
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
|
635
694
|
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
|
636
695
|
[github-action-release-link]: https://github.com/lobehub/lobe-chat/actions/workflows/release.yml
|
|
@@ -655,14 +714,30 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
655
714
|
[github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat?color=ffcb47&labelColor=black&style=flat-square
|
|
656
715
|
[github-trending-shield]: https://trendshift.io/api/badge/repositories/2256
|
|
657
716
|
[github-trending-url]: https://trendshift.io/repositories/2256
|
|
717
|
+
[image-banner]: https://github.com/lobehub/lobe-chat/assets/28616219/9f155dff-4737-429f-9cad-a70a1a860c5f
|
|
718
|
+
[image-feat-agent]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670869-f1ffbf66-42b6-42cf-a937-9ce1f8328514.png
|
|
719
|
+
[image-feat-local]: https://github.com/lobehub/lobe-chat/assets/28616219/ca9a21bc-ea6c-4c90-bf4a-fa53b4fb2b5c
|
|
720
|
+
[image-feat-mobile]: https://gw.alipayobjects.com/zos/kitchen/R441AuFS4W/mobile.webp
|
|
721
|
+
[image-feat-plugin]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/268670883-33c43a5c-a512-467e-855c-fa299548cce5.png
|
|
722
|
+
[image-feat-privoder]: https://github.com/lobehub/lobe-chat/assets/28616219/b164bc54-8ba2-4c1e-b2f2-f4d7f7e7a551
|
|
723
|
+
[image-feat-pwa]: https://gw.alipayobjects.com/zos/kitchen/69x6bllkX3/pwa.webp
|
|
724
|
+
[image-feat-t2i]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/297746445-0ff762b9-aa08-4337-afb7-12f932b6efbb.png
|
|
725
|
+
[image-feat-theme]: https://gw.alipayobjects.com/zos/kitchen/pvus1lo%26Z7/darkmode.webp
|
|
726
|
+
[image-feat-tts]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072124-c9853d8d-f1b5-44a8-a305-45ebc0f6d19a.png
|
|
727
|
+
[image-feat-vision]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072129-382bdf30-e3d6-4411-b5a0-249710b8ba08.png
|
|
728
|
+
[image-overview]: https://github.com/lobehub/lobe-chat/assets/28616219/8b04c3c9-3d71-4fb4-bd9b-a4f415c5876d
|
|
729
|
+
[image-star]: https://github.com/lobehub/lobe-chat/assets/17870709/cb06b748-513f-47c2-8740-d876858d7855
|
|
658
730
|
[issues-link]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
|
659
|
-
[lobe-assets-github]: https://github.com/lobehub/lobe-assets
|
|
660
731
|
[lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
|
|
661
732
|
[lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
|
|
662
733
|
[lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
|
|
734
|
+
[lobe-icons-github]: https://github.com/lobehub/lobe-icons
|
|
735
|
+
[lobe-icons-link]: https://www.npmjs.com/package/@lobehub/icons
|
|
736
|
+
[lobe-icons-shield]: https://img.shields.io/npm/v/@lobehub/icons?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
|
663
737
|
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
|
664
738
|
[lobe-lint-link]: https://www.npmjs.com/package/@lobehub/lint
|
|
665
739
|
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
|
740
|
+
[lobe-midjourney-webui]: https://github.com/lobehub/lobe-midjourney-webui
|
|
666
741
|
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
|
667
742
|
[lobe-tts-github]: https://github.com/lobehub/lobe-tts
|
|
668
743
|
[lobe-tts-link]: https://www.npmjs.com/package/@lobehub/tts
|
|
@@ -685,7 +760,7 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
685
760
|
[share-whatsapp-shield]: https://img.shields.io/badge/-share%20on%20whatsapp-black?labelColor=black&logo=whatsapp&logoColor=white&style=flat-square
|
|
686
761
|
[share-x-link]: https://x.com/intent/tweet?hashtags=chatbot%2CchatGPT%2CopenAI&text=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
|
687
762
|
[share-x-shield]: https://img.shields.io/badge/-share%20on%20x-black?labelColor=black&logo=x&logoColor=white&style=flat-square
|
|
688
|
-
[sponsor-link]: https://opencollective.com/lobehub 'Become
|
|
763
|
+
[sponsor-link]: https://opencollective.com/lobehub 'Become ❤ LobeHub Sponsor'
|
|
689
764
|
[sponsor-shield]: https://img.shields.io/badge/-Sponsor%20LobeHub-f04f88?logo=opencollective&logoColor=white&style=flat-square
|
|
690
765
|
[submit-agents-link]: https://github.com/lobehub/lobe-chat-agents
|
|
691
766
|
[submit-agents-shield]: https://img.shields.io/badge/🤖/🏪_submit_agent-%E2%86%92-c4f042?labelColor=black&style=for-the-badge
|
|
@@ -10,6 +10,7 @@ LobeChat uses [Auth.js v5](https://authjs.dev/) as the external authentication s
|
|
|
10
10
|
- [Step 2: Update Server Configuration Code](#step-2-update-server-configuration-code)
|
|
11
11
|
- [Step 3: Change Frontend Pages](#step-3-change-frontend-pages)
|
|
12
12
|
- [Step 4: Configure the Environment Variables](#step-4-configure-the-environment-variables)
|
|
13
|
+
- [Step 5: Modify server-side user information processing logic](#step-5-modify-server-side-user-information-processing-logic)
|
|
13
14
|
|
|
14
15
|
## Add New Authentication Provider
|
|
15
16
|
|
|
@@ -82,4 +83,111 @@ This value is the id of the Auth.js provider, and you can read the source code o
|
|
|
82
83
|
|
|
83
84
|
Add `OKTA_CLIENT_ID`、`OKTA_CLIENT_SECRET`、`OKTA_ISSUER` environment variables when you deploy.
|
|
84
85
|
|
|
86
|
+
### Step 5: Modify server-side user information processing logic
|
|
87
|
+
|
|
88
|
+
#### Get user information in the frontend
|
|
89
|
+
|
|
90
|
+
Use the `useOAuthSession()` method in the frontend page to get the user information `user` returned by the backend:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { useOAuthSession } from '@/hooks/useOAuthSession';
|
|
94
|
+
|
|
95
|
+
const { user, isOAuthLoggedIn } = useOAuthSession();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The default type of `user` is `User`, and the type definition is:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
interface User {
|
|
102
|
+
id?: string;
|
|
103
|
+
name?: string | null;
|
|
104
|
+
email?: string | null;
|
|
105
|
+
image?: string | null;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Modify user `id` handling logic
|
|
110
|
+
|
|
111
|
+
The `user.id` is used to identify users. When introducing a new OAuth identity provider, you need to handle the information carried in the OAuth callback in `src/app/api/auth/next-auth.ts`. You need to select the user's `id` from this information. Before that, we need to understand the data processing sequence of `Auth.js`:
|
|
112
|
+
|
|
113
|
+
```txt
|
|
114
|
+
authorize --> jwt --> session
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
By default, in the `jwt --> session` process, `Auth.js` will [automatically assign the user `id` to `account.providerAccountId` based on the login type](https://authjs.dev/reference/core/types#provideraccountid). If you need to select a different value as the user `id`, you need to implement the following handling logic:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
callbacks: {
|
|
121
|
+
async jwt({ token, account, profile }) {
|
|
122
|
+
if (account) {
|
|
123
|
+
// You can select a different value from `account` or `profile`
|
|
124
|
+
token.userId = account.providerAccountId;
|
|
125
|
+
}
|
|
126
|
+
return token;
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
#### Customize `session` return
|
|
132
|
+
|
|
133
|
+
If you want to carry more information about `profile` and `account` in the `session`, according to the data processing order mentioned above in `Auth.js`, you must first copy this information to the `token`. For example, add the user avatar URL `profile.picture` to the `session`:
|
|
134
|
+
|
|
135
|
+
```diff
|
|
136
|
+
callbacks: {
|
|
137
|
+
async jwt({ token, profile, account }) {
|
|
138
|
+
if (profile && account) {
|
|
139
|
+
token.userId = account.providerAccountId;
|
|
140
|
+
+ token.avatar = profile.picture;
|
|
141
|
+
}
|
|
142
|
+
return token;
|
|
143
|
+
},
|
|
144
|
+
async session({ session, token }) {
|
|
145
|
+
if (session.user) {
|
|
146
|
+
session.user.id = token.userId ?? session.user.id;
|
|
147
|
+
+ session.user.avatar = token.avatar;
|
|
148
|
+
}
|
|
149
|
+
return session;
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Then supplement the type definition for the new parameters:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
declare module '@auth/core/jwt' {
|
|
158
|
+
interface JWT {
|
|
159
|
+
// ...
|
|
160
|
+
avatar?: string;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare module 'next-auth' {
|
|
165
|
+
interface User {
|
|
166
|
+
avatar?: string;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
> [More built-in type extensions in Auth.js](https://authjs.dev/getting-started/typescript#module-augmentation)
|
|
172
|
+
|
|
173
|
+
#### Differentiate multiple authentication providers in the processing logic
|
|
174
|
+
|
|
175
|
+
If you have configured multiple authentication providers and their `userId` mappings are different, you can use the `account.provider` parameter in the `jwt` method to get the default id of the identity provider and enter different processing logic.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
callbacks: {
|
|
179
|
+
async jwt({ token, profile, account }) {
|
|
180
|
+
if (profile && account) {
|
|
181
|
+
if (account.provider === 'authing')
|
|
182
|
+
token.userId = account.providerAccountId ?? token.sub;
|
|
183
|
+
else if (acount.provider === 'auth0')
|
|
184
|
+
token.userId = profile.sub ?? token.sub;
|
|
185
|
+
else
|
|
186
|
+
// other providers
|
|
187
|
+
}
|
|
188
|
+
return token;
|
|
189
|
+
},
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
85
193
|
Now, you can use Okta as your provider to implement the authentication feature in LobeChat.
|