@lobehub/chat 1.97.5 → 1.97.7
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 +50 -0
- package/changelog/v1.json +18 -0
- package/package.json +2 -2
- package/src/config/aiModels/vertexai.ts +14 -0
- package/src/database/_deprecated/models/message.ts +2 -2
- package/src/database/_deprecated/models/session.ts +2 -2
- package/src/database/_deprecated/models/user.ts +3 -3
- package/src/database/models/session.ts +3 -3
- package/src/database/models/user.ts +2 -2
- package/src/features/AgentSetting/store/action.ts +2 -2
- package/src/libs/model-runtime/types/chat.ts +2 -2
- package/src/libs/model-runtime/utils/streams/google-ai.test.ts +0 -4
- package/src/libs/model-runtime/utils/streams/google-ai.ts +2 -3
- package/src/libs/model-runtime/utils/streams/vertex-ai.ts +24 -0
- package/src/services/__tests__/share.test.ts +2 -2
- package/src/services/global.ts +2 -2
- package/src/services/session/_deprecated.ts +3 -3
- package/src/services/session/type.ts +2 -2
- package/src/services/share.ts +3 -3
- package/src/services/user/_deprecated.test.ts +2 -2
- package/src/services/user/_deprecated.ts +2 -2
- package/src/services/user/client.test.ts +2 -2
- package/src/services/user/server.test.ts +2 -2
- package/src/services/user/type.ts +2 -2
- package/src/store/agent/slices/chat/action.ts +7 -7
- package/src/store/agent/slices/chat/initialState.ts +2 -2
- package/src/store/session/slices/session/action.ts +2 -2
- package/src/store/user/slices/common/action.ts +2 -2
- package/src/store/user/slices/settings/action.test.ts +3 -3
- package/src/store/user/slices/settings/action.ts +3 -3
- package/src/store/user/slices/settings/initialState.ts +2 -2
- package/src/types/message/tools.ts +2 -2
- package/src/types/serverConfig.ts +3 -3
- package/src/types/user/index.ts +2 -2
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,56 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.97.7](https://github.com/lobehub/lobe-chat/compare/v1.97.6...v1.97.7)
|
6
|
+
|
7
|
+
<sup>Released on **2025-07-10**</sup>
|
8
|
+
|
9
|
+
#### 💄 Styles
|
10
|
+
|
11
|
+
- **misc**: Add google search grounding for Vertex AI.
|
12
|
+
|
13
|
+
<br/>
|
14
|
+
|
15
|
+
<details>
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
17
|
+
|
18
|
+
#### Styles
|
19
|
+
|
20
|
+
- **misc**: Add google search grounding for Vertex AI, closes [#8313](https://github.com/lobehub/lobe-chat/issues/8313) ([afd5900](https://github.com/lobehub/lobe-chat/commit/afd5900))
|
21
|
+
|
22
|
+
</details>
|
23
|
+
|
24
|
+
<div align="right">
|
25
|
+
|
26
|
+
[](#readme-top)
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
### [Version 1.97.6](https://github.com/lobehub/lobe-chat/compare/v1.97.5...v1.97.6)
|
31
|
+
|
32
|
+
<sup>Released on **2025-07-10**</sup>
|
33
|
+
|
34
|
+
#### ♻ Code Refactoring
|
35
|
+
|
36
|
+
- **misc**: Replace `utility-types` with `type-fest`.
|
37
|
+
|
38
|
+
<br/>
|
39
|
+
|
40
|
+
<details>
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
42
|
+
|
43
|
+
#### Code refactoring
|
44
|
+
|
45
|
+
- **misc**: Replace `utility-types` with `type-fest`, closes [#8370](https://github.com/lobehub/lobe-chat/issues/8370) ([a072b53](https://github.com/lobehub/lobe-chat/commit/a072b53))
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<div align="right">
|
50
|
+
|
51
|
+
[](#readme-top)
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
5
55
|
### [Version 1.97.5](https://github.com/lobehub/lobe-chat/compare/v1.97.4...v1.97.5)
|
6
56
|
|
7
57
|
<sup>Released on **2025-07-10**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"improvements": [
|
5
|
+
"Add google search grounding for Vertex AI."
|
6
|
+
]
|
7
|
+
},
|
8
|
+
"date": "2025-07-10",
|
9
|
+
"version": "1.97.7"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"children": {
|
13
|
+
"improvements": [
|
14
|
+
"Replace utility-types with type-fest."
|
15
|
+
]
|
16
|
+
},
|
17
|
+
"date": "2025-07-10",
|
18
|
+
"version": "1.97.6"
|
19
|
+
},
|
2
20
|
{
|
3
21
|
"children": {
|
4
22
|
"improvements": [
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.97.
|
3
|
+
"version": "1.97.7",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
5
5
|
"keywords": [
|
6
6
|
"framework",
|
@@ -262,11 +262,11 @@
|
|
262
262
|
"systemjs": "^6.15.1",
|
263
263
|
"tokenx": "^0.4.1",
|
264
264
|
"ts-md5": "^1.3.1",
|
265
|
+
"type-fest": "^4.41.0",
|
265
266
|
"ua-parser-js": "^1.0.40",
|
266
267
|
"unstructured-client": "^0.19.0",
|
267
268
|
"url-join": "^5.0.0",
|
268
269
|
"use-merge-value": "^1.2.0",
|
269
|
-
"utility-types": "^3.11.0",
|
270
270
|
"uuid": "^11.1.0",
|
271
271
|
"ws": "^8.18.2",
|
272
272
|
"y-protocols": "^1.0.6",
|
@@ -6,6 +6,7 @@ const vertexaiChatModels: AIChatModelCard[] = [
|
|
6
6
|
abilities: {
|
7
7
|
functionCall: true,
|
8
8
|
reasoning: true,
|
9
|
+
search: true,
|
9
10
|
vision: true,
|
10
11
|
},
|
11
12
|
contextWindowTokens: 1_048_576 + 65_536,
|
@@ -20,6 +21,10 @@ const vertexaiChatModels: AIChatModelCard[] = [
|
|
20
21
|
output: 10, // prompts <= 200k tokens
|
21
22
|
},
|
22
23
|
releasedAt: '2025-06-17',
|
24
|
+
settings: {
|
25
|
+
searchImpl: 'params',
|
26
|
+
searchProvider: 'google',
|
27
|
+
},
|
23
28
|
type: 'chat',
|
24
29
|
},
|
25
30
|
{
|
@@ -65,6 +70,7 @@ const vertexaiChatModels: AIChatModelCard[] = [
|
|
65
70
|
abilities: {
|
66
71
|
functionCall: true,
|
67
72
|
reasoning: true,
|
73
|
+
search: true,
|
68
74
|
vision: true,
|
69
75
|
},
|
70
76
|
contextWindowTokens: 1_048_576 + 65_536,
|
@@ -78,6 +84,10 @@ const vertexaiChatModels: AIChatModelCard[] = [
|
|
78
84
|
output: 2.5,
|
79
85
|
},
|
80
86
|
releasedAt: '2025-06-17',
|
87
|
+
settings: {
|
88
|
+
searchImpl: 'params',
|
89
|
+
searchProvider: 'google',
|
90
|
+
},
|
81
91
|
type: 'chat',
|
82
92
|
},
|
83
93
|
{
|
@@ -117,6 +127,10 @@ const vertexaiChatModels: AIChatModelCard[] = [
|
|
117
127
|
output: 0.4,
|
118
128
|
},
|
119
129
|
releasedAt: '2025-06-17',
|
130
|
+
settings: {
|
131
|
+
searchImpl: 'params',
|
132
|
+
searchProvider: 'google',
|
133
|
+
},
|
120
134
|
type: 'chat',
|
121
135
|
},
|
122
136
|
{
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { BaseModel } from '@/database/_deprecated/core';
|
4
4
|
import { DBModel } from '@/database/_deprecated/core/types/db';
|
@@ -189,7 +189,7 @@ class _MessageModel extends BaseModel {
|
|
189
189
|
|
190
190
|
// **************** Update *************** //
|
191
191
|
|
192
|
-
async update(id: string, data:
|
192
|
+
async update(id: string, data: PartialDeep<DB_Message>) {
|
193
193
|
return super._updateWithSync(id, data);
|
194
194
|
}
|
195
195
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { DEFAULT_AGENT_LOBE_SESSION } from '@/const/session';
|
4
4
|
import { BaseModel } from '@/database/_deprecated/core';
|
@@ -232,7 +232,7 @@ class _SessionModel extends BaseModel {
|
|
232
232
|
return super._updateWithSync(id, data);
|
233
233
|
}
|
234
234
|
|
235
|
-
async updateConfig(id: string, data:
|
235
|
+
async updateConfig(id: string, data: PartialDeep<LobeAgentConfig>) {
|
236
236
|
const session = await this.findById(id);
|
237
237
|
if (!session) return;
|
238
238
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { BaseModel } from '@/database/_deprecated/core';
|
4
4
|
import { LobeAgentConfig } from '@/types/agent';
|
@@ -41,7 +41,7 @@ class _UserModel extends BaseModel {
|
|
41
41
|
|
42
42
|
// **************** Update *************** //
|
43
43
|
|
44
|
-
async updateSettings(settings:
|
44
|
+
async updateSettings(settings: PartialDeep<DB_Settings>) {
|
45
45
|
const user = await this.getUser();
|
46
46
|
|
47
47
|
return this.update(user.id, { settings: settings as any });
|
@@ -61,7 +61,7 @@ class _UserModel extends BaseModel {
|
|
61
61
|
|
62
62
|
// **************** Helper *************** //
|
63
63
|
|
64
|
-
private update = async (id: number, value:
|
64
|
+
private update = async (id: number, value: PartialDeep<DB_User>) => {
|
65
65
|
return this.table.update(id, value);
|
66
66
|
};
|
67
67
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Column, count, sql } from 'drizzle-orm';
|
2
2
|
import { and, asc, desc, eq, gt, inArray, isNull, like, not, or } from 'drizzle-orm/expressions';
|
3
|
-
import {
|
3
|
+
import type { PartialDeep } from 'type-fest';
|
4
4
|
|
5
5
|
import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
|
6
6
|
import { INBOX_SESSION_ID } from '@/const/session';
|
@@ -235,7 +235,7 @@ export class SessionModel {
|
|
235
235
|
});
|
236
236
|
};
|
237
237
|
|
238
|
-
createInbox = async (defaultAgentConfig:
|
238
|
+
createInbox = async (defaultAgentConfig: PartialDeep<LobeAgentConfig>) => {
|
239
239
|
const item = await this.db.query.sessions.findFirst({
|
240
240
|
where: and(eq(sessions.userId, this.userId), eq(sessions.slug, INBOX_SESSION_ID)),
|
241
241
|
});
|
@@ -393,7 +393,7 @@ export class SessionModel {
|
|
393
393
|
.returning();
|
394
394
|
};
|
395
395
|
|
396
|
-
updateConfig = async (sessionId: string, data:
|
396
|
+
updateConfig = async (sessionId: string, data: PartialDeep<AgentItem> | undefined | null) => {
|
397
397
|
if (!data || Object.keys(data).length === 0) return;
|
398
398
|
|
399
399
|
const session = await this.findByIdOrSlug(sessionId);
|
@@ -2,7 +2,7 @@ import { TRPCError } from '@trpc/server';
|
|
2
2
|
import dayjs from 'dayjs';
|
3
3
|
import { eq } from 'drizzle-orm/expressions';
|
4
4
|
import type { AdapterAccount } from 'next-auth/adapters';
|
5
|
-
import {
|
5
|
+
import type { PartialDeep } from 'type-fest';
|
6
6
|
|
7
7
|
import { LobeChatDatabase } from '@/database/type';
|
8
8
|
import { UserGuide, UserPreference } from '@/types/user';
|
@@ -99,7 +99,7 @@ export class UserModel {
|
|
99
99
|
/* empty */
|
100
100
|
}
|
101
101
|
|
102
|
-
const settings:
|
102
|
+
const settings: PartialDeep<UserSettings> = {
|
103
103
|
defaultAgent: state.settingsDefaultAgent || {},
|
104
104
|
general: state.settingsGeneral || {},
|
105
105
|
hotkey: state.settingsHotkey || {},
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
1
2
|
import { getSingletonAnalyticsOptional } from '@lobehub/analytics';
|
2
|
-
import { DeepPartial } from 'utility-types';
|
3
3
|
import { StateCreator } from 'zustand/vanilla';
|
4
4
|
|
5
5
|
import { chainPickEmoji } from '@/chains/pickEmoji';
|
@@ -57,7 +57,7 @@ export interface Action extends PublicAction {
|
|
57
57
|
resetAgentConfig: () => Promise<void>;
|
58
58
|
|
59
59
|
resetAgentMeta: () => Promise<void>;
|
60
|
-
setAgentConfig: (config:
|
60
|
+
setAgentConfig: (config: PartialDeep<LobeAgentConfig>) => Promise<void>;
|
61
61
|
setAgentMeta: (meta: Partial<MetaData>) => Promise<void>;
|
62
62
|
|
63
63
|
setChatConfig: (config: Partial<LobeAgentChatConfig>) => Promise<void>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { ModelTokensUsage, ToolFunction } from '@/types/message';
|
4
4
|
|
@@ -19,7 +19,7 @@ export interface MessageToolCall {
|
|
19
19
|
type: 'function' | string;
|
20
20
|
}
|
21
21
|
|
22
|
-
export type MessageToolCallChunk =
|
22
|
+
export type MessageToolCallChunk = PartialDeep<MessageToolCall> & { index: number };
|
23
23
|
|
24
24
|
export type LLMRoleType = 'user' | 'system' | 'assistant' | 'function' | 'tool';
|
25
25
|
|
@@ -86,9 +86,8 @@ const transformGoogleGenerativeAIStream = (
|
|
86
86
|
}
|
87
87
|
|
88
88
|
// return the grounding
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
const { groundingChunks, webSearchQueries } = candidate.groundingMetadata ?? {};
|
90
|
+
if (groundingChunks) {
|
92
91
|
return [
|
93
92
|
{ data: text, id: context.id, type: 'text' },
|
94
93
|
{
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { GenerateContentResponse } from '@google/genai';
|
2
2
|
|
3
3
|
import { ModelTokensUsage } from '@/types/message';
|
4
|
+
import { GroundingSearch } from '@/types/search';
|
4
5
|
import { nanoid } from '@/utils/uuid';
|
5
6
|
|
6
7
|
import { type GoogleAIStreamOptions } from './google-ai';
|
@@ -95,6 +96,29 @@ const transformVertexAIStream = (
|
|
95
96
|
];
|
96
97
|
}
|
97
98
|
|
99
|
+
// return the grounding
|
100
|
+
const { groundingChunks, webSearchQueries } = candidate.groundingMetadata ?? {};
|
101
|
+
if (groundingChunks) {
|
102
|
+
return [
|
103
|
+
!!part?.text ? { data: part.text, id: context?.id, type: 'text' } : undefined,
|
104
|
+
{
|
105
|
+
data: {
|
106
|
+
citations: groundingChunks?.map((chunk) => ({
|
107
|
+
// google 返回的 uri 是经过 google 自己处理过的 url,因此无法展现真实的 favicon
|
108
|
+
// 需要使用 title 作为替换
|
109
|
+
favicon: chunk.web?.title,
|
110
|
+
title: chunk.web?.title,
|
111
|
+
url: chunk.web?.uri,
|
112
|
+
})),
|
113
|
+
searchQueries: webSearchQueries,
|
114
|
+
} as GroundingSearch,
|
115
|
+
id: context.id,
|
116
|
+
type: 'grounding',
|
117
|
+
},
|
118
|
+
...usageChunks,
|
119
|
+
].filter(Boolean) as StreamProtocolChunk[];
|
120
|
+
}
|
121
|
+
|
98
122
|
if (candidate.finishReason) {
|
99
123
|
if (chunk.usageMetadata) {
|
100
124
|
return [
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
3
3
|
|
4
4
|
import { LOBE_URL_IMPORT_NAME } from '@/const/url';
|
@@ -20,7 +20,7 @@ describe('ShareGPTService', () => {
|
|
20
20
|
describe('ShareViaUrl', () => {
|
21
21
|
describe('createShareSettingsUrl', () => {
|
22
22
|
it('should create a share settings URL with the provided settings', () => {
|
23
|
-
const settings:
|
23
|
+
const settings: PartialDeep<UserSettings> = {
|
24
24
|
keyVaults: {
|
25
25
|
openai: {
|
26
26
|
apiKey: 'user-key',
|
package/src/services/global.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { lambdaClient } from '@/libs/trpc/client';
|
4
4
|
import { LobeAgentConfig } from '@/types/agent';
|
@@ -21,7 +21,7 @@ class GlobalService {
|
|
21
21
|
return lambdaClient.config.getGlobalConfig.query();
|
22
22
|
};
|
23
23
|
|
24
|
-
getDefaultAgentConfig = async (): Promise<
|
24
|
+
getDefaultAgentConfig = async (): Promise<PartialDeep<LobeAgentConfig>> => {
|
25
25
|
return lambdaClient.config.getDefaultAgentConfig.query();
|
26
26
|
};
|
27
27
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { INBOX_SESSION_ID } from '@/const/session';
|
4
4
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
@@ -108,7 +108,7 @@ export class ClientService implements ISessionService {
|
|
108
108
|
|
109
109
|
async updateSessionConfig(
|
110
110
|
activeId: string,
|
111
|
-
config:
|
111
|
+
config: PartialDeep<LobeAgentConfig>,
|
112
112
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
113
113
|
_?: AbortSignal,
|
114
114
|
) {
|
@@ -135,7 +135,7 @@ export class ClientService implements ISessionService {
|
|
135
135
|
|
136
136
|
async updateSessionChatConfig(
|
137
137
|
activeId: string,
|
138
|
-
config:
|
138
|
+
config: PartialDeep<LobeAgentChatConfig>,
|
139
139
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
140
140
|
_?: AbortSignal,
|
141
141
|
) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* eslint-disable typescript-sort-keys/interface */
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
|
4
4
|
import { LobeAgentChatConfig, LobeAgentConfig } from '@/types/agent';
|
5
5
|
import { MetaData } from '@/types/meta';
|
@@ -45,7 +45,7 @@ export interface ISessionService {
|
|
45
45
|
getSessionConfig(id: string): Promise<LobeAgentConfig>;
|
46
46
|
updateSessionConfig(
|
47
47
|
id: string,
|
48
|
-
config:
|
48
|
+
config: PartialDeep<LobeAgentConfig>,
|
49
49
|
signal?: AbortSignal,
|
50
50
|
): Promise<any>;
|
51
51
|
|
package/src/services/share.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { LOBE_URL_IMPORT_NAME } from '@/const/url';
|
4
4
|
import { UserSettings } from '@/types/user/settings';
|
@@ -10,7 +10,7 @@ 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:
|
13
|
+
public createShareSettingsUrl = (settings: PartialDeep<UserSettings>) => {
|
14
14
|
return withBasePath(`/?${LOBE_URL_IMPORT_NAME}=${encodeURI(JSON.stringify(settings))}`);
|
15
15
|
};
|
16
16
|
|
@@ -21,7 +21,7 @@ class ShareService {
|
|
21
21
|
*/
|
22
22
|
decodeShareSettings = (settings: string) => {
|
23
23
|
try {
|
24
|
-
return { data: JSON.parse(settings) as
|
24
|
+
return { data: JSON.parse(settings) as PartialDeep<UserSettings> };
|
25
25
|
} catch (e) {
|
26
26
|
return { message: JSON.stringify(e) };
|
27
27
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
3
3
|
|
4
4
|
import { UserModel } from '@/database/_deprecated/models/user';
|
@@ -57,7 +57,7 @@ describe('ClientService', () => {
|
|
57
57
|
});
|
58
58
|
|
59
59
|
it('should update user settings correctly', async () => {
|
60
|
-
const settingsPatch:
|
60
|
+
const settingsPatch: PartialDeep<UserSettings> = { general: { fontSize: 12 } };
|
61
61
|
(UserModel.updateSettings as Mock).mockResolvedValue(undefined);
|
62
62
|
|
63
63
|
await clientService.updateUserSettings(settingsPatch);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { MessageModel } from '@/database/_deprecated/models/message';
|
4
4
|
import { SessionModel } from '@/database/_deprecated/models/session';
|
@@ -47,7 +47,7 @@ export class ClientService implements IUserService {
|
|
47
47
|
};
|
48
48
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
50
|
-
updateUserSettings = async (patch:
|
50
|
+
updateUserSettings = async (patch: PartialDeep<UserSettings>, _?: any) => {
|
51
51
|
return UserModel.updateSettings(patch);
|
52
52
|
};
|
53
53
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { eq } from 'drizzle-orm';
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
4
4
|
|
5
5
|
import { clientDB, initializeDB } from '@/database/client/db';
|
@@ -54,7 +54,7 @@ describe('ClientService', () => {
|
|
54
54
|
});
|
55
55
|
|
56
56
|
it('should update user settings correctly', async () => {
|
57
|
-
const settingsPatch:
|
57
|
+
const settingsPatch: PartialDeep<UserSettings> = { general: { fontSize: 12 } };
|
58
58
|
|
59
59
|
await clientService.updateUserSettings(settingsPatch);
|
60
60
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
3
3
|
|
4
4
|
import { lambdaClient } from '@/libs/trpc/client';
|
@@ -125,7 +125,7 @@ describe('ServerService', () => {
|
|
125
125
|
});
|
126
126
|
|
127
127
|
it('should update user settings', async () => {
|
128
|
-
const settings:
|
128
|
+
const settings: PartialDeep<UserSettings> = {
|
129
129
|
defaultAgent: {
|
130
130
|
config: {
|
131
131
|
model: 'gpt-4',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { AdapterAccount } from 'next-auth/adapters';
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
|
4
4
|
import { UserGuide, UserInitializationState, UserPreference } from '@/types/user';
|
5
5
|
import { UserSettings } from '@/types/user/settings';
|
@@ -17,5 +17,5 @@ export interface IUserService {
|
|
17
17
|
updateAvatar: (avatar: string) => Promise<any>;
|
18
18
|
updateGuide: (guide: Partial<UserGuide>) => Promise<any>;
|
19
19
|
updatePreference: (preference: Partial<UserPreference>) => Promise<any>;
|
20
|
-
updateUserSettings: (value:
|
20
|
+
updateUserSettings: (value: PartialDeep<UserSettings>, signal?: AbortSignal) => Promise<any>;
|
21
21
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
2
2
|
import { produce } from 'immer';
|
3
3
|
import { SWRResponse, mutate } from 'swr';
|
4
|
-
import {
|
4
|
+
import type { PartialDeep } from 'type-fest';
|
5
5
|
import { StateCreator } from 'zustand/vanilla';
|
6
6
|
|
7
7
|
import { MESSAGE_CANCEL_FLAT } from '@/const/message';
|
@@ -28,14 +28,14 @@ export interface AgentChatAction {
|
|
28
28
|
|
29
29
|
internal_dispatchAgentMap: (
|
30
30
|
id: string,
|
31
|
-
config:
|
31
|
+
config: PartialDeep<LobeAgentConfig>,
|
32
32
|
actions?: string,
|
33
33
|
) => void;
|
34
34
|
internal_refreshAgentConfig: (id: string) => Promise<void>;
|
35
35
|
internal_refreshAgentKnowledge: () => Promise<void>;
|
36
36
|
internal_updateAgentConfig: (
|
37
37
|
id: string,
|
38
|
-
data:
|
38
|
+
data: PartialDeep<LobeAgentConfig>,
|
39
39
|
signal?: AbortSignal,
|
40
40
|
) => Promise<void>;
|
41
41
|
removeFileFromAgent: (fileId: string) => Promise<void>;
|
@@ -47,13 +47,13 @@ export interface AgentChatAction {
|
|
47
47
|
|
48
48
|
togglePlugin: (id: string, open?: boolean) => Promise<void>;
|
49
49
|
updateAgentChatConfig: (config: Partial<LobeAgentChatConfig>) => Promise<void>;
|
50
|
-
updateAgentConfig: (config:
|
50
|
+
updateAgentConfig: (config: PartialDeep<LobeAgentConfig>) => Promise<void>;
|
51
51
|
useFetchAgentConfig: (isLogin: boolean | undefined, id: string) => SWRResponse<LobeAgentConfig>;
|
52
52
|
useFetchFilesAndKnowledgeBases: () => SWRResponse<KnowledgeItem[]>;
|
53
53
|
useInitInboxAgentStore: (
|
54
54
|
isLogin: boolean | undefined,
|
55
|
-
defaultAgentConfig?:
|
56
|
-
) => SWRResponse<
|
55
|
+
defaultAgentConfig?: PartialDeep<LobeAgentConfig>,
|
56
|
+
) => SWRResponse<PartialDeep<LobeAgentConfig>>;
|
57
57
|
}
|
58
58
|
|
59
59
|
const FETCH_AGENT_CONFIG_KEY = 'FETCH_AGENT_CONFIG';
|
@@ -189,7 +189,7 @@ export const createChatSlice: StateCreator<
|
|
189
189
|
},
|
190
190
|
|
191
191
|
useInitInboxAgentStore: (isLogin, defaultAgentConfig) =>
|
192
|
-
useOnlyFetchOnceSWR<
|
192
|
+
useOnlyFetchOnceSWR<PartialDeep<LobeAgentConfig>>(
|
193
193
|
!!isLogin ? 'fetchInboxAgentConfig' : null,
|
194
194
|
() => sessionService.getSessionConfig(INBOX_SESSION_ID),
|
195
195
|
{
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
4
4
|
import { AgentSettingsInstance } from '@/features/AgentSetting';
|
@@ -8,7 +8,7 @@ export interface AgentState {
|
|
8
8
|
activeAgentId?: string;
|
9
9
|
activeId: string;
|
10
10
|
agentConfigInitMap: Record<string, boolean>;
|
11
|
-
agentMap: Record<string,
|
11
|
+
agentMap: Record<string, PartialDeep<LobeAgentConfig>>;
|
12
12
|
agentSettingInstance?: AgentSettingsInstance | null;
|
13
13
|
defaultAgentConfig: LobeAgentConfig;
|
14
14
|
isInboxAgentConfigInit: boolean;
|
@@ -2,7 +2,7 @@ import { getSingletonAnalyticsOptional } from '@lobehub/analytics';
|
|
2
2
|
import isEqual from 'fast-deep-equal';
|
3
3
|
import { t } from 'i18next';
|
4
4
|
import useSWR, { SWRResponse, mutate } from 'swr';
|
5
|
-
import {
|
5
|
+
import type { PartialDeep } from 'type-fest';
|
6
6
|
import { StateCreator } from 'zustand/vanilla';
|
7
7
|
|
8
8
|
import { message } from '@/components/AntdStaticMethods';
|
@@ -51,7 +51,7 @@ export interface SessionAction {
|
|
51
51
|
* @returns sessionId
|
52
52
|
*/
|
53
53
|
createSession: (
|
54
|
-
session?:
|
54
|
+
session?: PartialDeep<LobeAgentSession>,
|
55
55
|
isSwitchSession?: boolean,
|
56
56
|
) => Promise<string>;
|
57
57
|
duplicateSession: (id: string) => Promise<void>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { getSingletonAnalyticsOptional } from '@lobehub/analytics';
|
2
2
|
import useSWR, { SWRResponse, mutate } from 'swr';
|
3
|
-
import {
|
3
|
+
import type { PartialDeep } from 'type-fest';
|
4
4
|
import type { StateCreator } from 'zustand/vanilla';
|
5
5
|
|
6
6
|
import { DEFAULT_PREFERENCE } from '@/const/user';
|
@@ -76,7 +76,7 @@ export const createCommonSlice: StateCreator<
|
|
76
76
|
|
77
77
|
if (data) {
|
78
78
|
// merge settings
|
79
|
-
const serverSettings:
|
79
|
+
const serverSettings: PartialDeep<UserSettings> = {
|
80
80
|
defaultAgent: serverConfig.defaultAgent,
|
81
81
|
languageModel: serverConfig.languageModel,
|
82
82
|
systemAgent: serverConfig.systemAgent,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { act, renderHook, waitFor } from '@testing-library/react';
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
import { describe, expect, it, vi } from 'vitest';
|
4
4
|
import { withSWR } from '~test-utils';
|
5
5
|
|
@@ -70,7 +70,7 @@ describe('SettingsAction', () => {
|
|
70
70
|
describe('setSettings', () => {
|
71
71
|
it('should set partial settings', async () => {
|
72
72
|
const { result } = renderHook(() => useUserStore());
|
73
|
-
const partialSettings:
|
73
|
+
const partialSettings: PartialDeep<UserSettings> = { general: { fontSize: 12 } };
|
74
74
|
|
75
75
|
// Perform the action
|
76
76
|
await act(async () => {
|
@@ -108,7 +108,7 @@ describe('SettingsAction', () => {
|
|
108
108
|
describe('updateSystemAgent', () => {
|
109
109
|
it('should set partial settings', async () => {
|
110
110
|
const { result } = renderHook(() => useUserStore());
|
111
|
-
const systemAgentSettings:
|
111
|
+
const systemAgentSettings: PartialDeep<UserSettings> = {
|
112
112
|
systemAgent: {
|
113
113
|
translation: {
|
114
114
|
model: 'testmodel',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import isEqual from 'fast-deep-equal';
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
import type { StateCreator } from 'zustand/vanilla';
|
4
4
|
|
5
5
|
import { MESSAGE_CANCEL_FLAT } from '@/const/message';
|
@@ -22,8 +22,8 @@ export interface UserSettingsAction {
|
|
22
22
|
importUrlShareSettings: (settingsParams: string | null) => Promise<void>;
|
23
23
|
internal_createSignal: () => AbortController;
|
24
24
|
resetSettings: () => Promise<void>;
|
25
|
-
setSettings: (settings:
|
26
|
-
updateDefaultAgent: (agent:
|
25
|
+
setSettings: (settings: PartialDeep<UserSettings>) => Promise<void>;
|
26
|
+
updateDefaultAgent: (agent: PartialDeep<LobeAgentSettings>) => Promise<void>;
|
27
27
|
updateGeneralConfig: (settings: Partial<UserGeneralConfig>) => Promise<void>;
|
28
28
|
updateKeyVaults: (settings: Partial<UserKeyVaults>) => Promise<void>;
|
29
29
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { DEFAULT_SETTINGS } from '@/const/settings';
|
4
4
|
import { UserSettings } from '@/types/user/settings';
|
5
5
|
|
6
6
|
export interface UserSettingsState {
|
7
7
|
defaultSettings: UserSettings;
|
8
|
-
settings:
|
8
|
+
settings: PartialDeep<UserSettings>;
|
9
9
|
updateSettingsSignal?: AbortController;
|
10
10
|
}
|
11
11
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IPluginErrorType } from '@lobehub/chat-plugin-sdk';
|
2
|
-
import {
|
2
|
+
import type { PartialDeep } from 'type-fest';
|
3
3
|
import { z } from 'zod';
|
4
4
|
|
5
5
|
import { LobeToolRenderType } from '@/types/tool';
|
@@ -57,7 +57,7 @@ export interface MessageToolCall {
|
|
57
57
|
type: 'function' | string;
|
58
58
|
}
|
59
59
|
|
60
|
-
export type MessageToolCallChunk =
|
60
|
+
export type MessageToolCallChunk = PartialDeep<MessageToolCall> & { index: number };
|
61
61
|
|
62
62
|
export const MessageToolCallSchema = z.object({
|
63
63
|
function: z.object({
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
|
3
3
|
import { IFeatureFlags } from '@/config/featureFlags';
|
4
4
|
import { ChatModelCard } from '@/types/llm';
|
@@ -22,7 +22,7 @@ export type ServerLanguageModel = Partial<Record<GlobalLLMProviderKey, ServerMod
|
|
22
22
|
|
23
23
|
export interface GlobalServerConfig {
|
24
24
|
aiProvider: ServerLanguageModel;
|
25
|
-
defaultAgent?:
|
25
|
+
defaultAgent?: PartialDeep<UserDefaultAgent>;
|
26
26
|
enableUploadFileToServer?: boolean;
|
27
27
|
enabledAccessCode?: boolean;
|
28
28
|
/**
|
@@ -34,7 +34,7 @@ export interface GlobalServerConfig {
|
|
34
34
|
*/
|
35
35
|
languageModel?: ServerLanguageModel;
|
36
36
|
oAuthSSOProviders?: string[];
|
37
|
-
systemAgent?:
|
37
|
+
systemAgent?: PartialDeep<UserSystemAgentConfig>;
|
38
38
|
telemetry: {
|
39
39
|
langfuse?: boolean;
|
40
40
|
};
|
package/src/types/user/index.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { PartialDeep } from 'type-fest';
|
2
2
|
import { z } from 'zod';
|
3
3
|
|
4
4
|
import { TopicDisplayMode } from '@/types/topic';
|
@@ -55,7 +55,7 @@ export interface UserInitializationState {
|
|
55
55
|
isOnboard?: boolean;
|
56
56
|
lastName?: string;
|
57
57
|
preference: UserPreference;
|
58
|
-
settings:
|
58
|
+
settings: PartialDeep<UserSettings>;
|
59
59
|
userId?: string;
|
60
60
|
username?: string;
|
61
61
|
}
|