@lobehub/chat 0.161.16 → 0.161.17
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/package.json +1 -1
- package/src/app/(main)/chat/@session/features/SessionListContent/List/Item/index.tsx +1 -1
- package/src/app/(main)/chat/_layout/Desktop/index.tsx +3 -0
- package/src/app/(main)/chat/settings/features/EditPage.tsx +5 -1
- package/src/app/(main)/welcome/_layout/Desktop.tsx +21 -16
- package/src/app/@modal/chat/(.)settings/modal/layout.tsx +5 -2
- package/src/app/metadata.ts +1 -1
- package/src/const/session.ts +2 -2
- package/src/const/settings/agent.ts +6 -2
- package/src/database/client/core/db.ts +22 -0
- package/src/database/client/core/migrations/migrateSettingsToUser/index.ts +3 -5
- package/src/database/client/core/migrations/migrateSettingsToUser/type.ts +18 -10
- package/src/database/client/models/session.ts +4 -0
- package/src/database/client/schemas/session.ts +2 -9
- package/src/features/AgentSetting/AgentChat/index.tsx +19 -10
- package/src/features/AgentSetting/AgentModal/index.tsx +2 -1
- package/src/features/AgentSetting/StoreUpdater.tsx +3 -2
- package/src/features/AgentSetting/store/action.ts +12 -5
- package/src/features/AgentSetting/store/initialState.ts +2 -1
- package/src/features/AgentSetting/store/selectors.ts +11 -0
- package/src/features/ChatInput/ActionBar/History.tsx +2 -2
- package/src/features/Conversation/components/ChatItem/index.tsx +2 -2
- package/src/migrations/FromV5ToV6/fixtures/from-v1-to-v6-output.json +247 -0
- package/src/migrations/FromV5ToV6/fixtures/session-input-v5.json +81 -0
- package/src/migrations/FromV5ToV6/fixtures/session-output-v6.json +85 -0
- package/src/migrations/FromV5ToV6/index.ts +61 -0
- package/src/migrations/FromV5ToV6/migrations.test.ts +50 -0
- package/src/migrations/FromV5ToV6/types/v5.ts +48 -0
- package/src/migrations/FromV5ToV6/types/v6.ts +60 -0
- package/src/migrations/index.ts +8 -1
- package/src/services/session/client.test.ts +1 -1
- package/src/services/session/client.ts +18 -2
- package/src/services/session/type.ts +11 -2
- package/src/store/agent/slices/chat/__snapshots__/selectors.test.ts.snap +6 -4
- package/src/store/agent/slices/chat/action.test.ts +15 -3
- package/src/store/agent/slices/chat/action.ts +51 -5
- package/src/store/agent/slices/chat/initialState.ts +2 -0
- package/src/store/agent/slices/chat/selectors.test.ts +0 -3
- package/src/store/agent/slices/chat/selectors.ts +10 -2
- package/src/store/chat/helpers.test.ts +6 -6
- package/src/store/chat/helpers.ts +2 -2
- package/src/store/chat/slices/message/action.test.ts +9 -4
- package/src/store/chat/slices/message/action.ts +19 -15
- package/src/store/chat/slices/message/selectors.test.ts +4 -2
- package/src/store/chat/slices/message/selectors.ts +1 -1
- package/src/store/session/slices/session/action.test.ts +6 -7
- package/src/store/user/slices/settings/selectors/__snapshots__/settings.test.ts.snap +6 -4
- package/src/types/agent/index.ts +37 -19
- package/src/types/session/agentSession.ts +35 -0
- package/src/types/session/index.ts +10 -0
- package/src/types/session/sessionGroup.ts +24 -0
- package/vitest.config.ts +7 -1
- package/src/types/session.ts +0 -57
- /package/public/{icons/apple-touch-icon.png → apple-touch-icon.png} +0 -0
package/src/types/agent/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
import { FewShots, LLMParams } from '@/types/llm';
|
|
2
4
|
|
|
3
5
|
export type TTSServer = 'openai' | 'edge' | 'microsoft';
|
|
@@ -12,27 +14,10 @@ export interface LobeAgentTTSConfig {
|
|
|
12
14
|
openai: string;
|
|
13
15
|
};
|
|
14
16
|
}
|
|
15
|
-
export interface LobeAgentConfig {
|
|
16
|
-
autoCreateTopicThreshold: number;
|
|
17
|
-
compressThreshold?: number;
|
|
18
|
-
displayMode?: 'chat' | 'docs';
|
|
19
|
-
enableAutoCreateTopic: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* 历史消息长度压缩阈值
|
|
22
|
-
*/
|
|
23
|
-
enableCompressThreshold?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* 开启历史记录条数
|
|
26
|
-
*/
|
|
27
|
-
enableHistoryCount?: boolean;
|
|
28
|
-
enableMaxTokens?: boolean;
|
|
29
17
|
|
|
18
|
+
export interface LobeAgentConfig {
|
|
19
|
+
chatConfig: LobeAgentChatConfig;
|
|
30
20
|
fewShots?: FewShots;
|
|
31
|
-
/**
|
|
32
|
-
* 历史消息条数
|
|
33
|
-
*/
|
|
34
|
-
historyCount?: number;
|
|
35
|
-
inputTemplate?: string;
|
|
36
21
|
/**
|
|
37
22
|
* 角色所使用的语言模型
|
|
38
23
|
* @default gpt-3.5-turbo
|
|
@@ -60,6 +45,39 @@ export interface LobeAgentConfig {
|
|
|
60
45
|
tts: LobeAgentTTSConfig;
|
|
61
46
|
}
|
|
62
47
|
|
|
48
|
+
export interface LobeAgentChatConfig {
|
|
49
|
+
autoCreateTopicThreshold: number;
|
|
50
|
+
compressThreshold?: number;
|
|
51
|
+
displayMode?: 'chat' | 'docs';
|
|
52
|
+
enableAutoCreateTopic?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 历史消息长度压缩阈值
|
|
55
|
+
*/
|
|
56
|
+
enableCompressThreshold?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 开启历史记录条数
|
|
59
|
+
*/
|
|
60
|
+
enableHistoryCount?: boolean;
|
|
61
|
+
enableMaxTokens?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 历史消息条数
|
|
65
|
+
*/
|
|
66
|
+
historyCount?: number;
|
|
67
|
+
inputTemplate?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const AgentChatConfigSchema = z.object({
|
|
71
|
+
autoCreateTopicThreshold: z.number().default(2),
|
|
72
|
+
compressThreshold: z.number().optional(),
|
|
73
|
+
displayMode: z.enum(['chat', 'docs']).optional(),
|
|
74
|
+
enableAutoCreateTopic: z.boolean().optional(),
|
|
75
|
+
enableCompressThreshold: z.boolean().optional(),
|
|
76
|
+
enableHistoryCount: z.boolean().optional(),
|
|
77
|
+
enableMaxTokens: z.boolean().optional(),
|
|
78
|
+
historyCount: z.number().optional(),
|
|
79
|
+
});
|
|
80
|
+
|
|
63
81
|
export type LobeAgentConfigKeys =
|
|
64
82
|
| keyof LobeAgentConfig
|
|
65
83
|
| ['params', keyof LobeAgentConfig['params']];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { LobeAgentConfig } from '@/types/agent';
|
|
2
|
+
|
|
3
|
+
import { MetaData } from '../meta';
|
|
4
|
+
import { SessionGroupId } from './sessionGroup';
|
|
5
|
+
|
|
6
|
+
export enum LobeSessionType {
|
|
7
|
+
Agent = 'agent',
|
|
8
|
+
Group = 'group',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Lobe Agent
|
|
13
|
+
*/
|
|
14
|
+
export interface LobeAgentSession {
|
|
15
|
+
config: LobeAgentConfig;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
group?: SessionGroupId;
|
|
18
|
+
id: string;
|
|
19
|
+
meta: MetaData;
|
|
20
|
+
model: string;
|
|
21
|
+
pinned?: boolean;
|
|
22
|
+
tags?: string[];
|
|
23
|
+
type: LobeSessionType.Agent;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface LobeAgentSettings {
|
|
28
|
+
/**
|
|
29
|
+
* 语言模型角色设定
|
|
30
|
+
*/
|
|
31
|
+
config: LobeAgentConfig;
|
|
32
|
+
meta: MetaData;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type LobeSessions = LobeAgentSession[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LobeSessions } from '@/types/session/agentSession';
|
|
2
|
+
import { LobeSessionGroups } from '@/types/session/sessionGroup';
|
|
3
|
+
|
|
4
|
+
export * from './agentSession';
|
|
5
|
+
export * from './sessionGroup';
|
|
6
|
+
|
|
7
|
+
export interface ChatSessionList {
|
|
8
|
+
sessionGroups: LobeSessionGroups;
|
|
9
|
+
sessions: LobeSessions;
|
|
10
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LobeSessions } from './agentSession';
|
|
2
|
+
|
|
3
|
+
export enum SessionDefaultGroup {
|
|
4
|
+
Default = 'default',
|
|
5
|
+
Pinned = 'pinned',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type SessionGroupId = SessionDefaultGroup | string;
|
|
9
|
+
|
|
10
|
+
export interface SessionGroupItem {
|
|
11
|
+
createdAt: number;
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
sort?: number;
|
|
15
|
+
updatedAt: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type SessionGroups = SessionGroupItem[];
|
|
19
|
+
|
|
20
|
+
export interface CustomSessionGroup extends SessionGroupItem {
|
|
21
|
+
children: LobeSessions;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type LobeSessionGroups = SessionGroupItem[];
|
package/vitest.config.ts
CHANGED
|
@@ -13,7 +13,13 @@ export default defineConfig({
|
|
|
13
13
|
},
|
|
14
14
|
coverage: {
|
|
15
15
|
all: false,
|
|
16
|
-
exclude: [
|
|
16
|
+
exclude: [
|
|
17
|
+
'__mocks__/**',
|
|
18
|
+
// just ignore the migration code
|
|
19
|
+
// we will use pglite in the future
|
|
20
|
+
// so the coverage of this file is not important
|
|
21
|
+
'src/database/client/core/db.ts',
|
|
22
|
+
],
|
|
17
23
|
provider: 'v8',
|
|
18
24
|
reporter: ['text', 'json', 'lcov', 'text-summary'],
|
|
19
25
|
},
|
package/src/types/session.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { LobeAgentConfig } from '@/types/agent';
|
|
2
|
-
|
|
3
|
-
import { BaseDataModel, MetaData } from './meta';
|
|
4
|
-
|
|
5
|
-
export enum LobeSessionType {
|
|
6
|
-
Agent = 'agent',
|
|
7
|
-
Group = 'group',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type SessionGroupId = SessionDefaultGroup | string;
|
|
11
|
-
|
|
12
|
-
export enum SessionDefaultGroup {
|
|
13
|
-
Default = 'default',
|
|
14
|
-
Pinned = 'pinned',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface SessionGroupItem {
|
|
18
|
-
createdAt: number;
|
|
19
|
-
id: string;
|
|
20
|
-
name: string;
|
|
21
|
-
sort?: number;
|
|
22
|
-
updatedAt: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type SessionGroups = SessionGroupItem[];
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Lobe Agent
|
|
29
|
-
*/
|
|
30
|
-
export interface LobeAgentSession extends BaseDataModel {
|
|
31
|
-
config: LobeAgentConfig;
|
|
32
|
-
group?: SessionGroupId;
|
|
33
|
-
model: string;
|
|
34
|
-
pinned?: boolean;
|
|
35
|
-
type: LobeSessionType.Agent;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface LobeAgentSettings {
|
|
39
|
-
/**
|
|
40
|
-
* 语言模型角色设定
|
|
41
|
-
*/
|
|
42
|
-
config: LobeAgentConfig;
|
|
43
|
-
meta: MetaData;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type LobeSessions = LobeAgentSession[];
|
|
47
|
-
|
|
48
|
-
export interface CustomSessionGroup extends SessionGroupItem {
|
|
49
|
-
children: LobeSessions;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type LobeSessionGroups = SessionGroupItem[];
|
|
53
|
-
|
|
54
|
-
export interface ChatSessionList {
|
|
55
|
-
sessionGroups: LobeSessionGroups;
|
|
56
|
-
sessions: LobeSessions;
|
|
57
|
-
}
|
|
File without changes
|