@lobehub/lobehub 2.0.0-next.26 → 2.0.0-next.27
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/packages/types/src/topic/topic.ts +14 -0
- package/src/server/routers/lambda/topic.ts +7 -1
- package/src/services/aiModel/index.test.ts +3 -3
- package/src/services/aiModel/index.ts +56 -2
- package/src/services/aiProvider/index.test.ts +2 -2
- package/src/services/aiProvider/index.ts +48 -2
- package/src/services/chatGroup/index.ts +66 -2
- package/src/services/export/index.ts +10 -2
- package/src/services/file/index.ts +61 -2
- package/src/services/import/index.ts +133 -2
- package/src/services/message/index.ts +176 -2
- package/src/services/message/{__tests__/server.test.ts → server.test.ts} +3 -3
- package/src/services/plugin/index.test.ts +8 -0
- package/src/services/plugin/index.ts +53 -2
- package/src/services/session/index.test.ts +8 -0
- package/src/services/session/index.ts +145 -2
- package/src/services/thread/index.test.ts +8 -0
- package/src/services/thread/index.ts +38 -2
- package/src/services/topic/index.test.ts +8 -0
- package/src/services/topic/index.ts +76 -2
- package/src/services/user/index.test.ts +8 -0
- package/src/services/user/index.ts +53 -2
- package/src/store/aiInfra/slices/aiModel/action.test.ts +17 -9
- package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +4 -2
- package/src/store/chat/slices/topic/action.test.ts +1 -1
- package/src/store/chat/slices/topic/action.ts +1 -2
- package/src/store/chat/slices/topic/reducer.ts +1 -2
- package/src/store/file/slices/chat/action.ts +1 -4
- package/src/store/file/slices/fileManager/action.ts +2 -3
- package/src/store/session/slices/sessionGroup/action.test.ts +5 -5
- package/src/store/user/slices/common/action.test.ts +1 -1
- package/src/services/aiModel/server.test.ts +0 -122
- package/src/services/aiModel/server.ts +0 -51
- package/src/services/aiModel/type.ts +0 -32
- package/src/services/aiProvider/server.ts +0 -43
- package/src/services/aiProvider/type.ts +0 -27
- package/src/services/chatGroup/server.ts +0 -67
- package/src/services/chatGroup/type.ts +0 -22
- package/src/services/export/server.ts +0 -9
- package/src/services/export/type.ts +0 -5
- package/src/services/file/server.ts +0 -53
- package/src/services/file/type.ts +0 -13
- package/src/services/import/server.ts +0 -133
- package/src/services/import/type.ts +0 -17
- package/src/services/message/server.ts +0 -151
- package/src/services/message/type.ts +0 -55
- package/src/services/plugin/server.ts +0 -42
- package/src/services/plugin/type.ts +0 -23
- package/src/services/session/server.test.ts +0 -260
- package/src/services/session/server.ts +0 -125
- package/src/services/session/type.ts +0 -82
- package/src/services/thread/server.ts +0 -32
- package/src/services/thread/type.ts +0 -21
- package/src/services/topic/server.ts +0 -57
- package/src/services/topic/type.ts +0 -40
- package/src/services/user/server.test.ts +0 -149
- package/src/services/user/server.ts +0 -47
- package/src/services/user/type.ts +0 -21
|
@@ -2,11 +2,11 @@ import { describe, expect, it } from 'vitest';
|
|
|
2
2
|
|
|
3
3
|
import { INBOX_SESSION_ID } from '@/const/session';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { MessageService } from './index';
|
|
6
6
|
|
|
7
|
-
describe('
|
|
7
|
+
describe('MessageService', () => {
|
|
8
8
|
describe('toDbSessionId', () => {
|
|
9
|
-
const service = new
|
|
9
|
+
const service = new MessageService();
|
|
10
10
|
// @ts-ignore access private method for testing
|
|
11
11
|
const toDbSessionId = service.toDbSessionId;
|
|
12
12
|
|
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LobeTool } from '@lobechat/types';
|
|
2
|
+
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { lambdaClient } from '@/libs/trpc/client';
|
|
5
|
+
import { LobeToolCustomPlugin } from '@/types/tool/plugin';
|
|
6
|
+
|
|
7
|
+
export interface InstallPluginParams {
|
|
8
|
+
customParams?: Record<string, any>;
|
|
9
|
+
identifier: string;
|
|
10
|
+
manifest: LobeChatPluginManifest;
|
|
11
|
+
settings?: Record<string, any>;
|
|
12
|
+
type: 'plugin' | 'customPlugin';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class PluginService {
|
|
16
|
+
installPlugin = async (plugin: InstallPluginParams): Promise<void> => {
|
|
17
|
+
await lambdaClient.plugin.createOrInstallPlugin.mutate(plugin);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
getInstalledPlugins = (): Promise<LobeTool[]> => {
|
|
21
|
+
return lambdaClient.plugin.getPlugins.query();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
uninstallPlugin = async (identifier: string): Promise<void> => {
|
|
25
|
+
await lambdaClient.plugin.removePlugin.mutate({ id: identifier });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
createCustomPlugin = async (customPlugin: LobeToolCustomPlugin): Promise<void> => {
|
|
29
|
+
await lambdaClient.plugin.createPlugin.mutate({ ...customPlugin, type: 'customPlugin' });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
updatePlugin = async (id: string, value: Partial<LobeToolCustomPlugin>): Promise<void> => {
|
|
33
|
+
await lambdaClient.plugin.updatePlugin.mutate({
|
|
34
|
+
customParams: value.customParams,
|
|
35
|
+
id,
|
|
36
|
+
manifest: value.manifest,
|
|
37
|
+
settings: value.settings,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
updatePluginManifest = async (id: string, manifest: LobeChatPluginManifest): Promise<void> => {
|
|
42
|
+
await lambdaClient.plugin.updatePlugin.mutate({ id, manifest });
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
removeAllPlugins = async (): Promise<void> => {
|
|
46
|
+
await lambdaClient.plugin.removeAllPlugins.mutate();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
updatePluginSettings = async (id: string, settings: any, signal?: AbortSignal): Promise<void> => {
|
|
50
|
+
await lambdaClient.plugin.updatePlugin.mutate({ id, settings }, { signal });
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const pluginService = new PluginService();
|
|
@@ -1,3 +1,146 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { lambdaClient } from '@/libs/trpc/client';
|
|
5
|
+
import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
|
|
6
|
+
import { MetaData } from '@/types/meta';
|
|
7
|
+
import { BatchTaskResult } from '@/types/service';
|
|
8
|
+
import {
|
|
9
|
+
ChatSessionList,
|
|
10
|
+
LobeAgentSession,
|
|
11
|
+
LobeSessionType,
|
|
12
|
+
LobeSessions,
|
|
13
|
+
SessionGroupItem,
|
|
14
|
+
SessionGroups,
|
|
15
|
+
SessionRankItem,
|
|
16
|
+
UpdateSessionParams,
|
|
17
|
+
} from '@/types/session';
|
|
18
|
+
|
|
19
|
+
export class SessionService {
|
|
20
|
+
hasSessions = async (): Promise<boolean> => {
|
|
21
|
+
const result = await this.countSessions();
|
|
22
|
+
return result === 0;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
createSession = async (
|
|
26
|
+
type: LobeSessionType,
|
|
27
|
+
data: Partial<LobeAgentSession>,
|
|
28
|
+
): Promise<string> => {
|
|
29
|
+
const { config, group, meta, ...session } = data;
|
|
30
|
+
return lambdaClient.session.createSession.mutate({
|
|
31
|
+
config: { ...config, ...meta } as any,
|
|
32
|
+
session: { ...session, groupId: group },
|
|
33
|
+
type,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
cloneSession = (id: string, newTitle: string): Promise<string | undefined> => {
|
|
38
|
+
return lambdaClient.session.cloneSession.mutate({ id, newTitle });
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
getGroupedSessions = (): Promise<ChatSessionList> => {
|
|
42
|
+
return lambdaClient.session.getGroupedSessions.query();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
countSessions = async (params?: {
|
|
46
|
+
endDate?: string;
|
|
47
|
+
range?: [string, string];
|
|
48
|
+
startDate?: string;
|
|
49
|
+
}): Promise<number> => {
|
|
50
|
+
return lambdaClient.session.countSessions.query(params);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
rankSessions = async (limit?: number): Promise<SessionRankItem[]> => {
|
|
54
|
+
return lambdaClient.session.rankSessions.query(limit);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
updateSession = (id: string, data: Partial<UpdateSessionParams>) => {
|
|
58
|
+
const { group, pinned, meta, updatedAt } = data;
|
|
59
|
+
return lambdaClient.session.updateSession.mutate({
|
|
60
|
+
id,
|
|
61
|
+
value: { groupId: group === 'default' ? null : group, pinned, ...meta, updatedAt },
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// TODO: Need to be fixed
|
|
66
|
+
getSessionConfig = async (id: string): Promise<LobeAgentConfig> => {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
return lambdaClient.agent.getAgentConfig.query({ sessionId: id });
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
updateSessionConfig = (
|
|
72
|
+
id: string,
|
|
73
|
+
config: PartialDeep<LobeAgentConfig>,
|
|
74
|
+
signal?: AbortSignal,
|
|
75
|
+
) => {
|
|
76
|
+
return lambdaClient.session.updateSessionConfig.mutate(
|
|
77
|
+
{ id, value: config },
|
|
78
|
+
{
|
|
79
|
+
context: { showNotification: false },
|
|
80
|
+
signal,
|
|
81
|
+
},
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
updateSessionMeta = (id: string, meta: Partial<MetaData>, signal?: AbortSignal) => {
|
|
86
|
+
return lambdaClient.session.updateSessionConfig.mutate({ id, value: meta }, { signal });
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
updateSessionChatConfig = (
|
|
90
|
+
id: string,
|
|
91
|
+
value: Partial<LobeAgentChatConfig>,
|
|
92
|
+
signal?: AbortSignal,
|
|
93
|
+
) => {
|
|
94
|
+
return lambdaClient.session.updateSessionChatConfig.mutate({ id, value }, { signal });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
searchSessions = (keywords: string): Promise<LobeSessions> => {
|
|
98
|
+
return lambdaClient.session.searchSessions.query({ keywords });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
removeSession = (id: string) => {
|
|
102
|
+
return lambdaClient.session.removeSession.mutate({ id });
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
removeAllSessions = () => {
|
|
106
|
+
return lambdaClient.session.removeAllSessions.mutate();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ************************************** //
|
|
110
|
+
// *********** SessionGroup *********** //
|
|
111
|
+
// ************************************** //
|
|
112
|
+
|
|
113
|
+
createSessionGroup = (name: string, sort?: number): Promise<string> => {
|
|
114
|
+
return lambdaClient.sessionGroup.createSessionGroup.mutate({ name, sort });
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
getSessionGroups = (): Promise<SessionGroupItem[]> => {
|
|
118
|
+
return lambdaClient.sessionGroup.getSessionGroup.query();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 需要废弃
|
|
123
|
+
* @deprecated
|
|
124
|
+
*/
|
|
125
|
+
batchCreateSessionGroups = (groups: SessionGroups): Promise<BatchTaskResult> => {
|
|
126
|
+
return Promise.resolve({ added: 0, ids: [], skips: [], success: true });
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
removeSessionGroup = (id: string, removeChildren?: boolean) => {
|
|
130
|
+
return lambdaClient.sessionGroup.removeSessionGroup.mutate({ id, removeChildren });
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
removeSessionGroups = () => {
|
|
134
|
+
return lambdaClient.sessionGroup.removeAllSessionGroups.mutate();
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
updateSessionGroup = (id: string, value: Partial<SessionGroupItem>) => {
|
|
138
|
+
return lambdaClient.sessionGroup.updateSessionGroup.mutate({ id, value });
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
updateSessionGroupOrder = (sortMap: { id: string; sort: number }[]) => {
|
|
142
|
+
return lambdaClient.sessionGroup.updateSessionGroupOrder.mutate({ sortMap });
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const sessionService = new SessionService();
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateMessageParams } from '@lobechat/types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { INBOX_SESSION_ID } from '@/const/session';
|
|
4
|
+
import { lambdaClient } from '@/libs/trpc/client';
|
|
5
|
+
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
|
6
|
+
|
|
7
|
+
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
|
8
|
+
message: CreateMessageParams;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ThreadService {
|
|
12
|
+
getThreads = (topicId: string): Promise<ThreadItem[]> => {
|
|
13
|
+
return lambdaClient.thread.getThreads.query({ topicId });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
createThreadWithMessage = async ({
|
|
17
|
+
message,
|
|
18
|
+
...params
|
|
19
|
+
}: CreateThreadWithMessageParams): Promise<{ messageId: string; threadId: string }> => {
|
|
20
|
+
return lambdaClient.thread.createThreadWithMessage.mutate({
|
|
21
|
+
...params,
|
|
22
|
+
message: { ...message, sessionId: this.toDbSessionId(message.sessionId) },
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
updateThread = async (id: string, data: Partial<ThreadItem>) => {
|
|
27
|
+
return lambdaClient.thread.updateThread.mutate({ id, value: data });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
removeThread = async (id: string) => {
|
|
31
|
+
return lambdaClient.thread.removeThread.mutate({ id });
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
private toDbSessionId = (sessionId: string | undefined) => {
|
|
35
|
+
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const threadService = new ThreadService();
|
|
@@ -1,3 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INBOX_SESSION_ID } from '@/const/session';
|
|
2
|
+
import { lambdaClient } from '@/libs/trpc/client';
|
|
3
|
+
import { BatchTaskResult } from '@/types/service';
|
|
4
|
+
import { ChatTopic, CreateTopicParams, QueryTopicParams, TopicRankItem } from '@/types/topic';
|
|
2
5
|
|
|
3
|
-
export
|
|
6
|
+
export class TopicService {
|
|
7
|
+
createTopic = (params: CreateTopicParams): Promise<string> => {
|
|
8
|
+
return lambdaClient.topic.createTopic.mutate({
|
|
9
|
+
...params,
|
|
10
|
+
sessionId: this.toDbSessionId(params.sessionId),
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
batchCreateTopics = (importTopics: ChatTopic[]): Promise<BatchTaskResult> => {
|
|
15
|
+
return lambdaClient.topic.batchCreateTopics.mutate(importTopics);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
cloneTopic = (id: string, newTitle?: string): Promise<string> => {
|
|
19
|
+
return lambdaClient.topic.cloneTopic.mutate({ id, newTitle });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
getTopics = (params: QueryTopicParams): Promise<ChatTopic[]> => {
|
|
23
|
+
return lambdaClient.topic.getTopics.query({
|
|
24
|
+
...params,
|
|
25
|
+
containerId: this.toDbSessionId(params.containerId),
|
|
26
|
+
}) as any;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
getAllTopics = (): Promise<ChatTopic[]> => {
|
|
30
|
+
return lambdaClient.topic.getAllTopics.query() as any;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
countTopics = async (params?: {
|
|
34
|
+
endDate?: string;
|
|
35
|
+
range?: [string, string];
|
|
36
|
+
startDate?: string;
|
|
37
|
+
}): Promise<number> => {
|
|
38
|
+
return lambdaClient.topic.countTopics.query(params);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
rankTopics = async (limit?: number): Promise<TopicRankItem[]> => {
|
|
42
|
+
return lambdaClient.topic.rankTopics.query(limit);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
searchTopics = (keywords: string, sessionId?: string, groupId?: string): Promise<ChatTopic[]> => {
|
|
46
|
+
return lambdaClient.topic.searchTopics.query({
|
|
47
|
+
groupId,
|
|
48
|
+
keywords,
|
|
49
|
+
sessionId: this.toDbSessionId(sessionId),
|
|
50
|
+
}) as any;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
updateTopic = (id: string, data: Partial<ChatTopic>) => {
|
|
54
|
+
return lambdaClient.topic.updateTopic.mutate({ id, value: data });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
removeTopic = (id: string) => {
|
|
58
|
+
return lambdaClient.topic.removeTopic.mutate({ id });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
removeTopics = (sessionId: string) => {
|
|
62
|
+
return lambdaClient.topic.batchDeleteBySessionId.mutate({ id: this.toDbSessionId(sessionId) });
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
batchRemoveTopics = (topics: string[]) => {
|
|
66
|
+
return lambdaClient.topic.batchDelete.mutate({ ids: topics });
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
removeAllTopic = () => {
|
|
70
|
+
return lambdaClient.topic.removeAllTopics.mutate();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
private toDbSessionId = (sessionId?: string | null) =>
|
|
74
|
+
sessionId === INBOX_SESSION_ID ? null : sessionId;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const topicService = new TopicService();
|
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AdapterAccount } from 'next-auth/adapters';
|
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { lambdaClient } from '@/libs/trpc/client';
|
|
5
|
+
import { UserGuide, UserInitializationState, UserPreference } from '@/types/user';
|
|
6
|
+
import { UserSettings } from '@/types/user/settings';
|
|
7
|
+
|
|
8
|
+
export class UserService {
|
|
9
|
+
getUserRegistrationDuration = async (): Promise<{
|
|
10
|
+
createdAt: string;
|
|
11
|
+
duration: number;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}> => {
|
|
14
|
+
return lambdaClient.user.getUserRegistrationDuration.query();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
getUserState = async (): Promise<UserInitializationState> => {
|
|
18
|
+
return lambdaClient.user.getUserState.query();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
getUserSSOProviders = async (): Promise<AdapterAccount[]> => {
|
|
22
|
+
return lambdaClient.user.getUserSSOProviders.query();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
unlinkSSOProvider = async (provider: string, providerAccountId: string) => {
|
|
26
|
+
return lambdaClient.user.unlinkSSOProvider.mutate({ provider, providerAccountId });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
makeUserOnboarded = async () => {
|
|
30
|
+
return lambdaClient.user.makeUserOnboarded.mutate();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
updateAvatar = async (avatar: string) => {
|
|
34
|
+
return lambdaClient.user.updateAvatar.mutate(avatar);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
updatePreference = async (preference: Partial<UserPreference>) => {
|
|
38
|
+
return lambdaClient.user.updatePreference.mutate(preference);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
updateGuide = async (guide: Partial<UserGuide>) => {
|
|
42
|
+
return lambdaClient.user.updateGuide.mutate(guide);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
updateUserSettings = async (value: PartialDeep<UserSettings>, signal?: AbortSignal) => {
|
|
46
|
+
return lambdaClient.user.updateSettings.mutate(value, { signal });
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
resetUserSettings = async () => {
|
|
50
|
+
return lambdaClient.user.resetSettings.mutate();
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const userService = new UserService();
|
|
@@ -101,7 +101,7 @@ describe('AiModelAction', () => {
|
|
|
101
101
|
.mockResolvedValue(undefined);
|
|
102
102
|
const serviceSpy = vi
|
|
103
103
|
.spyOn(aiModelService, 'batchUpdateAiModels')
|
|
104
|
-
.mockResolvedValue(undefined);
|
|
104
|
+
.mockResolvedValue(undefined as any);
|
|
105
105
|
|
|
106
106
|
await act(async () => {
|
|
107
107
|
await result.current.batchUpdateAiModels(models);
|
|
@@ -119,7 +119,7 @@ describe('AiModelAction', () => {
|
|
|
119
119
|
const { result } = renderHook(() => useStore());
|
|
120
120
|
const serviceSpy = vi
|
|
121
121
|
.spyOn(aiModelService, 'batchUpdateAiModels')
|
|
122
|
-
.mockResolvedValue(undefined);
|
|
122
|
+
.mockResolvedValue(undefined as any);
|
|
123
123
|
|
|
124
124
|
await act(async () => {
|
|
125
125
|
await result.current.batchUpdateAiModels([]);
|
|
@@ -137,7 +137,7 @@ describe('AiModelAction', () => {
|
|
|
137
137
|
.mockResolvedValue(undefined);
|
|
138
138
|
const serviceSpy = vi
|
|
139
139
|
.spyOn(aiModelService, 'clearModelsByProvider')
|
|
140
|
-
.mockResolvedValue(undefined);
|
|
140
|
+
.mockResolvedValue(undefined as any);
|
|
141
141
|
|
|
142
142
|
await act(async () => {
|
|
143
143
|
await result.current.clearModelsByProvider('test-provider');
|
|
@@ -154,7 +154,9 @@ describe('AiModelAction', () => {
|
|
|
154
154
|
const refreshSpy = vi
|
|
155
155
|
.spyOn(result.current, 'refreshAiModelList')
|
|
156
156
|
.mockResolvedValue(undefined);
|
|
157
|
-
const serviceSpy = vi
|
|
157
|
+
const serviceSpy = vi
|
|
158
|
+
.spyOn(aiModelService, 'clearRemoteModels')
|
|
159
|
+
.mockResolvedValue(undefined as any);
|
|
158
160
|
|
|
159
161
|
await act(async () => {
|
|
160
162
|
await result.current.clearRemoteModels('test-provider');
|
|
@@ -178,7 +180,9 @@ describe('AiModelAction', () => {
|
|
|
178
180
|
const refreshSpy = vi
|
|
179
181
|
.spyOn(result.current, 'refreshAiModelList')
|
|
180
182
|
.mockResolvedValue(undefined);
|
|
181
|
-
const serviceSpy = vi
|
|
183
|
+
const serviceSpy = vi
|
|
184
|
+
.spyOn(aiModelService, 'createAiModel')
|
|
185
|
+
.mockResolvedValue(undefined as any);
|
|
182
186
|
|
|
183
187
|
await act(async () => {
|
|
184
188
|
await result.current.createNewAiModel(params);
|
|
@@ -349,7 +353,9 @@ describe('AiModelAction', () => {
|
|
|
349
353
|
const refreshSpy = vi
|
|
350
354
|
.spyOn(result.current, 'refreshAiModelList')
|
|
351
355
|
.mockResolvedValue(undefined);
|
|
352
|
-
const serviceSpy = vi
|
|
356
|
+
const serviceSpy = vi
|
|
357
|
+
.spyOn(aiModelService, 'deleteAiModel')
|
|
358
|
+
.mockResolvedValue(undefined as any);
|
|
353
359
|
|
|
354
360
|
await act(async () => {
|
|
355
361
|
await result.current.removeAiModel('model-1', 'test-provider');
|
|
@@ -371,7 +377,7 @@ describe('AiModelAction', () => {
|
|
|
371
377
|
.mockResolvedValue(undefined);
|
|
372
378
|
const serviceSpy = vi
|
|
373
379
|
.spyOn(aiModelService, 'toggleModelEnabled')
|
|
374
|
-
.mockResolvedValue(undefined);
|
|
380
|
+
.mockResolvedValue(undefined as any);
|
|
375
381
|
|
|
376
382
|
await act(async () => {
|
|
377
383
|
await result.current.toggleModelEnabled({ enabled: true, id: 'model-1' });
|
|
@@ -395,7 +401,7 @@ describe('AiModelAction', () => {
|
|
|
395
401
|
const { result } = renderHook(() => useStore());
|
|
396
402
|
const serviceSpy = vi
|
|
397
403
|
.spyOn(aiModelService, 'toggleModelEnabled')
|
|
398
|
-
.mockResolvedValue(undefined);
|
|
404
|
+
.mockResolvedValue(undefined as any);
|
|
399
405
|
|
|
400
406
|
await act(async () => {
|
|
401
407
|
await result.current.toggleModelEnabled({ enabled: true, id: 'model-1' });
|
|
@@ -435,7 +441,9 @@ describe('AiModelAction', () => {
|
|
|
435
441
|
const refreshSpy = vi
|
|
436
442
|
.spyOn(result.current, 'refreshAiModelList')
|
|
437
443
|
.mockResolvedValue(undefined);
|
|
438
|
-
const serviceSpy = vi
|
|
444
|
+
const serviceSpy = vi
|
|
445
|
+
.spyOn(aiModelService, 'updateAiModel')
|
|
446
|
+
.mockResolvedValue(undefined as any);
|
|
439
447
|
|
|
440
448
|
await act(async () => {
|
|
441
449
|
await result.current.updateAiModelsConfig('model-1', 'test-provider', updateData);
|
|
@@ -63,10 +63,12 @@ export const spyOnMessageService = () => {
|
|
|
63
63
|
const updateMessageSpy = vi
|
|
64
64
|
.spyOn(messageService, 'updateMessage')
|
|
65
65
|
.mockResolvedValue({ messages: [], success: true });
|
|
66
|
-
const removeMessageSpy = vi
|
|
66
|
+
const removeMessageSpy = vi
|
|
67
|
+
.spyOn(messageService, 'removeMessage')
|
|
68
|
+
.mockResolvedValue(undefined as any);
|
|
67
69
|
const updateMessageErrorSpy = vi
|
|
68
70
|
.spyOn(messageService, 'updateMessageError')
|
|
69
|
-
.mockResolvedValue(undefined);
|
|
71
|
+
.mockResolvedValue(undefined as any);
|
|
70
72
|
|
|
71
73
|
return {
|
|
72
74
|
createMessageSpy,
|
|
@@ -254,7 +254,7 @@ describe('topic action', () => {
|
|
|
254
254
|
|
|
255
255
|
const updateFavoriteSpy = vi
|
|
256
256
|
.spyOn(topicService, 'updateTopic')
|
|
257
|
-
.mockResolvedValue(
|
|
257
|
+
.mockResolvedValue(undefined as any);
|
|
258
258
|
|
|
259
259
|
const refreshTopicSpy = vi.spyOn(result.current, 'refreshTopic');
|
|
260
260
|
|
|
@@ -15,7 +15,6 @@ import { useClientDataSWR } from '@/libs/swr';
|
|
|
15
15
|
import { chatService } from '@/services/chat';
|
|
16
16
|
import { messageService } from '@/services/message';
|
|
17
17
|
import { topicService } from '@/services/topic';
|
|
18
|
-
import { CreateTopicParams } from '@/services/topic/type';
|
|
19
18
|
import type { ChatStore } from '@/store/chat';
|
|
20
19
|
import type { ChatStoreState } from '@/store/chat/initialState';
|
|
21
20
|
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
|
|
@@ -24,7 +23,7 @@ import { useSessionStore } from '@/store/session';
|
|
|
24
23
|
import { sessionSelectors } from '@/store/session/selectors';
|
|
25
24
|
import { useUserStore } from '@/store/user';
|
|
26
25
|
import { systemAgentSelectors } from '@/store/user/selectors';
|
|
27
|
-
import { ChatTopic } from '@/types/topic';
|
|
26
|
+
import { ChatTopic, CreateTopicParams } from '@/types/topic';
|
|
28
27
|
import { merge } from '@/utils/merge';
|
|
29
28
|
import { setNamespace } from '@/utils/storeDebug';
|
|
30
29
|
|
|
@@ -4,7 +4,6 @@ import { StateCreator } from 'zustand/vanilla';
|
|
|
4
4
|
import { notification } from '@/components/AntdStaticMethods';
|
|
5
5
|
import { FILE_UPLOAD_BLACKLIST } from '@/const/file';
|
|
6
6
|
import { fileService } from '@/services/file';
|
|
7
|
-
import { ServerService } from '@/services/file/server';
|
|
8
7
|
import { ragService } from '@/services/rag';
|
|
9
8
|
import { UPLOAD_NETWORK_ERROR } from '@/services/upload';
|
|
10
9
|
import {
|
|
@@ -21,8 +20,6 @@ import { FileStore } from '../../store';
|
|
|
21
20
|
|
|
22
21
|
const n = setNamespace('chat');
|
|
23
22
|
|
|
24
|
-
const serverFileService = new ServerService();
|
|
25
|
-
|
|
26
23
|
export interface FileAction {
|
|
27
24
|
clearChatUploadFileList: () => void;
|
|
28
25
|
dispatchChatUploadFileList: (payload: UploadFileListDispatch) => void;
|
|
@@ -71,7 +68,7 @@ export const createFileSlice: StateCreator<
|
|
|
71
68
|
let fileItem: FileListItem | undefined = undefined;
|
|
72
69
|
|
|
73
70
|
try {
|
|
74
|
-
fileItem = await
|
|
71
|
+
fileItem = await fileService.getFileItem(id);
|
|
75
72
|
} catch (e) {
|
|
76
73
|
console.error('getFileItem Error:', e);
|
|
77
74
|
continue;
|
|
@@ -4,8 +4,7 @@ import { StateCreator } from 'zustand/vanilla';
|
|
|
4
4
|
|
|
5
5
|
import { FILE_UPLOAD_BLACKLIST, MAX_UPLOAD_FILE_COUNT } from '@/const/file';
|
|
6
6
|
import { useClientDataSWR } from '@/libs/swr';
|
|
7
|
-
import { fileService } from '@/services/file';
|
|
8
|
-
import { ServerService } from '@/services/file/server';
|
|
7
|
+
import { fileService , FileService } from '@/services/file';
|
|
9
8
|
import { ragService } from '@/services/rag';
|
|
10
9
|
import {
|
|
11
10
|
UploadFileListDispatch,
|
|
@@ -18,7 +17,7 @@ import { unzipFile } from '@/utils/unzipFile';
|
|
|
18
17
|
import { FileStore } from '../../store';
|
|
19
18
|
import { fileManagerSelectors } from './selectors';
|
|
20
19
|
|
|
21
|
-
const serverFileService = new
|
|
20
|
+
const serverFileService = new FileService();
|
|
22
21
|
|
|
23
22
|
export interface FileManageAction {
|
|
24
23
|
dispatchDockFileList: (payload: UploadFileListDispatch) => void;
|