@lobehub/chat 1.39.3 → 1.40.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/.env.example +19 -8
- package/.eslintignore +1 -1
- package/CHANGELOG.md +33 -0
- package/changelog/v1.json +12 -0
- package/docs/.cdn.cache.json +25 -0
- package/docs/changelog/2023-09-09-plugin-system.mdx +1 -1
- package/docs/changelog/2023-09-09-plugin-system.zh-CN.mdx +1 -1
- package/docs/changelog/2024-09-20-artifacts.mdx +1 -1
- package/docs/changelog/2024-09-20-artifacts.zh-CN.mdx +1 -1
- package/docs/changelog/2024-10-27-pin-assistant.mdx +2 -2
- package/docs/changelog/2024-10-27-pin-assistant.zh-CN.mdx +2 -2
- package/docs/changelog/2024-11-06-share-text-json.mdx +2 -2
- package/docs/changelog/2024-11-06-share-text-json.zh-CN.mdx +2 -2
- package/docs/changelog/index.json +16 -16
- package/locales/ar/changelog.json +18 -0
- package/locales/ar/common.json +1 -0
- package/locales/ar/metadata.json +4 -0
- package/locales/bg-BG/changelog.json +18 -0
- package/locales/bg-BG/common.json +1 -0
- package/locales/bg-BG/metadata.json +4 -0
- package/locales/de-DE/changelog.json +18 -0
- package/locales/de-DE/common.json +1 -0
- package/locales/de-DE/metadata.json +4 -0
- package/locales/en-US/changelog.json +18 -0
- package/locales/en-US/common.json +1 -0
- package/locales/en-US/metadata.json +4 -0
- package/locales/es-ES/changelog.json +18 -0
- package/locales/es-ES/common.json +1 -0
- package/locales/es-ES/metadata.json +4 -0
- package/locales/fa-IR/changelog.json +18 -0
- package/locales/fa-IR/common.json +1 -0
- package/locales/fa-IR/metadata.json +4 -0
- package/locales/fr-FR/changelog.json +18 -0
- package/locales/fr-FR/common.json +1 -0
- package/locales/fr-FR/metadata.json +4 -0
- package/locales/it-IT/changelog.json +18 -0
- package/locales/it-IT/common.json +1 -0
- package/locales/it-IT/metadata.json +4 -0
- package/locales/ja-JP/changelog.json +18 -0
- package/locales/ja-JP/common.json +1 -0
- package/locales/ja-JP/metadata.json +4 -0
- package/locales/ko-KR/changelog.json +18 -0
- package/locales/ko-KR/common.json +1 -0
- package/locales/ko-KR/metadata.json +4 -0
- package/locales/nl-NL/changelog.json +18 -0
- package/locales/nl-NL/common.json +1 -0
- package/locales/nl-NL/metadata.json +4 -0
- package/locales/pl-PL/changelog.json +18 -0
- package/locales/pl-PL/common.json +1 -0
- package/locales/pl-PL/metadata.json +4 -0
- package/locales/pt-BR/changelog.json +18 -0
- package/locales/pt-BR/common.json +1 -0
- package/locales/pt-BR/metadata.json +4 -0
- package/locales/ru-RU/changelog.json +18 -0
- package/locales/ru-RU/common.json +1 -0
- package/locales/ru-RU/metadata.json +4 -0
- package/locales/tr-TR/changelog.json +18 -0
- package/locales/tr-TR/common.json +1 -0
- package/locales/tr-TR/metadata.json +4 -0
- package/locales/vi-VN/changelog.json +18 -0
- package/locales/vi-VN/common.json +1 -0
- package/locales/vi-VN/metadata.json +4 -0
- package/locales/zh-CN/changelog.json +18 -0
- package/locales/zh-CN/common.json +1 -0
- package/locales/zh-CN/metadata.json +4 -0
- package/locales/zh-TW/changelog.json +18 -0
- package/locales/zh-TW/common.json +1 -0
- package/locales/zh-TW/metadata.json +4 -0
- package/package.json +6 -1
- package/scripts/cdnWorkflow/index.ts +217 -0
- package/scripts/cdnWorkflow/optimized.ts +21 -0
- package/scripts/cdnWorkflow/s3/index.ts +120 -0
- package/scripts/cdnWorkflow/s3/types.ts +25 -0
- package/scripts/cdnWorkflow/s3/utils.ts +106 -0
- package/scripts/cdnWorkflow/uploader.ts +73 -0
- package/scripts/cdnWorkflow/utils.ts +93 -0
- package/src/app/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +25 -12
- package/src/app/(main)/(mobile)/me/(home)/features/useCategory.tsx +19 -9
- package/src/app/(main)/_layout/Desktop.tsx +4 -1
- package/src/app/(main)/_layout/Mobile.tsx +2 -1
- package/src/app/(main)/changelog/_layout/Desktop.tsx +25 -0
- package/src/app/(main)/changelog/_layout/Mobile/Header.tsx +33 -0
- package/src/app/(main)/changelog/_layout/Mobile/index.tsx +21 -0
- package/src/app/(main)/changelog/error.tsx +5 -0
- package/src/app/(main)/changelog/features/GridLayout.tsx +22 -0
- package/src/app/(main)/changelog/features/Hero.tsx +40 -0
- package/src/app/(main)/changelog/features/Post.tsx +56 -0
- package/src/app/(main)/changelog/features/PublishedTime.tsx +50 -0
- package/src/app/(main)/changelog/features/VersionTag.tsx +27 -0
- package/src/app/(main)/changelog/layout.tsx +10 -0
- package/src/app/(main)/changelog/loading.tsx +3 -0
- package/src/app/(main)/changelog/modal/page.tsx +23 -0
- package/src/app/(main)/changelog/not-found.tsx +3 -0
- package/src/app/(main)/changelog/page.tsx +73 -0
- package/src/app/(main)/chat/(workspace)/page.tsx +9 -2
- package/src/app/(main)/settings/about/features/Version.tsx +2 -2
- package/src/app/@modal/(.)changelog/modal/features/Cover.tsx +48 -0
- package/src/app/@modal/(.)changelog/modal/features/Hero.tsx +29 -0
- package/src/app/@modal/(.)changelog/modal/features/Pagination.tsx +54 -0
- package/src/app/@modal/(.)changelog/modal/features/Post.tsx +57 -0
- package/src/app/@modal/(.)changelog/modal/features/PublishedTime.tsx +50 -0
- package/src/app/@modal/(.)changelog/modal/features/ReadDetail.tsx +94 -0
- package/src/app/@modal/(.)changelog/modal/features/UpdateChangelogStatus.tsx +21 -0
- package/src/app/@modal/(.)changelog/modal/features/VersionTag.tsx +27 -0
- package/src/app/@modal/(.)changelog/modal/layout.tsx +39 -0
- package/src/app/@modal/(.)changelog/modal/loading.tsx +10 -0
- package/src/app/@modal/(.)changelog/modal/page.tsx +37 -0
- package/src/app/@modal/(.)settings/modal/layout.tsx +19 -16
- package/src/app/@modal/_layout/ModalLayout.tsx +63 -0
- package/src/app/@modal/chat/(.)settings/modal/layout.tsx +20 -17
- package/src/app/@modal/layout.tsx +5 -69
- package/src/components/mdx/Image.tsx +50 -0
- package/src/components/mdx/index.tsx +2 -0
- package/src/const/url.ts +1 -0
- package/src/features/ChangelogModal/index.tsx +22 -0
- package/src/features/User/UserPanel/useMenu.tsx +50 -46
- package/src/features/User/__tests__/useMenu.test.tsx +7 -6
- package/src/hooks/useInterceptingRoutes.ts +1 -6
- package/src/hooks/useShare.tsx +1 -0
- package/src/locales/default/changelog.ts +18 -0
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/index.ts +2 -0
- package/src/locales/default/metadata.ts +4 -0
- package/src/server/metadata.ts +5 -3
- package/src/server/routers/edge/appStatus.ts +3 -0
- package/src/server/routers/edge/index.ts +2 -0
- package/src/server/routers/lambda/agent.ts +1 -1
- package/src/server/services/changelog/index.test.ts +310 -0
- package/src/server/services/changelog/index.ts +196 -0
- package/src/server/services/discover/index.test.ts +0 -1
- package/src/server/sitemap.ts +4 -1
- package/src/services/__tests__/chat.test.ts +1 -1
- package/src/services/__tests__/global.test.ts +5 -2
- package/src/services/_auth.ts +1 -1
- package/src/services/agent.ts +25 -21
- package/src/services/chat.ts +2 -2
- package/src/services/file/ClientS3/index.ts +6 -6
- package/src/services/file/client.ts +14 -15
- package/src/services/file/server.ts +20 -25
- package/src/services/global.ts +2 -2
- package/src/services/import/client.ts +6 -5
- package/src/services/import/server.ts +6 -5
- package/src/services/import/type.ts +7 -0
- package/src/services/knowledgeBase.ts +19 -19
- package/src/services/message/_deprecated.ts +5 -0
- package/src/services/message/client.ts +52 -48
- package/src/services/message/server.ts +50 -53
- package/src/services/message/type.ts +2 -2
- package/src/services/plugin/client.ts +16 -22
- package/src/services/plugin/server.ts +15 -19
- package/src/services/rag.ts +18 -18
- package/src/services/ragEval.ts +29 -26
- package/src/services/session/_deprecated.ts +2 -2
- package/src/services/session/client.ts +55 -81
- package/src/services/session/server.ts +50 -74
- package/src/services/session/type.ts +4 -6
- package/src/services/share.ts +4 -4
- package/src/services/textToImage.ts +5 -2
- package/src/services/thread/client.ts +9 -15
- package/src/services/thread/server.ts +10 -15
- package/src/services/topic/client.ts +25 -25
- package/src/services/topic/server.ts +25 -42
- package/src/services/trace.ts +4 -4
- package/src/services/user/client.ts +13 -17
- package/src/services/user/server.ts +9 -13
- package/src/services/user/type.ts +1 -1
- package/src/store/chat/slices/message/reducer.ts +3 -2
- package/src/store/global/action.ts +27 -22
- package/src/store/global/initialState.ts +1 -0
- package/src/types/changelog.ts +6 -0
- package/src/types/message/index.ts +10 -8
- package/src/app/@modal/features/InterceptingContext.tsx +0 -9
@@ -1,30 +1,23 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
2
|
import { INBOX_SESSION_ID } from '@/const/session';
|
3
|
-
import { MessageItem } from '@/database/schemas';
|
4
3
|
import { lambdaClient } from '@/libs/trpc/client';
|
5
|
-
import {
|
6
|
-
ChatMessage,
|
7
|
-
ChatMessageError,
|
8
|
-
ChatTTS,
|
9
|
-
ChatTranslate,
|
10
|
-
CreateMessageParams,
|
11
|
-
} from '@/types/message';
|
4
|
+
import { ChatMessage, ChatMessageError, ChatTranslate } from '@/types/message';
|
12
5
|
|
13
6
|
import { IMessageService } from './type';
|
14
7
|
|
15
8
|
export class ServerService implements IMessageService {
|
16
|
-
createMessage({ sessionId, ...params }
|
9
|
+
createMessage: IMessageService['createMessage'] = async ({ sessionId, ...params }) => {
|
17
10
|
return lambdaClient.message.createMessage.mutate({
|
18
11
|
...params,
|
19
12
|
sessionId: this.toDbSessionId(sessionId),
|
20
13
|
});
|
21
|
-
}
|
14
|
+
};
|
22
15
|
|
23
|
-
batchCreateMessages
|
16
|
+
batchCreateMessages: IMessageService['batchCreateMessages'] = async (messages) => {
|
24
17
|
return lambdaClient.message.batchCreateMessages.mutate(messages);
|
25
|
-
}
|
18
|
+
};
|
26
19
|
|
27
|
-
getMessages = async (sessionId
|
20
|
+
getMessages: IMessageService['getMessages'] = async (sessionId, topicId) => {
|
28
21
|
const data = await lambdaClient.message.getMessages.query({
|
29
22
|
sessionId: this.toDbSessionId(sessionId),
|
30
23
|
topicId,
|
@@ -33,85 +26,89 @@ export class ServerService implements IMessageService {
|
|
33
26
|
return data as unknown as ChatMessage[];
|
34
27
|
};
|
35
28
|
|
36
|
-
getAllMessages
|
29
|
+
getAllMessages: IMessageService['getAllMessages'] = async () => {
|
37
30
|
return lambdaClient.message.getAllMessages.query();
|
38
|
-
}
|
31
|
+
};
|
39
32
|
|
40
|
-
getAllMessagesInSession
|
33
|
+
getAllMessagesInSession: IMessageService['getAllMessagesInSession'] = async (sessionId) => {
|
41
34
|
return lambdaClient.message.getAllMessagesInSession.query({
|
42
35
|
sessionId: this.toDbSessionId(sessionId),
|
43
36
|
});
|
44
|
-
}
|
37
|
+
};
|
45
38
|
|
46
|
-
countMessages()
|
39
|
+
countMessages: IMessageService['countMessages'] = async () => {
|
47
40
|
return lambdaClient.message.count.query();
|
48
|
-
}
|
49
|
-
|
41
|
+
};
|
42
|
+
|
43
|
+
countTodayMessages: IMessageService['countTodayMessages'] = async () => {
|
50
44
|
return lambdaClient.message.countToday.query();
|
51
|
-
}
|
45
|
+
};
|
52
46
|
|
53
|
-
updateMessageError(id
|
47
|
+
updateMessageError: IMessageService['updateMessageError'] = async (id, error) => {
|
54
48
|
return lambdaClient.message.update.mutate({ id, value: { error } });
|
55
|
-
}
|
49
|
+
};
|
56
50
|
|
57
|
-
async
|
51
|
+
updateMessagePluginError = async (id: string, error: ChatMessageError): Promise<any> => {
|
58
52
|
return lambdaClient.message.update.mutate({ id, value: { pluginError: error } });
|
59
|
-
}
|
53
|
+
};
|
60
54
|
|
61
|
-
async
|
62
|
-
id
|
63
|
-
value
|
64
|
-
)
|
55
|
+
updateMessagePluginArguments: IMessageService['updateMessagePluginArguments'] = async (
|
56
|
+
id,
|
57
|
+
value,
|
58
|
+
) => {
|
65
59
|
const args = typeof value === 'string' ? value : JSON.stringify(value);
|
66
|
-
|
67
60
|
return lambdaClient.message.updateMessagePlugin.mutate({ id, value: { arguments: args } });
|
68
|
-
}
|
61
|
+
};
|
69
62
|
|
70
|
-
updateMessage(id
|
63
|
+
updateMessage: IMessageService['updateMessage'] = async (id, message) => {
|
71
64
|
return lambdaClient.message.update.mutate({ id, value: message });
|
72
|
-
}
|
65
|
+
};
|
73
66
|
|
74
|
-
updateMessageTranslate
|
67
|
+
updateMessageTranslate: IMessageService['updateMessageTranslate'] = async (id, translate) => {
|
75
68
|
return lambdaClient.message.updateTranslate.mutate({ id, value: translate as ChatTranslate });
|
76
|
-
}
|
69
|
+
};
|
77
70
|
|
78
|
-
updateMessageTTS
|
71
|
+
updateMessageTTS: IMessageService['updateMessageTTS'] = async (id, tts) => {
|
79
72
|
return lambdaClient.message.updateTTS.mutate({ id, value: tts });
|
80
|
-
}
|
73
|
+
};
|
81
74
|
|
82
|
-
updateMessagePluginState(id
|
75
|
+
updateMessagePluginState: IMessageService['updateMessagePluginState'] = async (id, value) => {
|
83
76
|
return lambdaClient.message.updatePluginState.mutate({ id, value });
|
84
|
-
}
|
77
|
+
};
|
85
78
|
|
86
|
-
removeMessage(id
|
79
|
+
removeMessage: IMessageService['removeMessage'] = async (id) => {
|
87
80
|
return lambdaClient.message.removeMessage.mutate({ id });
|
88
|
-
}
|
81
|
+
};
|
89
82
|
|
90
|
-
removeMessages
|
83
|
+
removeMessages: IMessageService['removeMessages'] = async (ids) => {
|
91
84
|
return lambdaClient.message.removeMessages.mutate({ ids });
|
92
|
-
}
|
85
|
+
};
|
93
86
|
|
94
|
-
removeMessagesByAssistant
|
87
|
+
removeMessagesByAssistant: IMessageService['removeMessagesByAssistant'] = async (
|
88
|
+
sessionId,
|
89
|
+
topicId,
|
90
|
+
) => {
|
95
91
|
return lambdaClient.message.removeMessagesByAssistant.mutate({
|
96
92
|
sessionId: this.toDbSessionId(sessionId),
|
97
93
|
topicId,
|
98
94
|
});
|
99
|
-
}
|
100
|
-
|
95
|
+
};
|
96
|
+
|
97
|
+
removeAllMessages: IMessageService['removeAllMessages'] = async () => {
|
101
98
|
return lambdaClient.message.removeAllMessages.mutate();
|
102
|
-
}
|
99
|
+
};
|
103
100
|
|
104
|
-
private toDbSessionId(sessionId: string | undefined) {
|
101
|
+
private toDbSessionId = (sessionId: string | undefined) => {
|
105
102
|
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
106
|
-
}
|
103
|
+
};
|
107
104
|
|
108
|
-
async
|
105
|
+
hasMessages: IMessageService['hasMessages'] = async () => {
|
109
106
|
const number = await this.countMessages();
|
110
107
|
return number > 0;
|
111
|
-
}
|
108
|
+
};
|
112
109
|
|
113
|
-
async
|
110
|
+
messageCountToCheckTrace: IMessageService['messageCountToCheckTrace'] = async () => {
|
114
111
|
const number = await this.countMessages();
|
115
112
|
return number >= 4;
|
116
|
-
}
|
113
|
+
};
|
117
114
|
}
|
@@ -24,11 +24,11 @@ export interface IMessageService {
|
|
24
24
|
updateMessageTTS(id: string, tts: Partial<ChatTTS> | false): Promise<any>;
|
25
25
|
updateMessageTranslate(id: string, translate: Partial<ChatTranslate> | false): Promise<any>;
|
26
26
|
updateMessagePluginState(id: string, value: Record<string, any>): Promise<any>;
|
27
|
-
|
27
|
+
updateMessagePluginArguments(id: string, value: string | Record<string, any>): Promise<any>;
|
28
28
|
removeMessage(id: string): Promise<any>;
|
29
29
|
removeMessages(ids: string[]): Promise<any>;
|
30
30
|
removeMessagesByAssistant(assistantId: string, topicId?: string): Promise<any>;
|
31
31
|
removeAllMessages(): Promise<any>;
|
32
|
-
|
32
|
+
messageCountToCheckTrace(): Promise<boolean>;
|
33
33
|
hasMessages(): Promise<boolean>;
|
34
34
|
}
|
@@ -1,51 +1,45 @@
|
|
1
|
-
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
2
|
-
|
3
1
|
import { clientDB } from '@/database/client/db';
|
4
2
|
import { PluginModel } from '@/database/server/models/plugin';
|
5
3
|
import { BaseClientService } from '@/services/baseClientService';
|
6
4
|
import { LobeTool } from '@/types/tool';
|
7
|
-
import { LobeToolCustomPlugin } from '@/types/tool/plugin';
|
8
5
|
|
9
|
-
import { IPluginService
|
6
|
+
import { IPluginService } from './type';
|
10
7
|
|
11
8
|
export class ClientService extends BaseClientService implements IPluginService {
|
12
9
|
private get pluginModel(): PluginModel {
|
13
10
|
return new PluginModel(clientDB as any, this.userId);
|
14
11
|
}
|
15
12
|
|
16
|
-
installPlugin = async (plugin
|
13
|
+
installPlugin: IPluginService['installPlugin'] = async (plugin) => {
|
17
14
|
await this.pluginModel.create(plugin);
|
18
|
-
return;
|
19
15
|
};
|
20
16
|
|
21
|
-
getInstalledPlugins = () => {
|
17
|
+
getInstalledPlugins: IPluginService['getInstalledPlugins'] = () => {
|
22
18
|
return this.pluginModel.query() as Promise<LobeTool[]>;
|
23
19
|
};
|
24
20
|
|
25
|
-
async
|
21
|
+
uninstallPlugin: IPluginService['uninstallPlugin'] = async (identifier) => {
|
26
22
|
await this.pluginModel.delete(identifier);
|
27
|
-
|
28
|
-
}
|
23
|
+
};
|
29
24
|
|
30
|
-
async
|
25
|
+
createCustomPlugin: IPluginService['createCustomPlugin'] = async (customPlugin) => {
|
31
26
|
await this.pluginModel.create({ ...customPlugin, type: 'customPlugin' });
|
32
|
-
|
33
|
-
}
|
27
|
+
};
|
34
28
|
|
35
|
-
async
|
29
|
+
updatePlugin: IPluginService['updatePlugin'] = async (id, value) => {
|
36
30
|
await this.pluginModel.update(id, value);
|
37
|
-
|
38
|
-
|
39
|
-
async
|
31
|
+
};
|
32
|
+
|
33
|
+
updatePluginManifest: IPluginService['updatePluginManifest'] = async (id, manifest) => {
|
40
34
|
await this.pluginModel.update(id, { manifest });
|
41
|
-
}
|
35
|
+
};
|
42
36
|
|
43
|
-
async
|
37
|
+
removeAllPlugins: IPluginService['removeAllPlugins'] = async () => {
|
44
38
|
await this.pluginModel.deleteAll();
|
45
|
-
}
|
39
|
+
};
|
46
40
|
|
47
41
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
48
|
-
async
|
42
|
+
updatePluginSettings: IPluginService['updatePluginSettings'] = async (id, settings, _?) => {
|
49
43
|
await this.pluginModel.update(id, { settings });
|
50
|
-
}
|
44
|
+
};
|
51
45
|
}
|
@@ -1,46 +1,42 @@
|
|
1
|
-
import { LobeChatPluginManifest } from '@lobehub/chat-plugin-sdk';
|
2
|
-
|
3
1
|
import { lambdaClient } from '@/libs/trpc/client';
|
4
|
-
import { LobeTool } from '@/types/tool';
|
5
|
-
import { LobeToolCustomPlugin } from '@/types/tool/plugin';
|
6
2
|
|
7
|
-
import { IPluginService
|
3
|
+
import { IPluginService } from './type';
|
8
4
|
|
9
5
|
export class ServerService implements IPluginService {
|
10
|
-
installPlugin = async (plugin
|
6
|
+
installPlugin: IPluginService['installPlugin'] = async (plugin) => {
|
11
7
|
await lambdaClient.plugin.createOrInstallPlugin.mutate(plugin);
|
12
8
|
};
|
13
9
|
|
14
|
-
getInstalledPlugins = ()
|
10
|
+
getInstalledPlugins: IPluginService['getInstalledPlugins'] = () => {
|
15
11
|
return lambdaClient.plugin.getPlugins.query();
|
16
12
|
};
|
17
13
|
|
18
|
-
async
|
14
|
+
uninstallPlugin: IPluginService['uninstallPlugin'] = async (identifier) => {
|
19
15
|
await lambdaClient.plugin.removePlugin.mutate({ id: identifier });
|
20
|
-
}
|
16
|
+
};
|
21
17
|
|
22
|
-
async
|
18
|
+
createCustomPlugin: IPluginService['createCustomPlugin'] = async (customPlugin) => {
|
23
19
|
await lambdaClient.plugin.createPlugin.mutate({ ...customPlugin, type: 'customPlugin' });
|
24
|
-
}
|
20
|
+
};
|
25
21
|
|
26
|
-
async
|
22
|
+
updatePlugin: IPluginService['updatePlugin'] = async (id, value) => {
|
27
23
|
await lambdaClient.plugin.updatePlugin.mutate({
|
28
24
|
customParams: value.customParams,
|
29
25
|
id,
|
30
26
|
manifest: value.manifest,
|
31
27
|
settings: value.settings,
|
32
28
|
});
|
33
|
-
}
|
29
|
+
};
|
34
30
|
|
35
|
-
async
|
31
|
+
updatePluginManifest: IPluginService['updatePluginManifest'] = async (id, manifest) => {
|
36
32
|
await lambdaClient.plugin.updatePlugin.mutate({ id, manifest });
|
37
|
-
}
|
33
|
+
};
|
38
34
|
|
39
|
-
async
|
35
|
+
removeAllPlugins: IPluginService['removeAllPlugins'] = async () => {
|
40
36
|
await lambdaClient.plugin.removeAllPlugins.mutate();
|
41
|
-
}
|
37
|
+
};
|
42
38
|
|
43
|
-
async
|
39
|
+
updatePluginSettings: IPluginService['updatePluginSettings'] = async (id, settings, signal) => {
|
44
40
|
await lambdaClient.plugin.updatePlugin.mutate({ id, settings }, { signal });
|
45
|
-
}
|
41
|
+
};
|
46
42
|
}
|
package/src/services/rag.ts
CHANGED
@@ -2,29 +2,29 @@ import { lambdaClient } from '@/libs/trpc/client';
|
|
2
2
|
import { SemanticSearchSchemaType } from '@/types/rag';
|
3
3
|
|
4
4
|
class RAGService {
|
5
|
-
async
|
6
|
-
return
|
7
|
-
}
|
5
|
+
createParseFileTask = async (id: string, skipExist?: boolean) => {
|
6
|
+
return lambdaClient.chunk.createParseFileTask.mutate({ id, skipExist });
|
7
|
+
};
|
8
8
|
|
9
|
-
async
|
10
|
-
return
|
11
|
-
}
|
9
|
+
retryParseFile = async (id: string) => {
|
10
|
+
return lambdaClient.chunk.retryParseFileTask.mutate({ id });
|
11
|
+
};
|
12
12
|
|
13
|
-
async
|
14
|
-
return
|
15
|
-
}
|
13
|
+
createEmbeddingChunksTask = async (id: string) => {
|
14
|
+
return lambdaClient.chunk.createEmbeddingChunksTask.mutate({ id });
|
15
|
+
};
|
16
16
|
|
17
|
-
async
|
18
|
-
return
|
19
|
-
}
|
17
|
+
semanticSearch = async (query: string, fileIds?: string[]) => {
|
18
|
+
return lambdaClient.chunk.semanticSearch.mutate({ fileIds, query });
|
19
|
+
};
|
20
20
|
|
21
|
-
async
|
22
|
-
return
|
23
|
-
}
|
21
|
+
semanticSearchForChat = async (params: SemanticSearchSchemaType) => {
|
22
|
+
return lambdaClient.chunk.semanticSearchForChat.mutate(params);
|
23
|
+
};
|
24
24
|
|
25
|
-
async
|
26
|
-
return
|
27
|
-
}
|
25
|
+
deleteMessageRagQuery = async (id: string) => {
|
26
|
+
return lambdaClient.message.removeMessageQuery.mutate({ id });
|
27
|
+
};
|
28
28
|
}
|
29
29
|
|
30
30
|
export const ragService = new RAGService();
|
package/src/services/ragEval.ts
CHANGED
@@ -11,57 +11,60 @@ import {
|
|
11
11
|
|
12
12
|
class RAGEvalService {
|
13
13
|
// Dataset
|
14
|
-
async
|
15
|
-
return
|
16
|
-
}
|
14
|
+
createDataset = async (params: CreateNewEvalDatasets): Promise<number | undefined> => {
|
15
|
+
return lambdaClient.ragEval.createDataset.mutate(params);
|
16
|
+
};
|
17
17
|
|
18
|
-
async
|
18
|
+
getDatasets = async (knowledgeBaseId: string): Promise<RAGEvalDataSetItem[]> => {
|
19
19
|
return lambdaClient.ragEval.getDatasets.query({ knowledgeBaseId });
|
20
|
-
}
|
20
|
+
};
|
21
21
|
|
22
|
-
async
|
22
|
+
removeDataset = async (id: number): Promise<void> => {
|
23
23
|
await lambdaClient.ragEval.removeDataset.mutate({ id });
|
24
|
-
}
|
24
|
+
};
|
25
25
|
|
26
|
-
|
26
|
+
updateDataset = async (
|
27
|
+
id: number,
|
28
|
+
value: Partial<typeof insertEvalDatasetsSchema>,
|
29
|
+
): Promise<void> => {
|
27
30
|
await lambdaClient.ragEval.updateDataset.mutate({ id, value });
|
28
|
-
}
|
31
|
+
};
|
29
32
|
|
30
33
|
// Dataset Records
|
31
|
-
async
|
34
|
+
getDatasetRecords = async (datasetId: number): Promise<EvalDatasetRecord[]> => {
|
32
35
|
return lambdaClient.ragEval.getDatasetRecords.query({ datasetId });
|
33
|
-
}
|
36
|
+
};
|
34
37
|
|
35
|
-
async
|
38
|
+
removeDatasetRecord = async (id: number): Promise<void> => {
|
36
39
|
await lambdaClient.ragEval.removeDatasetRecords.mutate({ id });
|
37
|
-
}
|
40
|
+
};
|
38
41
|
|
39
|
-
async
|
42
|
+
importDatasetRecords = async (datasetId: number, file: File): Promise<void> => {
|
40
43
|
const { path } = await uploadService.uploadWithProgress(file, { directory: 'ragEval' });
|
41
44
|
|
42
45
|
await lambdaClient.ragEval.importDatasetRecords.mutate({ datasetId, pathname: path });
|
43
|
-
}
|
46
|
+
};
|
44
47
|
|
45
48
|
// Evaluation
|
46
|
-
async
|
47
|
-
return
|
48
|
-
}
|
49
|
+
createEvaluation = async (params: CreateNewEvalEvaluation): Promise<number | undefined> => {
|
50
|
+
return lambdaClient.ragEval.createEvaluation.mutate(params);
|
51
|
+
};
|
49
52
|
|
50
|
-
async
|
53
|
+
getEvaluationList = async (knowledgeBaseId: string): Promise<RAGEvalEvaluationItem[]> => {
|
51
54
|
return lambdaClient.ragEval.getEvaluationList.query({ knowledgeBaseId });
|
52
|
-
}
|
55
|
+
};
|
53
56
|
|
54
|
-
async
|
57
|
+
startEvaluationTask = async (id: number) => {
|
55
58
|
return lambdaClient.ragEval.startEvaluationTask.mutate({ id });
|
56
|
-
}
|
59
|
+
};
|
57
60
|
|
58
|
-
async
|
61
|
+
removeEvaluation = async (id: number): Promise<void> => {
|
59
62
|
await lambdaClient.ragEval.removeEvaluation.mutate({ id });
|
60
|
-
}
|
63
|
+
};
|
61
64
|
|
62
|
-
async
|
65
|
+
checkEvaluationStatus = async (id: number): Promise<{ success: boolean }> => {
|
63
66
|
return lambdaClient.ragEval.checkEvaluationStatus.query({ id });
|
64
|
-
}
|
67
|
+
};
|
65
68
|
}
|
66
69
|
|
67
70
|
export const ragEvalService = new RAGEvalService();
|
@@ -75,7 +75,7 @@ export class ClientService implements ISessionService {
|
|
75
75
|
|
76
76
|
async getAllAgents(): Promise<LobeSessions> {
|
77
77
|
// TODO: add a filter to get only agents
|
78
|
-
return
|
78
|
+
return SessionModel.query();
|
79
79
|
}
|
80
80
|
|
81
81
|
async countSessions() {
|
@@ -162,7 +162,7 @@ export class ClientService implements ISessionService {
|
|
162
162
|
}
|
163
163
|
|
164
164
|
async removeSessionGroup(id: string, removeChildren?: boolean) {
|
165
|
-
return
|
165
|
+
return SessionGroupModel.delete(id, removeChildren);
|
166
166
|
}
|
167
167
|
|
168
168
|
async updateSessionGroup(id: string, data: Partial<SessionGroupItem>) {
|