@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,22 +1,10 @@
|
|
1
|
-
import { DeepPartial } from 'utility-types';
|
2
|
-
|
3
1
|
import { INBOX_SESSION_ID } from '@/const/session';
|
4
2
|
import { clientDB } from '@/database/client/db';
|
5
3
|
import { AgentItem } from '@/database/schemas';
|
6
4
|
import { SessionModel } from '@/database/server/models/session';
|
7
5
|
import { SessionGroupModel } from '@/database/server/models/sessionGroup';
|
8
6
|
import { BaseClientService } from '@/services/baseClientService';
|
9
|
-
import {
|
10
|
-
import { MetaData } from '@/types/meta';
|
11
|
-
import {
|
12
|
-
ChatSessionList,
|
13
|
-
LobeAgentSession,
|
14
|
-
LobeSessionType,
|
15
|
-
LobeSessions,
|
16
|
-
SessionGroupItem,
|
17
|
-
SessionGroups,
|
18
|
-
UpdateSessionParams,
|
19
|
-
} from '@/types/session';
|
7
|
+
import { LobeAgentConfig } from '@/types/agent';
|
20
8
|
|
21
9
|
import { ISessionService } from './type';
|
22
10
|
|
@@ -29,7 +17,12 @@ export class ClientService extends BaseClientService implements ISessionService
|
|
29
17
|
return new SessionGroupModel(clientDB as any, this.userId);
|
30
18
|
}
|
31
19
|
|
32
|
-
|
20
|
+
hasSessions: ISessionService['hasSessions'] = async () => {
|
21
|
+
const result = await this.countSessions();
|
22
|
+
return result === 0;
|
23
|
+
};
|
24
|
+
|
25
|
+
createSession: ISessionService['createSession'] = async (type, data) => {
|
33
26
|
const { config, group, meta, ...session } = data;
|
34
27
|
|
35
28
|
const item = await this.sessionModel.create({
|
@@ -41,144 +34,125 @@ export class ClientService extends BaseClientService implements ISessionService
|
|
41
34
|
throw new Error('session create Error');
|
42
35
|
}
|
43
36
|
return item.id;
|
44
|
-
}
|
37
|
+
};
|
45
38
|
|
46
|
-
async
|
39
|
+
batchCreateSessions: ISessionService['batchCreateSessions'] = async (importSessions) => {
|
47
40
|
// @ts-ignore
|
48
41
|
return this.sessionModel.batchCreate(importSessions);
|
49
|
-
}
|
42
|
+
};
|
50
43
|
|
51
|
-
async
|
44
|
+
cloneSession: ISessionService['cloneSession'] = async (id, newTitle) => {
|
52
45
|
const res = await this.sessionModel.duplicate(id, newTitle);
|
53
46
|
|
54
47
|
if (res) return res?.id;
|
55
|
-
}
|
48
|
+
};
|
56
49
|
|
57
|
-
async
|
50
|
+
getGroupedSessions: ISessionService['getGroupedSessions'] = async () => {
|
58
51
|
return this.sessionModel.queryWithGroups();
|
59
|
-
}
|
52
|
+
};
|
60
53
|
|
61
|
-
async
|
54
|
+
getSessionConfig: ISessionService['getSessionConfig'] = async (id) => {
|
62
55
|
const res = await this.sessionModel.findByIdOrSlug(id);
|
63
56
|
|
64
57
|
if (!res) throw new Error('Session not found');
|
65
58
|
|
66
59
|
return res.agent as LobeAgentConfig;
|
67
|
-
}
|
60
|
+
};
|
68
61
|
|
69
62
|
/**
|
70
63
|
* 这个方法要对应移除的
|
71
64
|
*/
|
72
|
-
|
65
|
+
// @ts-ignore
|
66
|
+
getSessionsByType: ISessionService['getSessionsByType'] = async (type = 'all') => {
|
73
67
|
switch (type) {
|
74
68
|
// TODO: add a filter to get only agents or agents
|
75
|
-
case 'group':
|
76
|
-
|
77
|
-
return this.sessionModel.query();
|
78
|
-
}
|
79
|
-
case 'agent': {
|
80
|
-
// @ts-ignore
|
81
|
-
return this.sessionModel.query();
|
82
|
-
}
|
83
|
-
|
69
|
+
case 'group':
|
70
|
+
case 'agent':
|
84
71
|
case 'all': {
|
85
|
-
// @ts-ignore
|
86
72
|
return this.sessionModel.query();
|
87
73
|
}
|
88
74
|
}
|
89
|
-
}
|
75
|
+
};
|
90
76
|
|
91
|
-
async
|
77
|
+
countSessions: ISessionService['countSessions'] = async () => {
|
92
78
|
return this.sessionModel.count();
|
93
|
-
}
|
79
|
+
};
|
94
80
|
|
95
|
-
async
|
81
|
+
searchSessions: ISessionService['searchSessions'] = async (keyword) => {
|
96
82
|
return this.sessionModel.queryByKeyword(keyword);
|
97
|
-
}
|
83
|
+
};
|
98
84
|
|
99
|
-
async
|
85
|
+
updateSession: ISessionService['updateSession'] = async (id, value) => {
|
100
86
|
return this.sessionModel.update(id, {
|
101
87
|
...value,
|
102
88
|
groupId: value.group === 'default' ? null : value.group,
|
103
89
|
});
|
104
|
-
}
|
90
|
+
};
|
105
91
|
|
106
|
-
async
|
107
|
-
activeId: string,
|
108
|
-
config: DeepPartial<LobeAgentConfig>,
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
110
|
-
_?: AbortSignal,
|
111
|
-
) {
|
92
|
+
updateSessionConfig: ISessionService['updateSessionConfig'] = async (activeId, config) => {
|
112
93
|
const session = await this.sessionModel.findByIdOrSlug(activeId);
|
113
94
|
if (!session || !config) return;
|
114
95
|
|
115
96
|
return this.sessionModel.updateConfig(session.agent.id, config as AgentItem);
|
116
|
-
}
|
97
|
+
};
|
117
98
|
|
118
|
-
async
|
119
|
-
activeId: string,
|
120
|
-
meta: Partial<MetaData>,
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
122
|
-
_?: AbortSignal,
|
123
|
-
) {
|
99
|
+
updateSessionMeta: ISessionService['updateSessionMeta'] = async (activeId, meta) => {
|
124
100
|
// inbox 不允许修改 meta
|
125
101
|
if (activeId === INBOX_SESSION_ID) return;
|
126
102
|
|
127
103
|
return this.sessionModel.update(activeId, meta);
|
128
|
-
}
|
104
|
+
};
|
129
105
|
|
130
|
-
async
|
131
|
-
activeId
|
132
|
-
config
|
133
|
-
|
134
|
-
_?: AbortSignal,
|
135
|
-
) {
|
106
|
+
updateSessionChatConfig: ISessionService['updateSessionChatConfig'] = async (
|
107
|
+
activeId,
|
108
|
+
config,
|
109
|
+
) => {
|
136
110
|
return this.updateSessionConfig(activeId, { chatConfig: config });
|
137
|
-
}
|
111
|
+
};
|
138
112
|
|
139
|
-
async
|
113
|
+
removeSession: ISessionService['removeSession'] = async (id) => {
|
140
114
|
return this.sessionModel.delete(id);
|
141
|
-
}
|
115
|
+
};
|
142
116
|
|
143
|
-
async
|
117
|
+
removeAllSessions: ISessionService['removeAllSessions'] = async () => {
|
144
118
|
return this.sessionModel.deleteAll();
|
145
|
-
}
|
119
|
+
};
|
146
120
|
|
147
121
|
// ************************************** //
|
148
122
|
// *********** SessionGroup *********** //
|
149
123
|
// ************************************** //
|
150
124
|
|
151
|
-
async
|
125
|
+
createSessionGroup: ISessionService['createSessionGroup'] = async (name, sort) => {
|
152
126
|
const item = await this.sessionGroupModel.create({ name, sort });
|
153
127
|
if (!item) {
|
154
128
|
throw new Error('session group create Error');
|
155
129
|
}
|
156
130
|
|
157
131
|
return item.id;
|
158
|
-
}
|
132
|
+
};
|
159
133
|
|
160
134
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
161
|
-
async
|
135
|
+
batchCreateSessionGroups: ISessionService['batchCreateSessionGroups'] = async (_groups) => {
|
162
136
|
return { added: 0, ids: [], skips: [], success: true };
|
163
|
-
}
|
137
|
+
};
|
164
138
|
|
165
|
-
async
|
166
|
-
return
|
167
|
-
}
|
139
|
+
removeSessionGroup: ISessionService['removeSessionGroup'] = async (id) => {
|
140
|
+
return this.sessionGroupModel.delete(id);
|
141
|
+
};
|
168
142
|
|
169
|
-
async
|
143
|
+
updateSessionGroup: ISessionService['updateSessionGroup'] = async (id, data) => {
|
170
144
|
return this.sessionGroupModel.update(id, data);
|
171
|
-
}
|
145
|
+
};
|
172
146
|
|
173
|
-
|
147
|
+
updateSessionGroupOrder: ISessionService['updateSessionGroupOrder'] = async (sortMap) => {
|
174
148
|
return this.sessionGroupModel.updateOrder(sortMap);
|
175
|
-
}
|
149
|
+
};
|
176
150
|
|
177
|
-
|
151
|
+
getSessionGroups: ISessionService['getSessionGroups'] = async () => {
|
178
152
|
return this.sessionGroupModel.query();
|
179
|
-
}
|
153
|
+
};
|
180
154
|
|
181
|
-
async
|
155
|
+
removeSessionGroups: ISessionService['removeSessionGroups'] = async () => {
|
182
156
|
return this.sessionGroupModel.deleteAll();
|
183
|
-
}
|
157
|
+
};
|
184
158
|
}
|
@@ -1,145 +1,121 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
|
-
import { DeepPartial } from 'utility-types';
|
3
|
-
|
4
2
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
5
3
|
import { lambdaClient } from '@/libs/trpc/client';
|
6
4
|
import { useUserStore } from '@/store/user';
|
7
5
|
import { authSelectors } from '@/store/user/selectors';
|
8
|
-
import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
|
9
|
-
import { MetaData } from '@/types/meta';
|
10
|
-
import { BatchTaskResult } from '@/types/service';
|
11
|
-
import {
|
12
|
-
ChatSessionList,
|
13
|
-
LobeAgentSession,
|
14
|
-
LobeSessionType,
|
15
|
-
LobeSessions,
|
16
|
-
SessionGroupItem,
|
17
|
-
SessionGroups,
|
18
|
-
UpdateSessionParams,
|
19
|
-
} from '@/types/session';
|
20
6
|
|
21
7
|
import { ISessionService } from './type';
|
22
8
|
|
23
9
|
export class ServerService implements ISessionService {
|
24
|
-
async
|
25
|
-
|
26
|
-
|
10
|
+
hasSessions: ISessionService['hasSessions'] = async () => {
|
11
|
+
const result = await this.countSessions();
|
12
|
+
return result === 0;
|
13
|
+
};
|
27
14
|
|
28
|
-
createSession(type
|
15
|
+
createSession: ISessionService['createSession'] = async (type, data) => {
|
29
16
|
const { config, group, meta, ...session } = data;
|
30
|
-
|
31
17
|
return lambdaClient.session.createSession.mutate({
|
32
18
|
config: { ...config, ...meta } as any,
|
33
19
|
session: { ...session, groupId: group },
|
34
20
|
type,
|
35
21
|
});
|
36
|
-
}
|
22
|
+
};
|
37
23
|
|
38
|
-
async
|
24
|
+
batchCreateSessions: ISessionService['batchCreateSessions'] = async (importSessions) => {
|
39
25
|
// TODO: remove any
|
40
26
|
const data = await lambdaClient.session.batchCreateSessions.mutate(importSessions as any);
|
41
27
|
console.log(data);
|
42
28
|
return data;
|
43
|
-
}
|
29
|
+
};
|
44
30
|
|
45
|
-
cloneSession(id
|
31
|
+
cloneSession: ISessionService['cloneSession'] = (id, newTitle) => {
|
46
32
|
return lambdaClient.session.cloneSession.mutate({ id, newTitle });
|
47
|
-
}
|
33
|
+
};
|
48
34
|
|
49
|
-
getGroupedSessions()
|
35
|
+
getGroupedSessions: ISessionService['getGroupedSessions'] = () => {
|
50
36
|
return lambdaClient.session.getGroupedSessions.query();
|
51
|
-
}
|
37
|
+
};
|
52
38
|
|
53
|
-
countSessions()
|
39
|
+
countSessions: ISessionService['countSessions'] = () => {
|
54
40
|
return lambdaClient.session.countSessions.query();
|
55
|
-
}
|
41
|
+
};
|
56
42
|
|
57
|
-
updateSession(id
|
43
|
+
updateSession: ISessionService['updateSession'] = (id, data) => {
|
58
44
|
const { group, pinned, meta, updatedAt } = data;
|
59
45
|
return lambdaClient.session.updateSession.mutate({
|
60
46
|
id,
|
61
47
|
value: { groupId: group === 'default' ? null : group, pinned, ...meta, updatedAt },
|
62
48
|
});
|
63
|
-
}
|
49
|
+
};
|
64
50
|
|
65
|
-
|
51
|
+
// TODO: Need to be fixed
|
52
|
+
// @ts-ignore
|
53
|
+
getSessionConfig: ISessionService['getSessionConfig'] = async (id) => {
|
66
54
|
const isLogin = authSelectors.isLogin(useUserStore.getState());
|
67
55
|
if (!isLogin) return DEFAULT_AGENT_CONFIG;
|
68
56
|
|
69
|
-
// TODO: Need to be fixed
|
70
|
-
// @ts-ignore
|
71
57
|
return lambdaClient.agent.getAgentConfig.query({ sessionId: id });
|
72
|
-
}
|
58
|
+
};
|
73
59
|
|
74
|
-
updateSessionConfig(
|
75
|
-
id: string,
|
76
|
-
config: DeepPartial<LobeAgentConfig>,
|
77
|
-
signal?: AbortSignal,
|
78
|
-
): Promise<any> {
|
60
|
+
updateSessionConfig: ISessionService['updateSessionConfig'] = (id, config, signal) => {
|
79
61
|
return lambdaClient.session.updateSessionConfig.mutate({ id, value: config }, { signal });
|
80
|
-
}
|
62
|
+
};
|
81
63
|
|
82
|
-
updateSessionMeta(id
|
64
|
+
updateSessionMeta: ISessionService['updateSessionMeta'] = (id, meta, signal) => {
|
83
65
|
return lambdaClient.session.updateSessionConfig.mutate({ id, value: meta }, { signal });
|
84
|
-
}
|
66
|
+
};
|
85
67
|
|
86
|
-
updateSessionChatConfig(
|
87
|
-
id: string,
|
88
|
-
value: DeepPartial<LobeAgentChatConfig>,
|
89
|
-
signal?: AbortSignal,
|
90
|
-
): Promise<any> {
|
68
|
+
updateSessionChatConfig: ISessionService['updateSessionChatConfig'] = (id, value, signal) => {
|
91
69
|
return lambdaClient.session.updateSessionChatConfig.mutate({ id, value }, { signal });
|
92
|
-
}
|
70
|
+
};
|
93
71
|
|
94
|
-
|
95
|
-
|
96
|
-
|
72
|
+
// TODO: need be fixed
|
73
|
+
// @ts-ignore
|
74
|
+
getSessionsByType: ISessionService['getSessionsByType'] = (_type = 'all') => {
|
97
75
|
return lambdaClient.session.getSessions.query({});
|
98
|
-
}
|
76
|
+
};
|
99
77
|
|
100
|
-
searchSessions(keywords
|
78
|
+
searchSessions: ISessionService['searchSessions'] = (keywords) => {
|
101
79
|
return lambdaClient.session.searchSessions.query({ keywords });
|
102
|
-
}
|
80
|
+
};
|
103
81
|
|
104
|
-
removeSession(id
|
82
|
+
removeSession: ISessionService['removeSession'] = (id) => {
|
105
83
|
return lambdaClient.session.removeSession.mutate({ id });
|
106
|
-
}
|
84
|
+
};
|
107
85
|
|
108
|
-
removeAllSessions()
|
86
|
+
removeAllSessions: ISessionService['removeAllSessions'] = () => {
|
109
87
|
return lambdaClient.session.removeAllSessions.mutate();
|
110
|
-
}
|
88
|
+
};
|
111
89
|
|
112
90
|
// ************************************** //
|
113
91
|
// *********** SessionGroup *********** //
|
114
92
|
// ************************************** //
|
115
93
|
|
116
|
-
createSessionGroup(name
|
94
|
+
createSessionGroup: ISessionService['createSessionGroup'] = (name, sort) => {
|
117
95
|
return lambdaClient.sessionGroup.createSessionGroup.mutate({ name, sort });
|
118
|
-
}
|
96
|
+
};
|
119
97
|
|
120
|
-
getSessionGroups
|
98
|
+
getSessionGroups: ISessionService['getSessionGroups'] = () => {
|
121
99
|
return lambdaClient.sessionGroup.getSessionGroup.query();
|
122
|
-
}
|
100
|
+
};
|
123
101
|
|
124
|
-
batchCreateSessionGroups(_groups
|
102
|
+
batchCreateSessionGroups: ISessionService['batchCreateSessionGroups'] = (_groups) => {
|
125
103
|
return Promise.resolve({ added: 0, ids: [], skips: [], success: true });
|
126
|
-
}
|
104
|
+
};
|
127
105
|
|
128
|
-
removeSessionGroup(id
|
106
|
+
removeSessionGroup: ISessionService['removeSessionGroup'] = (id, removeChildren) => {
|
129
107
|
return lambdaClient.sessionGroup.removeSessionGroup.mutate({ id, removeChildren });
|
130
|
-
}
|
108
|
+
};
|
131
109
|
|
132
|
-
removeSessionGroups()
|
110
|
+
removeSessionGroups: ISessionService['removeSessionGroups'] = () => {
|
133
111
|
return lambdaClient.sessionGroup.removeAllSessionGroups.mutate();
|
134
|
-
}
|
112
|
+
};
|
135
113
|
|
136
|
-
updateSessionGroup(id
|
137
|
-
// TODO: need be fixed
|
138
|
-
// @ts-ignore
|
114
|
+
updateSessionGroup: ISessionService['updateSessionGroup'] = (id, value) => {
|
139
115
|
return lambdaClient.sessionGroup.updateSessionGroup.mutate({ id, value });
|
140
|
-
}
|
116
|
+
};
|
141
117
|
|
142
|
-
updateSessionGroupOrder
|
118
|
+
updateSessionGroupOrder: ISessionService['updateSessionGroupOrder'] = (sortMap) => {
|
143
119
|
return lambdaClient.sessionGroup.updateSessionGroupOrder.mutate({ sortMap });
|
144
|
-
}
|
120
|
+
};
|
145
121
|
}
|
@@ -9,12 +9,13 @@ import {
|
|
9
9
|
LobeAgentSession,
|
10
10
|
LobeSessionType,
|
11
11
|
LobeSessions,
|
12
|
-
SessionGroupId,
|
13
12
|
SessionGroupItem,
|
14
13
|
SessionGroups,
|
14
|
+
UpdateSessionParams,
|
15
15
|
} from '@/types/session';
|
16
16
|
|
17
17
|
export interface ISessionService {
|
18
|
+
hasSessions(): Promise<boolean>;
|
18
19
|
createSession(type: LobeSessionType, defaultValue: Partial<LobeAgentSession>): Promise<string>;
|
19
20
|
|
20
21
|
/**
|
@@ -29,14 +30,11 @@ export interface ISessionService {
|
|
29
30
|
/**
|
30
31
|
* @deprecated
|
31
32
|
*/
|
32
|
-
getSessionsByType(type
|
33
|
+
getSessionsByType(type?: 'agent' | 'group' | 'all'): Promise<LobeSessions>;
|
33
34
|
countSessions(): Promise<number>;
|
34
35
|
searchSessions(keyword: string): Promise<LobeSessions>;
|
35
36
|
|
36
|
-
updateSession(
|
37
|
-
id: string,
|
38
|
-
data: Partial<{ group?: SessionGroupId; pinned?: boolean }>,
|
39
|
-
): Promise<any>;
|
37
|
+
updateSession(id: string, data: Partial<UpdateSessionParams>): Promise<any>;
|
40
38
|
|
41
39
|
getSessionConfig(id: string): Promise<LobeAgentConfig>;
|
42
40
|
updateSessionConfig(
|
package/src/services/share.ts
CHANGED
@@ -10,22 +10,22 @@ class ShareService {
|
|
10
10
|
* @param settings - The settings object to be encoded in the URL.
|
11
11
|
* @returns The share settings URL.
|
12
12
|
*/
|
13
|
-
public createShareSettingsUrl(settings: DeepPartial<UserSettings>) {
|
13
|
+
public createShareSettingsUrl = (settings: DeepPartial<UserSettings>) => {
|
14
14
|
return withBasePath(`/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`);
|
15
|
-
}
|
15
|
+
};
|
16
16
|
|
17
17
|
/**
|
18
18
|
* Decode share settings from search params
|
19
19
|
* @param settings
|
20
20
|
* @returns
|
21
21
|
*/
|
22
|
-
|
22
|
+
decodeShareSettings = (settings: string) => {
|
23
23
|
try {
|
24
24
|
return { data: JSON.parse(settings) as DeepPartial<UserSettings> };
|
25
25
|
} catch (e) {
|
26
26
|
return { message: JSON.stringify(e) };
|
27
27
|
}
|
28
|
-
}
|
28
|
+
};
|
29
29
|
}
|
30
30
|
|
31
31
|
export const shareService = new ShareService();
|
@@ -9,7 +9,10 @@ interface FetchOptions {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
class ImageGenerationService {
|
12
|
-
|
12
|
+
generateImage = async (
|
13
|
+
params: Omit<OpenAIImagePayload, 'model' | 'n'>,
|
14
|
+
options?: FetchOptions,
|
15
|
+
) => {
|
13
16
|
const payload: OpenAIImagePayload = { ...params, model: 'dall-e-3', n: 1 };
|
14
17
|
|
15
18
|
const provider = ModelProvider.OpenAI;
|
@@ -32,7 +35,7 @@ class ImageGenerationService {
|
|
32
35
|
const urls = await res.json();
|
33
36
|
|
34
37
|
return urls[0] as string;
|
35
|
-
}
|
38
|
+
};
|
36
39
|
}
|
37
40
|
|
38
41
|
export const imageGenerationService = new ImageGenerationService();
|
@@ -3,29 +3,23 @@ import { clientDB } from '@/database/client/db';
|
|
3
3
|
import { MessageModel } from '@/database/server/models/message';
|
4
4
|
import { ThreadModel } from '@/database/server/models/thread';
|
5
5
|
import { BaseClientService } from '@/services/baseClientService';
|
6
|
-
import { CreateMessageParams } from '@/types/message';
|
7
|
-
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
8
6
|
|
9
7
|
import { IThreadService } from './type';
|
10
8
|
|
11
|
-
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
12
|
-
message: CreateMessageParams;
|
13
|
-
}
|
14
9
|
export class ClientService extends BaseClientService implements IThreadService {
|
15
10
|
private get threadModel(): ThreadModel {
|
16
11
|
return new ThreadModel(clientDB as any, this.userId);
|
17
12
|
}
|
13
|
+
|
18
14
|
private get messageModel(): MessageModel {
|
19
15
|
return new MessageModel(clientDB as any, this.userId);
|
20
16
|
}
|
21
17
|
|
22
|
-
getThreads = async (topicId
|
18
|
+
getThreads: IThreadService['getThreads'] = async (topicId) => {
|
23
19
|
return this.threadModel.queryByTopicId(topicId);
|
24
20
|
};
|
25
21
|
|
26
|
-
createThreadWithMessage = async (
|
27
|
-
input: CreateThreadWithMessageParams,
|
28
|
-
): Promise<{ messageId: string; threadId: string }> => {
|
22
|
+
createThreadWithMessage: IThreadService['createThreadWithMessage'] = async (input) => {
|
29
23
|
const thread = await this.threadModel.create({
|
30
24
|
parentThreadId: input.parentThreadId,
|
31
25
|
sourceMessageId: input.sourceMessageId,
|
@@ -43,15 +37,15 @@ export class ClientService extends BaseClientService implements IThreadService {
|
|
43
37
|
return { messageId: message?.id, threadId: thread?.id };
|
44
38
|
};
|
45
39
|
|
46
|
-
updateThread(id
|
40
|
+
updateThread: IThreadService['updateThread'] = async (id, data) => {
|
47
41
|
return this.threadModel.update(id, data);
|
48
|
-
}
|
42
|
+
};
|
49
43
|
|
50
|
-
removeThread(id
|
44
|
+
removeThread: IThreadService['removeThread'] = async (id) => {
|
51
45
|
return this.threadModel.delete(id);
|
52
|
-
}
|
46
|
+
};
|
53
47
|
|
54
|
-
private toDbSessionId(sessionId: string | undefined) {
|
48
|
+
private toDbSessionId = (sessionId: string | undefined) => {
|
55
49
|
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
56
|
-
}
|
50
|
+
};
|
57
51
|
}
|
@@ -1,37 +1,32 @@
|
|
1
1
|
import { INBOX_SESSION_ID } from '@/const/session';
|
2
2
|
import { lambdaClient } from '@/libs/trpc/client';
|
3
|
-
import { CreateMessageParams } from '@/types/message';
|
4
|
-
import { CreateThreadParams, ThreadItem } from '@/types/topic';
|
5
3
|
|
6
4
|
import { IThreadService } from './type';
|
7
5
|
|
8
|
-
interface CreateThreadWithMessageParams extends CreateThreadParams {
|
9
|
-
message: CreateMessageParams;
|
10
|
-
}
|
11
6
|
export class ServerService implements IThreadService {
|
12
|
-
getThreads = (topicId
|
7
|
+
getThreads: IThreadService['getThreads'] = (topicId) => {
|
13
8
|
return lambdaClient.thread.getThreads.query({ topicId });
|
14
9
|
};
|
15
10
|
|
16
|
-
createThreadWithMessage({
|
11
|
+
createThreadWithMessage: IThreadService['createThreadWithMessage'] = async ({
|
17
12
|
message,
|
18
13
|
...params
|
19
|
-
}
|
14
|
+
}) => {
|
20
15
|
return lambdaClient.thread.createThreadWithMessage.mutate({
|
21
16
|
...params,
|
22
17
|
message: { ...message, sessionId: this.toDbSessionId(message.sessionId) },
|
23
18
|
});
|
24
|
-
}
|
19
|
+
};
|
25
20
|
|
26
|
-
updateThread(id
|
21
|
+
updateThread: IThreadService['updateThread'] = async (id, data) => {
|
27
22
|
return lambdaClient.thread.updateThread.mutate({ id, value: data });
|
28
|
-
}
|
23
|
+
};
|
29
24
|
|
30
|
-
removeThread(id
|
25
|
+
removeThread: IThreadService['removeThread'] = async (id) => {
|
31
26
|
return lambdaClient.thread.removeThread.mutate({ id });
|
32
|
-
}
|
27
|
+
};
|
33
28
|
|
34
|
-
private toDbSessionId(sessionId: string | undefined) {
|
29
|
+
private toDbSessionId = (sessionId: string | undefined) => {
|
35
30
|
return sessionId === INBOX_SESSION_ID ? null : sessionId;
|
36
|
-
}
|
31
|
+
};
|
37
32
|
}
|