@lobehub/chat 0.107.14 → 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 +25 -0
- package/README.md +12 -25
- package/README.zh-CN.md +10 -25
- package/package.json +3 -3
- package/src/database/models/__tests__/topic.test.ts +40 -0
- package/src/database/models/topic.ts +9 -2
- package/src/store/chat/actions/topic.ts +4 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
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
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.107.14](https://github.com/lobehub/lobe-chat/compare/v0.107.13...v0.107.14)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2023-12-03**</sup>
|
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
<a name="readme-top"></a
|
|
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://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)
|
|
@@ -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:
|
|
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
|
-
|
|
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://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
|
- [🧩 插件体系](#-插件体系)
|
|
@@ -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
|
-
- 点击下方按钮开始部署:
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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": "^
|
|
154
|
+
"jsdom": "^23.0.0",
|
|
155
155
|
"lint-staged": "^15",
|
|
156
156
|
"lodash": "^4",
|
|
157
157
|
"markdown-table": "^3",
|
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
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
|
|