@lobehub/chat 1.37.2 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/src/const/version.ts +2 -0
- package/src/features/Conversation/hooks/useChatListActionsBar.tsx +3 -3
- package/src/locales/default/common.ts +1 -1
- package/src/services/thread/client.ts +57 -0
- package/src/services/thread/index.ts +5 -0
- package/src/services/{thread.ts → thread/server.ts} +3 -20
- package/src/services/thread/type.ts +20 -0
- package/src/store/chat/slices/thread/action.ts +2 -2
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,31 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
## [Version 1.38.0](https://github.com/lobehub/lobe-chat/compare/v1.37.2...v1.38.0)
|
6
|
+
|
7
|
+
<sup>Released on **2024-12-23**</sup>
|
8
|
+
|
9
|
+
#### ✨ Features
|
10
|
+
|
11
|
+
- **misc**: Support thread in client pglite.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### What's improved
|
19
|
+
|
20
|
+
- **misc**: Support thread in client pglite, closes [#5150](https://github.com/lobehub/lobe-chat/issues/5150) ([848b29f](https://github.com/lobehub/lobe-chat/commit/848b29f))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
5
30
|
### [Version 1.37.2](https://github.com/lobehub/lobe-chat/compare/v1.37.1...v1.37.2)
|
6
31
|
|
7
32
|
<sup>Released on **2024-12-22**</sup>
|
package/changelog/v1.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.38.0",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
package/src/const/version.ts
CHANGED
@@ -8,6 +8,8 @@ export const CURRENT_VERSION = pkg.version;
|
|
8
8
|
export const isServerMode = getServerDBConfig().NEXT_PUBLIC_ENABLED_SERVER_SERVICE;
|
9
9
|
export const isUsePgliteDB = process.env.NEXT_PUBLIC_CLIENT_DB === 'pglite';
|
10
10
|
|
11
|
+
export const isDeprecatedEdition = !isServerMode && !isUsePgliteDB;
|
12
|
+
|
11
13
|
// @ts-ignore
|
12
14
|
export const isCustomBranding = BRANDING_NAME !== 'LobeChat';
|
13
15
|
// @ts-ignore
|
@@ -3,7 +3,7 @@ import { Copy, Edit, ListRestart, RotateCcw, Split, Trash } from 'lucide-react';
|
|
3
3
|
import { useMemo } from 'react';
|
4
4
|
import { useTranslation } from 'react-i18next';
|
5
5
|
|
6
|
-
import {
|
6
|
+
import { isDeprecatedEdition } from '@/const/version';
|
7
7
|
|
8
8
|
interface ChatListActionsBar {
|
9
9
|
branching: ActionIconGroupItems;
|
@@ -23,10 +23,10 @@ export const useChatListActionsBar = ({
|
|
23
23
|
return useMemo(
|
24
24
|
() => ({
|
25
25
|
branching: {
|
26
|
-
disable:
|
26
|
+
disable: isDeprecatedEdition,
|
27
27
|
icon: Split,
|
28
28
|
key: 'branching',
|
29
|
-
label:
|
29
|
+
label: !isDeprecatedEdition
|
30
30
|
? t('branching', { defaultValue: 'Create Sub Topic' })
|
31
31
|
: t('branchingDisable'),
|
32
32
|
},
|
@@ -33,7 +33,7 @@ export default {
|
|
33
33
|
blog: '产品博客',
|
34
34
|
branching: '创建子话题',
|
35
35
|
branchingDisable:
|
36
|
-
'
|
36
|
+
'「子话题」功能在当前模式下不可用,如需该功能,请切换到 Postgres/Pglite DB 模式或使用 LobeChat Cloud',
|
37
37
|
cancel: '取消',
|
38
38
|
changelog: '更新日志',
|
39
39
|
clientDB: {
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { INBOX_SESSION_ID } from '@/const/session';
|
2
|
+
import { clientDB } from '@/database/client/db';
|
3
|
+
import { MessageModel } from '@/database/server/models/message';
|
4
|
+
import { ThreadModel } from '@/database/server/models/thread';
|
5
|
+
import { BaseClientService } from '@/services/baseClientService';
|
6
|
+
import { CreateMessageParams } from '@/types/message';
|
7
|
+
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
8
|
+
|
9
|
+
import { IThreadService } from './type';
|
10
|
+
|
11
|
+
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
12
|
+
message: CreateMessageParams;
|
13
|
+
}
|
14
|
+
export class ClientService extends BaseClientService implements IThreadService {
|
15
|
+
private get threadModel(): ThreadModel {
|
16
|
+
return new ThreadModel(clientDB as any, this.userId);
|
17
|
+
}
|
18
|
+
private get messageModel(): MessageModel {
|
19
|
+
return new MessageModel(clientDB as any, this.userId);
|
20
|
+
}
|
21
|
+
|
22
|
+
getThreads = async (topicId: string): Promise<ThreadItem[]> => {
|
23
|
+
return this.threadModel.queryByTopicId(topicId);
|
24
|
+
};
|
25
|
+
|
26
|
+
createThreadWithMessage = async (
|
27
|
+
input: CreateThreadWithMessageParams,
|
28
|
+
): Promise<{ messageId: string; threadId: string }> => {
|
29
|
+
const thread = await this.threadModel.create({
|
30
|
+
parentThreadId: input.parentThreadId,
|
31
|
+
sourceMessageId: input.sourceMessageId,
|
32
|
+
title: input.message.content.slice(0, 20),
|
33
|
+
topicId: input.topicId,
|
34
|
+
type: input.type,
|
35
|
+
});
|
36
|
+
|
37
|
+
const message = await this.messageModel.create({
|
38
|
+
...input.message,
|
39
|
+
sessionId: this.toDbSessionId(input.message.sessionId) as string,
|
40
|
+
threadId: thread?.id,
|
41
|
+
});
|
42
|
+
|
43
|
+
return { messageId: message?.id, threadId: thread?.id };
|
44
|
+
};
|
45
|
+
|
46
|
+
updateThread(id: string, data: Partial<ThreadItem>): Promise<any> {
|
47
|
+
return this.threadModel.update(id, data);
|
48
|
+
}
|
49
|
+
|
50
|
+
removeThread(id: string): Promise<any> {
|
51
|
+
return this.threadModel.delete(id);
|
52
|
+
}
|
53
|
+
|
54
|
+
private toDbSessionId(sessionId: string | undefined) {
|
55
|
+
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
56
|
+
}
|
57
|
+
}
|
@@ -3,10 +3,12 @@ import { lambdaClient } from '@/libs/trpc/client';
|
|
3
3
|
import { CreateMessageParams } from '@/types/message';
|
4
4
|
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
5
5
|
|
6
|
+
import { IThreadService } from './type';
|
7
|
+
|
6
8
|
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
7
9
|
message: CreateMessageParams;
|
8
10
|
}
|
9
|
-
export class
|
11
|
+
export class ServerService implements IThreadService {
|
10
12
|
getThreads = (topicId: string): Promise<ThreadItem[]> => {
|
11
13
|
return lambdaClient.thread.getThreads.query({ topicId });
|
12
14
|
};
|
@@ -21,34 +23,15 @@ export class ThreadService {
|
|
21
23
|
});
|
22
24
|
}
|
23
25
|
|
24
|
-
// createThread(params: CreateThreadParams): Promise<string> {
|
25
|
-
// return lambdaClient.thread.createThread.mutate(params);
|
26
|
-
// }
|
27
|
-
|
28
26
|
updateThread(id: string, data: Partial<ThreadItem>): Promise<any> {
|
29
27
|
return lambdaClient.thread.updateThread.mutate({ id, value: data });
|
30
28
|
}
|
31
29
|
|
32
|
-
//
|
33
30
|
removeThread(id: string): Promise<any> {
|
34
31
|
return lambdaClient.thread.removeThread.mutate({ id });
|
35
32
|
}
|
36
|
-
//
|
37
|
-
// removeThreads(sessionId: string): Promise<any> {
|
38
|
-
// return lambdaClient.thread.batchDeleteBySessionId.mutate({ id: this.toDbSessionId(sessionId) });
|
39
|
-
// }
|
40
|
-
//
|
41
|
-
// batchRemoveThreads(topics: string[]): Promise<any> {
|
42
|
-
// return lambdaClient.thread.batchDelete.mutate({ ids: topics });
|
43
|
-
// }
|
44
|
-
//
|
45
|
-
// removeAllThread(): Promise<any> {
|
46
|
-
// return lambdaClient.thread.removeAllThreads.mutate();
|
47
|
-
// }
|
48
33
|
|
49
34
|
private toDbSessionId(sessionId: string | undefined) {
|
50
35
|
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
51
36
|
}
|
52
37
|
}
|
53
|
-
|
54
|
-
export const threadService = new ThreadService();
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/* eslint-disable typescript-sort-keys/interface */
|
2
|
+
import { CreateMessageParams } from '@/types/message';
|
3
|
+
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
4
|
+
|
5
|
+
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
6
|
+
message: CreateMessageParams;
|
7
|
+
}
|
8
|
+
|
9
|
+
export interface IThreadService {
|
10
|
+
getThreads(topicId: string): Promise<ThreadItem[]>;
|
11
|
+
|
12
|
+
createThreadWithMessage({
|
13
|
+
message,
|
14
|
+
...params
|
15
|
+
}: CreateThreadWithMessageParams): Promise<{ messageId: string; threadId: string }>;
|
16
|
+
|
17
|
+
updateThread(id: string, data: Partial<ThreadItem>): Promise<any>;
|
18
|
+
//
|
19
|
+
removeThread(id: string): Promise<any>;
|
20
|
+
}
|
@@ -6,7 +6,7 @@ import { StateCreator } from 'zustand/vanilla';
|
|
6
6
|
|
7
7
|
import { chainSummaryTitle } from '@/chains/summaryTitle';
|
8
8
|
import { LOADING_FLAT, THREAD_DRAFT_ID } from '@/const/message';
|
9
|
-
import {
|
9
|
+
import { isDeprecatedEdition } from '@/const/version';
|
10
10
|
import { useClientDataSWR } from '@/libs/swr';
|
11
11
|
import { chatService } from '@/services/chat';
|
12
12
|
import { threadService } from '@/services/thread';
|
@@ -211,7 +211,7 @@ export const chatThreadMessage: StateCreator<
|
|
211
211
|
|
212
212
|
useFetchThreads: (enable, topicId) =>
|
213
213
|
useClientDataSWR<ThreadItem[]>(
|
214
|
-
enable && !!topicId &&
|
214
|
+
enable && !!topicId && !isDeprecatedEdition ? [SWR_USE_FETCH_THREADS, topicId] : null,
|
215
215
|
async ([, topicId]: [string, string]) => threadService.getThreads(topicId),
|
216
216
|
{
|
217
217
|
suspense: true,
|