@lobehub/chat 0.107.13 → 0.107.15

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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.107.15](https://github.com/lobehub/lobe-chat/compare/v0.107.14...v0.107.15)
6
+
7
+ <sup>Released on **2023-12-03**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Fix messages flickering when creating topic.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix messages flickering when creating topic, closes [#565](https://github.com/lobehub/lobe-chat/issues/565) ([7127550](https://github.com/lobehub/lobe-chat/commit/7127550))
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.107.14](https://github.com/lobehub/lobe-chat/compare/v0.107.13...v0.107.14)
31
+
32
+ <sup>Released on **2023-12-03**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Fix opt+delete fail in inputing (resolve.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Fix opt+delete fail in inputing (resolve, closes [#556](https://github.com/lobehub/lobe-chat/issues/556) ([4d5d93d](https://github.com/lobehub/lobe-chat/commit/4d5d93d))
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.107.13](https://github.com/lobehub/lobe-chat/compare/v0.107.12...v0.107.13)
6
56
 
7
57
  <sup>Released on **2023-12-03**</sup>
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- <a name="readme-top"></a><div align="center">
1
+ <a name="readme-top"></a>
2
+
3
+ <div align="center">
2
4
 
3
5
  <img height="120" src="https://registry.npmmirror.com/@lobehub/assets-logo/1.0.0/files/assets/logo-3d.webp">
4
6
  <img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
@@ -24,7 +26,8 @@ Supports one-click free deployment of your private ChatGPT/LLM web application.
24
26
  [![][github-forks-shield]][github-forks-link]
25
27
  [![][github-stars-shield]][github-stars-link]
26
28
  [![][github-issues-shield]][github-issues-link]
27
- [![][github-license-shield]][github-license-link]
29
+ [![][github-license-shield]][github-license-link]<br>
30
+ [![](https://img.shields.io/badge/-Sponsor%20LobeHub-f04f88?logo=opencollective&logoColor=white&style=flat-square)](https://opencollective.com/lobehub 'Sponsor LobeHub on open-collective')
28
31
 
29
32
  **Share LobeChat Repository**
30
33
 
@@ -49,9 +52,8 @@ Supports one-click free deployment of your private ChatGPT/LLM web application.
49
52
  - [✨ Features](#-features)
50
53
  - [⚡️ Performance](#️-performance)
51
54
  - [🛳 Self Hosting](#-self-hosting)
52
- - [`A` Deploying with Vercel](#a-deploying-with-vercel)
55
+ - [`A` Deploying with Vercel or Zeabur](#a-deploying-with-vercel-or-zeabur)
53
56
  - [`B` Deploying with Docker](#b-deploying-with-docker)
54
- - [`C` Deploying with Zeabur](#c-deploying-with-zeabur)
55
57
  - [Environment Variable](#environment-variable)
56
58
  - [📦 Ecosystem](#-ecosystem)
57
59
  - [🧩 Plugins](#-plugins)
@@ -203,12 +205,12 @@ Our marketplace is not just a showcase platform but also a collaborative space.
203
205
 
204
206
  | Recent Submits | Description |
205
207
  | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
208
+ | [Organic Chemistry Researcher](https://chat-preview.lobehub.com/market?agent=organic-chemistry-researcher)<br/><sup>By **[y22emc2](https://github.com/y22emc2)** on **2023-12-02**</sup> | Specializes in academic translation and writing in the field of organic chemistry<br/>`organic-chemistry` `research` `translation` `writing` `academic-articles` |
206
209
  | [JS Code Quality Optimization](https://chat-preview.lobehub.com/market?agent=js-code-quality)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2023-11-22**</sup> | Dedicated to clean and elegant code refactoring<br/>`refactoring` `code-optimization` `code-quality` |
207
210
  | [LobeChat Test Engineer](https://chat-preview.lobehub.com/market?agent=lobe-chat-unit-test-dev)<br/><sup>By **[arvinxx](https://github.com/arvinxx)** on **2023-11-22**</sup> | Proficient in writing frontend automation tests, especially comprehensive test coverage for TypeScript applications. Skilled in using the Vitest testing framework with a deep understanding of testing principles and strategies.<br/>`automation-testing` `testing` `lobe-chat` `frontend` |
208
211
  | [Q\&A Document Conversion Expert](https://chat-preview.lobehub.com/market?agent=q-a-helper)<br/><sup>By **[barryWang12138](https://github.com/barryWang12138)** on **2023-11-22**</sup> | Please provide your document content, and I will segment and clean it according to your requirements, and provide answers in a standardized format.<br/>`q-a` `document` |
209
- | [True Friend](https://chat-preview.lobehub.com/market?agent=ai-0x0-old-friends)<br/><sup>By **[mushan0x0](https://github.com/mushan0x0)** on **2023-11-21**</sup> | You can talk to me about anything. I can give you some thoughts and advice as a friend. Relax.<br/>`friendship` `humor` `authentic` `simulation` |
210
212
 
211
- > 📊 Total agents: [<kbd>**52**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
213
+ > 📊 Total agents: [<kbd>**53**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
212
214
 
213
215
  <!-- AGENT LIST -->
214
216
 
@@ -322,18 +324,20 @@ Beside these features, LobeChat also have much better basic technique undergroun
322
324
 
323
325
  LobeChat provides Self-Hosted Version with Vercel and [Docker Image][docker-release-link]. This allows you to deploy your own chatbot within a few minutes without any prior knowledge.
324
326
 
325
- ### `A` Deploying with Vercel
327
+ ### `A` Deploying with Vercel or Zeabur
326
328
 
327
- If you want to deploy this service yourself on Vercel, you can follow these steps:
329
+ If you want to deploy this service yourself on either Vercel or Zeabur, you can follow these steps:
328
330
 
329
331
  - Prepare your [OpenAI API Key](https://platform.openai.com/account/api-keys).
330
- - Click the button below to start deployment: Deploy with Vercel. Log in directly with your GitHub account, and remember to fill in the `OPENAI_API_KEY`(required) and `ACCESS_CODE` (recommended) on the environment variable section.
332
+ - Click the button below to start deployment: Log in directly with your GitHub account, and remember to fill in the `OPENAI_API_KEY`(required) and `ACCESS_CODE` (recommended) on the environment variable section.
331
333
  - After deployment, you can start using it.
332
334
  - Bind a custom domain (optional): The DNS of the domain assigned by Vercel is polluted in some areas; binding a custom domain can connect directly.
333
335
 
334
336
  <div align="center">
335
337
 
336
- [![][deploy-button-image]][deploy-link]
338
+ | Deploy with Vercel | Deploy with Zeabur |
339
+ | :-------------------------------------: | :---------------------------------------------------------: |
340
+ | [![][deploy-button-image]][deploy-link] | [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link] |
337
341
 
338
342
  </div>
339
343
 
@@ -380,23 +384,6 @@ $ docker run -d -p 3210:3210 \
380
384
 
381
385
  <br/>
382
386
 
383
- ### `C` Deploying with Zeabur
384
-
385
- If you want to deploy this service yourself on Zeabur, you can follow these steps:
386
-
387
- - Prepare your [OpenAI API Key](https://platform.openai.com/account/api-keys).
388
- - Click the button below to start deployment: Deploy with Zeabur.
389
- - You can start using it after the deployment.
390
- - You can bind a custom domain or use the subdomain provided by Zeabur.
391
-
392
- <div align="center">
393
-
394
- [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link]
395
-
396
- </div>
397
-
398
- <br/>
399
-
400
387
  ### Environment Variable
401
388
 
402
389
  This project provides some additional configuration items set with environment variables:
package/README.zh-CN.md CHANGED
@@ -25,7 +25,8 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
25
25
  [![][github-forks-shield]][github-forks-link]
26
26
  [![][github-stars-shield]][github-stars-link]
27
27
  [![][github-issues-shield]][github-issues-link]
28
- [![][github-license-shield]][github-license-link]
28
+ [![][github-license-shield]][github-license-link]<br>
29
+ [![](https://img.shields.io/badge/-Sponsor%20LobeHub-f04f88?logo=opencollective&logoColor=white&style=flat-square)](https://opencollective.com/lobehub 'Sponsor LobeHub on open-collective')
29
30
 
30
31
  **分享 LobeChat 给你的好友**
31
32
 
@@ -48,9 +49,8 @@ LobeChat 是开源的高性能聊天机器人框架,支持语音合成、多
48
49
  - [✨ 特性一览](#-特性一览)
49
50
  - [⚡️ 性能测试](#️-性能测试)
50
51
  - [🛳 开箱即用](#-开箱即用)
51
- - [`A` 使用 Vercel 部署](#a-使用-vercel-部署)
52
+ - [`A` 使用 Vercel 或 Zeabur 部署](#a-使用-vercel-或-zeabur-部署)
52
53
  - [`B` 使用 Docker 部署](#b-使用-docker-部署)
53
- - [`C` 使用 Zeabur 部署](#c-使用-zeabur-部署)
54
54
  - [环境变量](#环境变量)
55
55
  - [📦 生态系统](#-生态系统)
56
56
  - [🧩 插件体系](#-插件体系)
@@ -182,12 +182,12 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
182
182
 
183
183
  | 最近新增 | 助手说明 |
184
184
  | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
185
+ | [有机化学研究员](https://chat-preview.lobehub.com/market?agent=organic-chemistry-researcher)<br/><sup>By **[y22emc2](https://github.com/y22emc2)** on **2023-12-02**</sup> | 擅长有机化学领域的学术翻译和写作<br/>`有机化学` `科研` `翻译` `写作` `学术文章` |
185
186
  | [JS 代码质量优化](https://chat-preview.lobehub.com/market?agent=js-code-quality)<br/><sup>By **[canisminor1990](https://github.com/canisminor1990)** on **2023-11-22**</sup> | 致力于干净和优雅的代码重构<br/>`重构` `代码优化` `代码质量` |
186
187
  | [LobeChat 测试工程师](https://chat-preview.lobehub.com/market?agent=lobe-chat-unit-test-dev)<br/><sup>By **[arvinxx](https://github.com/arvinxx)** on **2023-11-22**</sup> | 擅长编写前端自动化测试,特别是 TypeScript 应用的全面测试覆盖。熟练使用 Vitest 测试框架,具备深入的测试原理和策略理解。<br/>`自动化测试` `测试` `lobe-chat` `前端` |
187
188
  | [问答文档转换专家](https://chat-preview.lobehub.com/market?agent=q-a-helper)<br/><sup>By **[barryWang12138](https://github.com/barryWang12138)** on **2023-11-22**</sup> | 请提供您的文档内容,我将根据您的要求进行分段和清洗,并按照规范的格式回答。<br/>`q-a` `文档` |
188
- | [真实的老友](https://chat-preview.lobehub.com/market?agent=ai-0x0-old-friends)<br/><sup>By **[mushan0x0](https://github.com/mushan0x0)** on **2023-11-21**</sup> | 可以跟我谈论一切,我可以给你作为老友的一些想法和建议,放轻松<br/>`友情` `幽默` `真实` `模拟` |
189
189
 
190
- > 📊 Total agents: [<kbd>**52**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
190
+ > 📊 Total agents: [<kbd>**53**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
191
191
 
192
192
  <!-- AGENT LIST -->
193
193
 
@@ -296,18 +296,20 @@ LobeChat 提供了 Vercel 的 自托管版本 和 [Docker 镜像][docker-release
296
296
 
297
297
  <br/>
298
298
 
299
- ### `A` 使用 Vercel 部署
299
+ ### `A` 使用 Vercel 或 Zeabur 部署
300
300
 
301
- 如果想在 Vercel 上部署该服务,可以按照以下步骤进行操作:
301
+ 如果想在 Vercel 或 Zeabur 上部署该服务,可以按照以下步骤进行操作:
302
302
 
303
303
  - 准备好你的 [OpenAI API Key](https://platform.openai.com/account/api-keys) 。
304
- - 点击下方按钮开始部署: Deploy with Vercel,直接使用 GitHub 账号登录即可,记得在环境变量页填入 `OPENAI_API_KEY` (必填) and `ACCESS_CODE`(推荐);
304
+ - 点击下方按钮开始部署: 直接使用 GitHub 账号登录即可,记得在环境变量页填入 `OPENAI_API_KEY` (必填) and `ACCESS_CODE`(推荐);
305
305
  - 部署完毕后,即可开始使用;
306
- - 绑定自定义域名(可选):Vercel 分配的域名 DNS 在某些区域被污染了,绑定自定义域名即可直连。
306
+ - 绑定自定义域名(可选):Vercel 分配的域名 DNS 在某些区域被污染了,绑定自定义域名即可直连。目前 Zeabur 提供的域名还未被污染,大多数地区都可以直连。
307
307
 
308
308
  <div align="center">
309
309
 
310
- [![][deploy-button-image]][deploy-link]
310
+ | 使用 Vercel 部署 | 使用 Zeabur 部署 |
311
+ | :-------------------------------------: | :---------------------------------------------------------: |
312
+ | [![][deploy-button-image]][deploy-link] | [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link] |
311
313
 
312
314
  </div>
313
315
 
@@ -354,23 +356,6 @@ $ docker run -d -p 3210:3210 \
354
356
 
355
357
  <br/>
356
358
 
357
- ### `C` 使用 Zeabur 部署
358
-
359
- 如果想在 Zeabur 上部署该服务,可以按照以下步骤进行操作:
360
-
361
- - 准备好你的 [OpenAI API Key](https://platform.openai.com/account/api-keys) 。
362
- - 点击下方按钮开始部署: Deploy to Zeabur
363
- - 部署完毕后,即可开始使用;
364
- - 绑定自定义域名(可选):你可以使用 Zeabur 提供的子域名,也可以选择绑定自定义域名。目前 Zeabur 提供的域名还未被污染,大多数地区都可以直连。
365
-
366
- <div align="center">
367
-
368
- [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link]
369
-
370
- </div>
371
-
372
- <br/>
373
-
374
359
  ### 环境变量
375
360
 
376
361
  本项目提供了一些额外的配置项,使用环境变量进行设置:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.107.13",
3
+ "version": "0.107.15",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -111,7 +111,7 @@
111
111
  "remark-gfm": "^3",
112
112
  "remark-html": "^15",
113
113
  "semver": "^7",
114
- "sharp": "^0.32.6",
114
+ "sharp": "^0.33.0",
115
115
  "swr": "^2",
116
116
  "systemjs": "^6",
117
117
  "ts-md5": "^1",
@@ -151,7 +151,7 @@
151
151
  "eslint": "^8",
152
152
  "fake-indexeddb": "^5",
153
153
  "husky": "^8",
154
- "jsdom": "^22",
154
+ "jsdom": "^23.0.0",
155
155
  "lint-staged": "^15",
156
156
  "lodash": "^4",
157
157
  "markdown-table": "^3",
@@ -22,6 +22,7 @@ const Clear = memo(() => {
22
22
  }, []);
23
23
 
24
24
  useHotkeys(hotkeys, resetConversation, {
25
+ enableOnFormTags: true,
25
26
  preventDefault: true,
26
27
  });
27
28
 
@@ -45,6 +45,7 @@ const List = memo(() => {
45
45
  resendMessage(lastMessage.id);
46
46
  },
47
47
  {
48
+ enableOnFormTags: true,
48
49
  preventDefault: true,
49
50
  },
50
51
  );
@@ -1,6 +1,9 @@
1
1
  import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
2
 
3
3
  import { CreateMessageParams, MessageModel } from '@/database/models/message';
4
+ import { DB_Message } from '@/database/schemas/message';
5
+ import { nanoid } from '@/utils/uuid';
6
+ import * as uuidUtils from '@/utils/uuid';
4
7
 
5
8
  import { CreateTopicParams, QueryTopicParams, TopicModel } from '../topic';
6
9
 
@@ -54,6 +57,43 @@ describe('TopicModel', () => {
54
57
  }),
55
58
  );
56
59
  });
60
+
61
+ it('should update messages with the new topic id when messages are provided', async () => {
62
+ const messagesToUpdate = [nanoid(), nanoid()];
63
+ // 假设这些消息存在于数据库中
64
+ for (const messageId of messagesToUpdate) {
65
+ await MessageModel.table.add({ id: messageId, text: 'Sample message', topicId: null });
66
+ }
67
+
68
+ const topicDataWithMessages = {
69
+ ...topicData,
70
+ messages: messagesToUpdate,
71
+ };
72
+
73
+ const topic = await TopicModel.create(topicDataWithMessages);
74
+ expect(topic).toHaveProperty('id');
75
+
76
+ // 验证数据库中的消息是否已更新
77
+ const updatedMessages: DB_Message[] = await MessageModel.table
78
+ .where('id')
79
+ .anyOf(messagesToUpdate)
80
+ .toArray();
81
+
82
+ expect(updatedMessages).toHaveLength(messagesToUpdate.length);
83
+ for (const message of updatedMessages) {
84
+ expect(message.topicId).toEqual(topic.id);
85
+ }
86
+ });
87
+
88
+ it('should create a topic with a unique id when no id is provided', async () => {
89
+ const spy = vi.spyOn(uuidUtils, 'nanoid'); // 使用 Vitest 的 spy 功能来监视 nanoid 调用
90
+ const result = await TopicModel.create(topicData);
91
+
92
+ expect(spy).toHaveBeenCalled(); // 验证 nanoid 被调用来生成 id
93
+ expect(result).toHaveProperty('id');
94
+ expect(typeof result.id).toBe('string');
95
+ spy.mockRestore(); // 测试结束后恢复原始行为
96
+ });
57
97
  });
58
98
  describe('batch create', () => {
59
99
  it('should batch create topic records', async () => {
@@ -5,6 +5,7 @@ import { nanoid } from '@/utils/uuid';
5
5
 
6
6
  export interface CreateTopicParams {
7
7
  favorite?: boolean;
8
+ messages?: string[];
8
9
  sessionId: string;
9
10
  title: string;
10
11
  }
@@ -20,8 +21,14 @@ class _TopicModel extends BaseModel {
20
21
  super('topics', DB_TopicSchema);
21
22
  }
22
23
 
23
- async create({ title, favorite, sessionId }: CreateTopicParams, id = nanoid()) {
24
- return this._add({ favorite: favorite ? 1 : 0, sessionId, title: title }, id);
24
+ async create({ title, favorite, sessionId, messages }: CreateTopicParams, id = nanoid()) {
25
+ const topic = await this._add({ favorite: favorite ? 1 : 0, sessionId, title: title }, id);
26
+
27
+ // add topicId to these messages
28
+ if (messages) {
29
+ await this.db.messages.where('id').anyOf(messages).modify({ topicId: topic.id });
30
+ }
31
+ return topic;
25
32
  }
26
33
 
27
34
  async batchCreate(topics: CreateTopicParams[]) {
@@ -60,23 +60,17 @@ export const chatTopic: StateCreator<
60
60
  const messages = chatSelectors.currentChats(get());
61
61
  if (messages.length === 0) return;
62
62
 
63
- const { activeId, summaryTopicTitle, refreshTopic, refreshMessages } = get();
63
+ const { activeId, summaryTopicTitle, refreshTopic } = get();
64
64
 
65
- // 1. create topic
65
+ // 1. create topic and bind these messages
66
66
  const topicId = await topicService.createTopic({
67
67
  sessionId: activeId,
68
68
  title: t('topic.defaultTitle', { ns: 'chat' }),
69
+ messages: messages.map((m) => m.id),
69
70
  });
70
71
  await refreshTopic();
71
72
 
72
- // 2.add topicId to these message
73
- await messageService.bindMessagesToTopic(
74
- topicId,
75
- messages.map((m) => m.id),
76
- );
77
- await refreshMessages();
78
-
79
- // 3. auto summary topic Title
73
+ // 2. auto summary topic Title
80
74
  // we don't need to wait for summary, just let it run async
81
75
  summaryTopicTitle(topicId, messages);
82
76