@lobehub/chat 0.120.0 → 0.120.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +24 -26
  3. package/README.zh-CN.md +24 -26
  4. package/docs/Deployment/Common-Error.md +18 -1
  5. package/docs/Deployment/Common-Error.zh-CN.md +18 -0
  6. package/docs/Deployment/Environment-Variable.md +14 -3
  7. package/docs/Deployment/Environment-Variable.zh-CN.md +14 -3
  8. package/docs/Development/Contributing-Guidelines.zh-CN.md +72 -0
  9. package/docs/Development/Internationalization-Implementation.zh-CN.md +117 -0
  10. package/docs/Development/State-Management/Selectors.zh-CN.md +49 -0
  11. package/docs/Development/State-Management/index.zh-CN.md +219 -0
  12. package/docs/Development/index.zh-CN.md +66 -1
  13. package/docs/Home.md +3 -3
  14. package/docs/_Sidebar.md +4 -4
  15. package/package.json +7 -3
  16. package/src/features/Conversation/Plugins/Render/StandaloneType/Iframe.tsx +2 -2
  17. package/src/features/Conversation/Plugins/Render/utils/listenToPlugin.test.ts +2 -2
  18. package/src/features/Conversation/Plugins/Render/utils/listenToPlugin.ts +5 -2
  19. package/src/features/Conversation/components/ChatItem/index.tsx +12 -1
  20. package/src/features/Conversation/components/VirtualizedList/index.tsx +4 -1
  21. package/src/store/chat/slices/tool/action.test.ts +167 -7
  22. package/src/store/chat/slices/tool/action.ts +36 -4
  23. package/src/store/tool/slices/plugin/__snapshots__/action.test.ts.snap +15 -0
  24. package/src/store/tool/slices/plugin/action.test.ts +122 -0
  25. package/src/store/tool/slices/plugin/action.ts +18 -1
  26. package/docs/Development/Data-Store-Selectors.zh-CN.md +0 -68
  27. /package/docs/{Add-New-Locale.md → Development/Add-New-Locale.md} +0 -0
  28. /package/docs/{Add-New-Locale.zh-CN.md → Development/Add-New-Locale.zh-CN.md} +0 -0
  29. /package/docs/Development/{Data-Store-Selectors.md → State-Management/Selectors.md} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.120.2](https://github.com/lobehub/lobe-chat/compare/v0.120.1...v0.120.2)
6
+
7
+ <sup>Released on **2024-01-17**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix setPluginMessage can not stop create ai message.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix setPluginMessage can not stop create ai message, closes [#1078](https://github.com/lobehub/lobe-chat/issues/1078) ([67de28d](https://github.com/lobehub/lobe-chat/commit/67de28d))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.120.1](https://github.com/lobehub/lobe-chat/compare/v0.120.0...v0.120.1)
31
+
32
+ <sup>Released on **2024-01-16**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Fix list scrolling white screen on mobile.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Fix list scrolling white screen on mobile, closes [#1072](https://github.com/lobehub/lobe-chat/issues/1072) ([af10947](https://github.com/lobehub/lobe-chat/commit/af10947))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ## [Version 0.120.0](https://github.com/lobehub/lobe-chat/compare/v0.119.13...v0.120.0)
6
56
 
7
57
  <sup>Released on **2024-01-15**</sup>
package/README.md CHANGED
@@ -169,14 +169,14 @@ e-commerce platform data access, and various third-party services.
169
169
 
170
170
  <!-- PLUGIN LIST -->
171
171
 
172
- | Recent Submits | Description |
173
- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
174
- | [weather GPT](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Steven Tey** on **2023-12-16**</sup> | Get current weather information for a specific location.<br/>`weather` |
175
- | [Ask Your PDF](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **AskYourPDF** on **2023-12-16**</sup> | Unlock the power of your PDFs!, dive into your documents, find answers, and bring information to your fingertips.<br/>`pdf` `document` `web` |
176
- | [Clock Time](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2023-11-01**</sup> | Display a clock to show current time<br/>`clock` `time` |
177
- | [Mindmap](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Moonlit7** on **2023-12-19**</sup> | A mindmap generation assistant<br/>`mindmap` |
172
+ | Recent Submits | Description |
173
+ | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
174
+ | [TikZJax](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Arvin Xu** on **2024-01-14**</sup> | Convert LaTeX TikZ code into SVG images for crisp, scalable mathematical diagrams and visualizations.<br/>`latex` `svg` `visualization` `diagram` `math` |
175
+ | [weather GPT](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Steven Tey** on **2023-12-16**</sup> | Get current weather information for a specific location.<br/>`weather` |
176
+ | [Ask Your PDF](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **AskYourPDF** on **2023-12-16**</sup> | Unlock the power of your PDFs!, dive into your documents, find answers, and bring information to your fingertips.<br/>`pdf` `document` `web` |
177
+ | [Clock Time](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2023-11-01**</sup> | Display a clock to show current time<br/>`clock` `time` |
178
178
 
179
- > 📊 Total plugins: [<kbd>**9**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
179
+ > 📊 Total plugins: [<kbd>**10**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
180
180
 
181
181
  <!-- PLUGIN LIST -->
182
182
 
@@ -208,14 +208,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
208
208
 
209
209
  <!-- AGENT LIST -->
210
210
 
211
- | Recent Submits | Description |
212
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
213
- | [English Analyst](https://chat-preview.lobehub.com/market?agent=english-teacher)<br/><sup>By **[fmaxyou](https://github.com/fmaxyou)** on **2024-01-11**</sup> | Specializes in explaining and memorization techniques for English words and phrases<br/>`english-teaching` `explanation` `memorization-techniques` |
214
- | [Life Decision Advisor](https://chat-preview.lobehub.com/market?agent=life-decision-advisor)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2024-01-11**</sup> | A Life Decision Advisor is a virtual guide designed to assist users in making informed life decisions<br/>`prompt` |
215
- | [Computer Science Paper Proofreading](https://chat-preview.lobehub.com/market?agent=cs-research-paper)<br/><sup>By **[McKinleyLu](https://github.com/McKinleyLu)** on **2024-01-10**</sup> | Specializing in proofreading master's degree theses<br/>`proofreading` `paper` `education` `computer-science` |
216
- | [Emoji Generator](https://chat-preview.lobehub.com/market?agent=emoji-generate)<br/><sup>By **[mushan0x0](https://github.com/mushan0x0)** on **2024-01-09**</sup> | Generate emoji expressions based on content<br/>`expression-generation` `emoji` `creative` |
211
+ | Recent Submits | Description |
212
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
213
+ | [William](https://chat-preview.lobehub.com/market?agent=unreal-engine-development-engineer)<br/><sup>By **[Wutpeach](https://github.com/Wutpeach)** on **2024-01-16**</sup> | Unreal Engine expert, proficient in C++ programming, rendering, memory, thread and other pipeline architectures, UE application on Android platform, comprehensive artistic cognition, familiar with Shader writing, proficient in 3D art asset production process and tools.<br/>`unreal-engine` `c-programming` `rendering-pipeline` `memory-management` `thread-architecture` |
214
+ | [Chad](https://chat-preview.lobehub.com/market?agent=chad)<br/><sup>By **[HerIsDia](https://github.com/HerIsDia)** on **2024-01-15**</sup> | Just chad<br/>`humor` `funny` |
215
+ | [English Analyst](https://chat-preview.lobehub.com/market?agent=english-teacher)<br/><sup>By **[fmaxyou](https://github.com/fmaxyou)** on **2024-01-11**</sup> | Specializes in explaining and memorization techniques for English words and phrases<br/>`english-teaching` `explanation` `memorization-techniques` |
216
+ | [Life Decision Advisor](https://chat-preview.lobehub.com/market?agent=life-decision-advisor)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2024-01-11**</sup> | A Life Decision Advisor is a virtual guide designed to assist users in making informed life decisions<br/>`prompt` |
217
217
 
218
- > 📊 Total agents: [<kbd>**96**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
218
+ > 📊 Total agents: [<kbd>**98**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
219
219
 
220
220
  <!-- AGENT LIST -->
221
221
 
@@ -395,12 +395,12 @@ $ docker run -d -p 3210:3210 \
395
395
 
396
396
  This project provides some additional configuration items set with environment variables:
397
397
 
398
- | Environment Variable | Required | Description | Example |
399
- | -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
400
- | `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
401
- | `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` |
402
- | `ACCESS_CODE` | No | Add a password to access this service; you can set a long password to avoid leaking. If this value contains a comma, it is a password array. | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
403
- | `CUSTOM_MODELS` | No | Used to control the model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model, separated by commas. | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
398
+ | Environment Variable | Required | Description | Example |
399
+ | -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
400
+ | `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
401
+ | `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` or `https://aihubmix.com/v1` <br/>The default value is<br/>`https://api.openai.com/v1` |
402
+ | `ACCESS_CODE` | No | Add a password to access this service; you can set a long password to avoid leaking. If this value contains a comma, it is a password array. | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
403
+ | `CUSTOM_MODELS` | No | Used to control the model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model, separated by commas. | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
404
404
 
405
405
  > \[!NOTE]
406
406
  >
@@ -458,15 +458,15 @@ You can use GitHub Codespaces for online development:
458
458
 
459
459
  Or clone it for local development:
460
460
 
461
- [![][bun-shield]][bun-link]
462
-
463
461
  ```fish
464
462
  $ git clone https://github.com/lobehub/lobe-chat.git
465
463
  $ cd lobe-chat
466
- $ bun install
467
- $ bun dev
464
+ $ pnpm install
465
+ $ pnpm dev
468
466
  ```
469
467
 
468
+ If you would like to learn more details, please feel free to look at our [LobeChat Development Guide](https://github.com/lobehub/lobe-chat/wiki/index)
469
+
470
470
  <div align="right">
471
471
 
472
472
  [![][back-to-top]](#readme-top)
@@ -562,8 +562,6 @@ This project is [MIT](./LICENSE) licensed.
562
562
  <!-- LINK GROUP -->
563
563
 
564
564
  [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
565
- [bun-link]: https://bun.sh
566
- [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
567
565
  [chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
568
566
  [chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/chat_preview_lobehub_com_chat.html
569
567
  [chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
package/README.zh-CN.md CHANGED
@@ -150,14 +150,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
150
150
 
151
151
  <!-- PLUGIN LIST -->
152
152
 
153
- | 最近新增 | 插件描述 |
154
- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
155
- | [天气 GPT](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Steven Tey** on **2023-12-16**</sup> | 获取特定位置的当前天气信息。<br/>`天气` |
156
- | [AskYouPDF](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **AskYourPDF** on **2023-12-16**</sup> | 释放您的 PDF 的力量!深入您的文档,找到答案,并将信息带到您的指尖。<br/>`pdf` `文档` `web` |
157
- | [时钟时间](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2023-11-01**</sup> | 显示一个时钟来展示当前时间<br/>`时钟` `时间` |
158
- | [思维导图](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Moonlit7** on **2023-12-19**</sup> | 思维导图生成助手<br/>`思维导图` `脑图` |
153
+ | 最近新增 | 插件描述 |
154
+ | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
155
+ | [TikZJax](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Arvin Xu** on **2024-01-14**</sup> | 将 LaTeX TikZ 代码转换为 SVG 图像,用于创建清晰、可缩放的数学图表和可视化效果。<br/>`latex` `svg` `可视化` `图表` `数学` |
156
+ | [天气 GPT](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **Steven Tey** on **2023-12-16**</sup> | 获取特定位置的当前天气信息。<br/>`天气` |
157
+ | [AskYouPDF](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **AskYourPDF** on **2023-12-16**</sup> | 释放您的 PDF 的力量!深入您的文档,找到答案,并将信息带到您的指尖。<br/>`pdf` `文档` `web` |
158
+ | [时钟时间](https://chat-preview.lobehub.com/settings/agent)<br/><sup>By **LobeHub** on **2023-11-01**</sup> | 显示一个时钟来展示当前时间<br/>`时钟` `时间` |
159
159
 
160
- > 📊 Total plugins: [<kbd>**9**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
160
+ > 📊 Total plugins: [<kbd>**10**</kbd>](https://github.com/lobehub/lobe-chat-plugins)
161
161
 
162
162
  <!-- PLUGIN LIST -->
163
163
 
@@ -185,14 +185,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
185
185
 
186
186
  <!-- AGENT LIST -->
187
187
 
188
- | 最近新增 | 助手说明 |
189
- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
190
- | [英语解析师](https://chat-preview.lobehub.com/market?agent=english-teacher)<br/><sup>By **[fmaxyou](https://github.com/fmaxyou)** on **2024-01-11**</sup> | 擅长英语单词和短语解释与记忆技巧<br/>`英语教学` `解释` `记忆技巧` |
191
- | [生活决策顾问](https://chat-preview.lobehub.com/market?agent=life-decision-advisor)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2024-01-11**</sup> | 生活决策顾问是一个虚拟指南,旨在帮助用户做出明智的生活决策<br/>`提示` |
192
- | [计算机科学论文润色](https://chat-preview.lobehub.com/market?agent=cs-research-paper)<br/><sup>By **[McKinleyLu](https://github.com/McKinleyLu)** on **2024-01-10**</sup> | 擅长润色硕士学位论文<br/>`润色` `论文` `教育` `计算机科学` |
193
- | [Emoji 生成](https://chat-preview.lobehub.com/market?agent=emoji-generate)<br/><sup>By **[mushan0x0](https://github.com/mushan0x0)** on **2024-01-09**</sup> | 可以根据内容生成 Emoji 表情<br/>`表情生成` `emoji` `创意` |
188
+ | 最近新增 | 助手说明 |
189
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
190
+ | [William](https://chat-preview.lobehub.com/market?agent=unreal-engine-development-engineer)<br/><sup>By **[Wutpeach](https://github.com/Wutpeach)** on **2024-01-16**</sup> | 虚幻引擎专家,精通 C++ 编程,渲染、内存、线程等管线架构,UE 在安卓平台应用,全面的美术认知,熟悉 Shader 编写,熟练掌握 3D 美术资产制作流程与工具。<br/>`虚幻引擎` `c-编程` `渲染管线` `内存管理` `线程架构` |
191
+ | [乍得](https://chat-preview.lobehub.com/market?agent=chad)<br/><sup>By **[HerIsDia](https://github.com/HerIsDia)** on **2024-01-15**</sup> | 只是乍得<br/>`幽默` `搞笑` |
192
+ | [英语解析师](https://chat-preview.lobehub.com/market?agent=english-teacher)<br/><sup>By **[fmaxyou](https://github.com/fmaxyou)** on **2024-01-11**</sup> | 擅长英语单词和短语解释与记忆技巧<br/>`英语教学` `解释` `记忆技巧` |
193
+ | [生活决策顾问](https://chat-preview.lobehub.com/market?agent=life-decision-advisor)<br/><sup>By **[amitalokbera](https://github.com/amitalokbera)** on **2024-01-11**</sup> | 生活决策顾问是一个虚拟指南,旨在帮助用户做出明智的生活决策<br/>`提示` |
194
194
 
195
- > 📊 Total agents: [<kbd>**96**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
195
+ > 📊 Total agents: [<kbd>**98**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
196
196
 
197
197
  <!-- AGENT LIST -->
198
198
 
@@ -367,12 +367,12 @@ $ docker run -d -p 3210:3210 \
367
367
 
368
368
  本项目提供了一些额外的配置项,使用环境变量进行设置:
369
369
 
370
- | 环境变量 | 类型 | 描述 | 示例 |
371
- | ------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
372
- | `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
373
- | `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
374
- | `ACCESS_CODE` | 可选 | 添加访问此服务的密码,你可以设置一个长密码以防被爆破,该值用逗号分隔时为密码数组 | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
375
- | `CUSTOM_MODELS` | 可选 | 用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。 | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
370
+ | 环境变量 | 类型 | 描述 | 示例 |
371
+ | ------------------ | ---- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
372
+ | `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
373
+ | `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn` 或 `https://aihubmix.com/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
374
+ | `ACCESS_CODE` | 可选 | 添加访问此服务的密码,你可以设置一个长密码以防被爆破,该值用逗号分隔时为密码数组 | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
375
+ | `CUSTOM_MODELS` | 可选 | 用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。 | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
376
376
 
377
377
  > \[!NOTE]
378
378
  >
@@ -472,15 +472,15 @@ API Key 是使用 LobeChat 进行大语言模型会话的必要信息,本节
472
472
 
473
473
  或者使用以下命令进行本地开发:
474
474
 
475
- [![][bun-shield]][bun-link]
476
-
477
475
  ```fish
478
476
  $ git clone https://github.com/lobehub/lobe-chat.git
479
477
  $ cd lobe-chat
480
- $ bun install
481
- $ bun run dev
478
+ $ pnpm install
479
+ $ pnpm run dev
482
480
  ```
483
481
 
482
+ 如果你希望了解更多详情,欢迎可以查阅我们的 [LobeChat 开发指南](https://github.com/lobehub/lobe-chat/wiki/index.zh-CN)
483
+
484
484
  <div align="right">
485
485
 
486
486
  [![][back-to-top]](#readme-top)
@@ -576,8 +576,6 @@ This project is [MIT](./LICENSE) licensed.
576
576
  <!-- LINK GROUP -->
577
577
 
578
578
  [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
579
- [bun-link]: https://bun.sh
580
- [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
581
579
  [chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
582
580
  [chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/chat_preview_lobehub_com_chat.html
583
581
  [chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
@@ -1,5 +1,23 @@
1
1
  # Frequently Asked Questions
2
2
 
3
+ ## Configuring the `OPENAI_PROXY_URL` Environment Variable but Receiving an Empty Response
4
+
5
+ ### Problem Description
6
+
7
+ After configuring the `OPENAI_PROXY_URL` environment variable, you may encounter a situation where the response from the AI is empty. This could be due to an incorrect configuration of the `OPENAI_PROXY_URL`.
8
+
9
+ ### Solution
10
+
11
+ Recheck and confirm if the `OPENAI_PROXY_URL` is set correctly, including the correct addition of the `/v1` suffix (if required).
12
+
13
+ ### Related Discussion Links
14
+
15
+ - [Why is the response blank after installing and configuring Docker and environment variables?](https://github.com/lobehub/lobe-chat/discussions/623)
16
+ - [Reasons for errors when using third-party APIs](https://github.com/lobehub/lobe-chat/discussions/734)
17
+ - [No response from the chat when the proxy server address is filled](https://github.com/lobehub/lobe-chat/discussions/1065)
18
+
19
+ If the issue persists, it is recommended to raise the problem in the community with relevant logs and configuration information for other developers or maintainers to provide assistance.
20
+
3
21
  ## When using a proxy(e.g. Surge), I encounter the `UNABLE_TO_VERIFY_LEAF_SIGNATURE` error
4
22
 
5
23
  ### Problem Description
@@ -67,4 +85,3 @@ If possible, it is recommended to address certificate issues using the following
67
85
  3. Properly configure the certificate chain in the code to ensure that Node.js can validate to the root certificate.
68
86
 
69
87
  Implementing these methods can resolve certificate validation issues without sacrificing security.
70
-
@@ -1,5 +1,23 @@
1
1
  # 常见问题
2
2
 
3
+ ## 配置 `OPENAI_PROXY_URL` 环境变量但返回值为空
4
+
5
+ ### 问题描述
6
+
7
+ 配置 `OPENAI_PROXY_URL` 环境变量后,可能会遇到 AI 的返回消息为空的情况。这可能是由于 `OPENAI_PROXY_URL` 配置不正确导致。
8
+
9
+ ### 解决方案
10
+
11
+ 重新检查并确认 `OPENAI_PROXY_URL` 是否设置正确,包括是否正确地添加了 `/v1` 后缀(如果需要)。
12
+
13
+ ### 相关讨论链接
14
+
15
+ - [Docker 安装,配置好环境变量后,为何返回值是空白?](https://github.com/lobehub/lobe-chat/discussions/623)
16
+ - [使用第三方接口报错的原因](https://github.com/lobehub/lobe-chat/discussions/734)
17
+ - [代理服务器地址填了聊天没任何反应](https://github.com/lobehub/lobe-chat/discussions/1065)
18
+
19
+ 如果问题依旧无法解决,建议在社区中提出问题,附上相关日志和配置信息,以便其他开发者或维护者提供帮助。
20
+
3
21
  ## 使用代理中转请求时(例如:Surge),报 `UNABLE_TO_VERIFY_LEAF_SIGNATURE` 错误
4
22
 
5
23
  ### 问题描述
@@ -54,10 +54,21 @@ The above example adds `qwen-7b-chat` and `glm-6b` to the model list, removes `g
54
54
 
55
55
  - Type: Optional
56
56
  - Description: If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL
57
- - Default: `https://api.openai.com`
58
- - Example: `https://api.chatanywhere.cn`
57
+ - Default: `https://api.openai.com/v1`
58
+ - Example: `https://api.chatanywhere.cn` or `https://aihubmix.com/v1`
59
59
 
60
- <br/>
60
+ > !\[NOTE]
61
+ >
62
+ > Please check the request suffix of your proxy service provider. Some proxy service providers may add `/v1` to the request suffix, while others may not.
63
+ > If you find that the AI returns an empty message during testing, try adding the `/v1` suffix and retrying.
64
+
65
+ Whether to fill in `/v1` is closely related to the model service provider. For example, the default address of OpenAI is `api.openai.com/v1`. If your proxy forwards this interface, you can directly fill in `proxy.com`. However, if the model service provider directly forwards the `api.openai.com` domain, you need to add the `/v1` URL by yourself.
66
+
67
+ Related discussions:
68
+
69
+ - [Why is the return value blank after installing Docker, configuring the environment variables?](https://github.com/lobehub/lobe-chat/discussions/623)
70
+ - [Reasons for errors when using third-party interfaces](https://github.com/lobehub/lobe-chat/discussions/734)
71
+ - [No response when filling in the proxy server address for chatting](https://github.com/lobehub/lobe-chat/discussions/1065)
61
72
 
62
73
  ## Azure OpenAI
63
74
 
@@ -54,10 +54,21 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
54
54
 
55
55
  - 类型:可选
56
56
  - 描述:如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL
57
- - 默认值:`https://api.openai.com`
58
- - 示例:`https://api.chatanywhere.cn`
57
+ - 默认值:`https://api.openai.com/v1`
58
+ - 示例:`https://api.chatanywhere.cn` 或 `https://aihubmix.com/v1`
59
59
 
60
- <br/>
60
+ > !\[NOTE] 注意事项:
61
+ >
62
+ > 请检查你的代理服务商的请求后缀,有的代理服务商会在请求后缀添加 `/v1`,有的则不会。
63
+ > 如果你在测试时发现 AI 返回的消息为空,请尝试添加 `/v1` 后缀后重试。
64
+
65
+ 是否填写 `/v1` 跟模型服务商有很大关系,比如 openai 的默认地址是 `api.openai.com/v1` 。如果你的代理上是转发了 `/v1` 这个接口,那么直接填 `proxy.com` 即可。 但如果模型服务商是直接转发了 `api.openai.com` 域名,那么你就要自己加上 `/v1` 这个 url。
66
+
67
+ 相关讨论:
68
+
69
+ - [Docker 安装,配置好环境变量后,为何返回值是空白?](https://github.com/lobehub/lobe-chat/discussions/623)
70
+ - [使用第三方接口报错的原因](https://github.com/lobehub/lobe-chat/discussions/734)
71
+ - [代理服务器地址填了聊天没任何反应](https://github.com/lobehub/lobe-chat/discussions/1065)
61
72
 
62
73
  ## Azure OpenAI
63
74
 
@@ -0,0 +1,72 @@
1
+ # 代码风格与贡献指南
2
+
3
+ 欢迎来到 LobeChat 的代码风格与贡献指南。本指南将帮助您理解我们的代码规范和贡献流程,确保代码的一致性和项目的顺利进行。
4
+
5
+ ## 代码风格
6
+
7
+ 在 LobeChat 中,我们使用 `@lobehub/lint` 程序包来统一代码风格。该程序包内置了 `ESLint`、`Prettier`、`remarklint` 和 `stylelint` 的配置,以确保我们的 JavaScript、Markdown 和 CSS 文件遵循相同的编码标准。
8
+
9
+ ### ESLint
10
+
11
+ 我们的项目使用 ESLint 来检查 JavaScript 代码中的问题。您可以在项目根目录下找到 `.eslintrc.js` 文件,其中包含了我们对 `@lobehub/lint` 的 ESLint 配置的扩展和自定义规则。
12
+
13
+ 为了与 Next.js 框架兼容,我们在配置中添加了 `plugin:@next/next/recommended`。此外,我们禁用了一些规则,以适应我们项目的特定需求。
14
+
15
+ 请在提交代码前运行 ESLint,以确保您的代码符合项目规范。
16
+
17
+ ### Prettier
18
+
19
+ Prettier 负责代码格式化,以保证代码的一致性。您可以在 `.prettierrc.js` 中找到我们的 Prettier 配置,它是从 `@lobehub/lint` 导入的。
20
+
21
+ 在保存文件时,建议您配置您的编辑器以自动运行 Prettier,或者在提交前手动运行它。
22
+
23
+ ### remarklint
24
+
25
+ 对于 Markdown 文件,我们使用 remarklint 来确保文档格式的统一。您可以在项目中找到相应的配置文件。
26
+
27
+ ### stylelint
28
+
29
+ 我们使用 stylelint 来规范 CSS 代码的风格。在 `stylelint` 的配置文件中,我们基于 `@lobehub/lint` 的配置进行了一些自定义规则的调整。
30
+
31
+ 确保您的样式代码在提交前通过了 stylelint 的检查。
32
+
33
+ ## 贡献流程
34
+
35
+ LobeChat 采用 gitmoji 和 semantic release 作为我们的代码提交和发布流程。
36
+
37
+ ### Gitmoji
38
+
39
+ 在提交代码时,请使用 gitmoji 来标注您的提交信息。这有助于其他贡献者快速理解您提交的内容和目的。
40
+
41
+ Gitmoji commit messages 使用特定的 emoji 来表示提交的类型或意图。以下是一个示例:
42
+
43
+ ```
44
+ 📝 Update README with contribution guidelines
45
+
46
+ - Added section about code style preferences
47
+ - Included instructions for running tests
48
+ - Corrected typos and improved formatting
49
+ ```
50
+
51
+ 在这个示例中,📝 emoji 代表了文档的更新。提交信息清晰地描述了更改的内容,提供了具体的细节。
52
+
53
+ ### Semantic Release
54
+
55
+ 我们使用 semantic release 来自动化版本控制和发布流程。请确保您的提交信息遵循 semantic release 的规范,这样当代码合并到主分支后,系统就可以自动创建新的版本并发布。
56
+
57
+ ### Commitlint
58
+
59
+ 为了确保提交信息的一致性,我们使用 `commitlint` 来检查提交信息格式。您可以在 `.commitlintrc.js` 配置文件中找到相关规则。
60
+
61
+ 在您提交代码之前,请确保您的提交信息遵循我们的规范。
62
+
63
+ ### 如何贡献
64
+
65
+ 1. Fork 项目到您的账户。
66
+ 2. 创建一个新的分支进行开发。
67
+ 3. 开发完成后,确保您的代码通过了上述的代码风格检查。
68
+ 4. 提交您的更改,并使用合适的 gitmoji 标注您的提交信息。
69
+ 5. 创建一个 Pull Request 到原项目的主分支。
70
+ 6. 等待代码审查,并根据反馈进行必要的修改。
71
+
72
+ 感谢您遵循这些指导原则,它们有助于我们维护项目的质量和一致性。我们期待您的贡献!
@@ -0,0 +1,117 @@
1
+ # LobeChat 国际化实现指南
2
+
3
+ 欢迎阅读 LobeChat 国际化实现指南。本文档将指导你了解 LobeChat 的国际化机制,包括文件结构、如何添加新语种。LobeChat 采用 `i18next` 和 `lobe-i18n` 作为国际化解决方案,旨在为用户提供流畅的多语言支持。
4
+
5
+ ## 国际化概述
6
+
7
+ 国际化(Internationalization,简称为 i18n)是一个让应用能够适应不同语言和地区的过程。在 LobeChat 中,我们支持多种语言,并通过 `i18next` 库来实现语言的动态切换和内容的本地化。我们的目标是让 LobeChat 能够为全球用户提供本地化的体验。
8
+
9
+ ## 文件结构
10
+
11
+ 在 LobeChat 的项目中,国际化相关的文件被组织如下:
12
+
13
+ - `src/locales/default`: 包含默认开发语言(中文)的翻译文件,我们作为中文。
14
+ - `locales`: 包含所有支持的语言文件夹,每个语言文件夹中包含相应语言的翻译文件,这些翻译文件通过 lobe-i18n 自动生成。
15
+
16
+ 在 `src/locales` 这个目录结构中,`default` 文件夹包含了原始的翻译文件(中文),其他每个语言文件夹则包含了相应语言的 JSON 翻译文件。每个语言文件夹中的文件对应 `default` 文件夹中的 TypeScript 文件,确保了各语种之间的翻译文件结构一致性。
17
+
18
+ ```
19
+ src/locales
20
+ ├── create.ts
21
+ ├── default
22
+ │ ├── chat.ts
23
+ │ ├── common.ts
24
+ │ ├── error.ts
25
+ │ ├── index.ts
26
+ │ ├── market.ts
27
+ │ ├── migration.ts
28
+ │ ├── plugin.ts
29
+ │ ├── setting.ts
30
+ │ ├── tool.ts
31
+ │ └── welcome.ts
32
+ └── resources.ts
33
+ ```
34
+
35
+ 通过 lobe-i18n 自动生成的文件结构如下:
36
+
37
+ ```
38
+ locales
39
+ ├── ar
40
+ │ ├── chat.json
41
+ │ ├── common.json
42
+ │ ├── error.json
43
+ │ └── ... (其他翻译文件)
44
+ ├── de-DE
45
+ │ ├── chat.json
46
+ │ ├── common.json
47
+ │ ├── error.json
48
+ │ └── ... (其他翻译文件)
49
+ ├── en-US
50
+ ├── ... (其他语种目录)
51
+ ├── zh-CN
52
+ └── zh-TW
53
+ ```
54
+
55
+ ## 核心实现逻辑
56
+
57
+ LobeChat 的国际化核心实现逻辑如下:
58
+
59
+ - 使用 `i18next` 库进行初始化和配置。
60
+ - 使用 `i18next-browser-languagedetector` 自动检测用户的语言偏好。
61
+ - 使用 `i18next-resources-to-backend` 动态加载翻译资源。
62
+ - 根据用户的语言偏好,设置 HTML 文档的方向(LTR 或 RTL)。
63
+
64
+ 以下是一个简化的伪代码示例,用以说明 LobeChat 国际化的核心实现逻辑:
65
+
66
+ ```ts
67
+ import i18n from 'i18next';
68
+ import LanguageDetector from 'i18next-browser-languagedetector';
69
+ import resourcesToBackend from 'i18next-resources-to-backend';
70
+ import { isRtlLang } from 'rtl-detect';
71
+
72
+ // 创建 i18n 实例并配置
73
+ const createI18nInstance = (lang) => {
74
+ const i18nInstance = i18n
75
+ .use(LanguageDetector) // 使用语言检测
76
+ .use(
77
+ resourcesToBackend((language, namespace) => {
78
+ // 动态加载对应语言的翻译资源
79
+ return import(`path/to/locales/${language}/${namespace}.json`);
80
+ }),
81
+ );
82
+
83
+ // 监听语言变化事件,动态设置文档方向
84
+ i18nInstance.on('languageChanged', (language) => {
85
+ const direction = isRtlLang(language) ? 'rtl' : 'ltr';
86
+ document.documentElement.dir = direction; // 设置 HTML 文档方向
87
+ });
88
+
89
+ // 初始化 i18n 实例
90
+ i18nInstance.init({
91
+ // 相关配置
92
+ });
93
+
94
+ return i18nInstance;
95
+ };
96
+ ```
97
+
98
+ 在这个示例中,我们展示了如何使用 `i18next` 和相关插件来初始化国际化设置。我们动态导入了翻译资源,并响应语言变化事件来调整页面的文本方向。这个过程为 LobeChat 提供了灵活的多语言支持能力。
99
+
100
+ ## 添加新的语言支持
101
+
102
+ 我们通过以下工作,已经支持了全球多种语言:
103
+
104
+ - [✨ feat: adding Arabic Language Support #1049](https://github.com/lobehub/lobe-chat/pull/1049)
105
+ - [🌐 style: Add Vietnamese files and add the vi-VN option in the General Settings #860](https://github.com/lobehub/lobe-chat/pull/860)
106
+ - [🌐 style: support it-IT nl-NL and pl-PL locales #759](https://github.com/lobehub/lobe-chat/pull/759)
107
+ - [🌐 feat(locale): Add fr-FR (#637) #645](https://github.com/lobehub/lobe-chat/pull/645)
108
+ - [🌐 Add russian localy #137](https://github.com/lobehub/lobe-chat/pull/137)
109
+
110
+ 要添加新的语种支持, 详细步骤请参考:[新语种添加指南](Add-New-Locale.zh-CN)。
111
+
112
+ ## 资源和进一步阅读
113
+
114
+ - [i18next 官方文档](https://www.i18next.com/)
115
+ - [lobe-i18n 工具说明](https://github.com/lobehub/lobe-cli-toolbox/tree/master/packages/lobe-i18n)
116
+
117
+ 通过遵循本指南,你可以更好地理解和参与到 LobeChat 的国际化工作中,为全球用户提供无缝的多语言体验。
@@ -0,0 +1,49 @@
1
+ # 数据存储取数模块
2
+
3
+ selectors 是 LobeChat 数据流研发框架下的取数模块,它的作用是从 store 中以特定特务逻辑取出数据,供组件消费使用。
4
+
5
+ 以 `src/store/tool/slices/plugin/selectors.ts` 为例:
6
+
7
+ 这个 TypeScript 代码段定义了一个名为 `pluginSelectors` 的对象,该对象包含一系列用于从插件存储状态中检索数据的选择器函数。选择器是一种从 zustand 中提取和派生数据的函数。这个特定的例子是为了管理与前端应用程序的插件系统相关的状态。
8
+
9
+ 下面是一些关键点的说明:
10
+
11
+ - `getCustomPluginById`: 根据插件 ID 返回自定义插件信息。
12
+ - `getInstalledPluginById`: 根据插件 ID 返回已安装插件的信息。
13
+ - `getPluginManifestById`: 根据插件 ID 返回插件清单。
14
+ - `getPluginMetaById`: 根据插件 ID 返回插件元数据。
15
+ - `getPluginSettingsById`: 根据插件 ID 返回插件设置。
16
+ - `installedCustomPluginMetaList`: 返回所有已安装的自定义插件的元数据列表。
17
+ - `installedPluginManifestList`: 返回所有已安装插件的清单列表。
18
+ - `installedPluginMetaList`: 返回所有已安装插件的元数据列表。
19
+ - `installedPlugins`: 返回所有已安装插件的列表。
20
+ - `isPluginHasUI`: 根据插件 ID 确定插件是否有 UI 组件。
21
+ - `isPluginInstalled`: 根据插件 ID 检查插件是否已安装。
22
+ - `storeAndInstallPluginsIdList`: 返回 store 中和已安装插件的所有 ID 列表。
23
+
24
+ 选择器通过将复杂的状态选择逻辑封装在单独的函数中,使得在应用程序的其他部分调用状态数据时,代码更加简洁和直观。此外,由于使用了 TypeScript,每个函数都可以具有明确的输入和输出类型,这有助于提高代码的可靠性和开发效率。
25
+
26
+ 在组件中,只需引入相应的选择器即可直接获取最终消费的数据:
27
+
28
+ ```tsx | pure
29
+ import { useToolStore } from '@/store/tool';
30
+ import { pluginSelectors } from '@/store/tool/selectors';
31
+
32
+ const Render = () => {
33
+ const list = useToolStore(pluginSelectors.installedPluginMetaList);
34
+
35
+ return <> ... </>;
36
+ };
37
+ ```
38
+
39
+ 这样实现的好处在于:
40
+
41
+ 1. **解耦和重用**:通过将选择器独立于组件,我们可以在多个组件之间复用这些选择器而不需要重写取数逻辑。这减少了重复代码,提高了开发效率,并且使得代码库更加干净和易于维护。
42
+ 2. **性能优化**:选择器可以用来计算派生数据,这样可以避免在每个组件中重复计算相同的数据。当状态发生变化时,只有依赖于这部分状态的选择器才会重新计算,从而减少不必要的渲染和计算。
43
+ 3. **易于测试**:选择器是纯函数,它们仅依赖于传入的参数。这意味着它们可以在隔离的环境中进行测试,无需模拟整个 store 或组件树。
44
+ 4. **类型安全**:由于 LobeChat 使用 TypeScript,每个选择器都有明确的输入和输出类型定义。这为开发者提供了自动完成和编译时检查的优势,减少了运行时错误。
45
+ 5. **可维护性**:选择器集中了状态的读取逻辑,使得跟踪状态的变化和管理更加直观。如果状态结构发生变化,我们只需要更新相应的选择器,而不是搜索和替换整个代码库中的多个位置。
46
+ 6. **可组合性**:选择器可以组合其他选择器,以创建更复杂的选择逻辑。这种模式允许开发者构建一个选择器层次结构,使得状态选择更加灵活和强大。
47
+ 7. **简化组件逻辑**:组件不需要知道状态的结构或如何获取和计算需要的数据。组件只需调用选择器即可获取渲染所需的数据,这使得组件逻辑变得更简单和清晰。
48
+
49
+ 通过这样的设计,LobeChat 的开发者可以更专注于构建用户界面和业务逻辑,而不必担心数据的获取和处理细节。这种模式也为未来可能的状态结构变更提供了更好的适应性和扩展性。