@lobehub/lobehub 2.0.0-next.170 → 2.0.0-next.171
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/docs/development/database-schema.dbml +33 -0
- package/package.json +1 -1
- package/packages/database/migrations/0062_add_more_index.sql +15 -0
- package/packages/database/migrations/meta/0062_snapshot.json +8960 -0
- package/packages/database/migrations/meta/_journal.json +7 -0
- package/packages/database/src/core/migrations.json +42 -20
- package/packages/database/src/schemas/apiKey.ts +17 -13
- package/packages/database/src/schemas/asyncTask.ts +16 -12
- package/packages/database/src/schemas/chatGroup.ts +5 -1
- package/packages/database/src/schemas/file.ts +24 -23
- package/packages/database/src/schemas/generation.ts +90 -72
- package/packages/database/src/schemas/message.ts +1 -0
- package/packages/database/src/schemas/rag.ts +6 -1
- package/packages/model-bank/src/aiModels/aihubmix.ts +74 -2
- package/packages/model-bank/src/aiModels/ollamacloud.ts +11 -0
- package/packages/model-bank/src/aiModels/openai.ts +74 -5
- package/packages/model-bank/src/aiModels/zenmux.ts +74 -0
- package/packages/model-runtime/src/const/models.ts +2 -0
- package/packages/model-runtime/src/core/contextBuilders/openai.ts +6 -2
- package/src/server/routers/lambda/image.ts +6 -6
- package/src/server/routers/lambda/user.ts +12 -4
|
@@ -21,7 +21,80 @@ export const openaiChatModels: AIChatModelCard[] = [
|
|
|
21
21
|
{
|
|
22
22
|
abilities: {
|
|
23
23
|
functionCall: true,
|
|
24
|
-
|
|
24
|
+
reasoning: true,
|
|
25
|
+
search: true,
|
|
26
|
+
structuredOutput: true,
|
|
27
|
+
vision: true,
|
|
28
|
+
},
|
|
29
|
+
contextWindowTokens: 400_000,
|
|
30
|
+
description: 'GPT-5.2 — 面向编码与 agentic 工作流的旗舰模型,提供更强推理与长上下文能力。',
|
|
31
|
+
displayName: 'GPT-5.2',
|
|
32
|
+
enabled: true,
|
|
33
|
+
id: 'gpt-5.2',
|
|
34
|
+
maxOutput: 128_000,
|
|
35
|
+
pricing: {
|
|
36
|
+
units: [
|
|
37
|
+
{ name: 'textInput', rate: 1.75, strategy: 'fixed', unit: 'millionTokens' },
|
|
38
|
+
{ name: 'textInput_cacheRead', rate: 0.175, strategy: 'fixed', unit: 'millionTokens' },
|
|
39
|
+
{ name: 'textOutput', rate: 14, strategy: 'fixed', unit: 'millionTokens' },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
releasedAt: '2025-12-11',
|
|
43
|
+
settings: {
|
|
44
|
+
extendParams: ['gpt5_1ReasoningEffort', 'textVerbosity'],
|
|
45
|
+
searchImpl: 'params',
|
|
46
|
+
},
|
|
47
|
+
type: 'chat',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
abilities: {
|
|
51
|
+
functionCall: true,
|
|
52
|
+
reasoning: true,
|
|
53
|
+
search: true,
|
|
54
|
+
vision: true,
|
|
55
|
+
},
|
|
56
|
+
contextWindowTokens: 400_000,
|
|
57
|
+
description:
|
|
58
|
+
'GPT-5.2 pro:更聪明、更精确的 GPT-5.2 版本(Responses API Only),适合高难度问题与更长的多轮推理。',
|
|
59
|
+
displayName: 'GPT-5.2 pro',
|
|
60
|
+
id: 'gpt-5.2-pro',
|
|
61
|
+
maxOutput: 128_000,
|
|
62
|
+
pricing: {
|
|
63
|
+
units: [
|
|
64
|
+
{ name: 'textInput', rate: 21, strategy: 'fixed', unit: 'millionTokens' },
|
|
65
|
+
{ name: 'textOutput', rate: 168, strategy: 'fixed', unit: 'millionTokens' },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
releasedAt: '2025-12-11',
|
|
69
|
+
settings: {
|
|
70
|
+
searchImpl: 'params',
|
|
71
|
+
},
|
|
72
|
+
type: 'chat',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
abilities: {
|
|
76
|
+
functionCall: true,
|
|
77
|
+
vision: true,
|
|
78
|
+
},
|
|
79
|
+
contextWindowTokens: 128_000,
|
|
80
|
+
description: 'GPT-5.2 Chat:ChatGPT 使用的 GPT-5.2 变体(chat-latest),用于体验最新对话改进。',
|
|
81
|
+
displayName: 'GPT-5.2 Chat',
|
|
82
|
+
enabled: true,
|
|
83
|
+
id: 'gpt-5.2-chat-latest',
|
|
84
|
+
maxOutput: 16_384,
|
|
85
|
+
pricing: {
|
|
86
|
+
units: [
|
|
87
|
+
{ name: 'textInput', rate: 1.75, strategy: 'fixed', unit: 'millionTokens' },
|
|
88
|
+
{ name: 'textInput_cacheRead', rate: 0.175, strategy: 'fixed', unit: 'millionTokens' },
|
|
89
|
+
{ name: 'textOutput', rate: 14, strategy: 'fixed', unit: 'millionTokens' },
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
releasedAt: '2025-12-11',
|
|
93
|
+
type: 'chat',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
abilities: {
|
|
97
|
+
functionCall: true,
|
|
25
98
|
reasoning: true,
|
|
26
99
|
search: true,
|
|
27
100
|
vision: true,
|
|
@@ -30,7 +103,6 @@ export const openaiChatModels: AIChatModelCard[] = [
|
|
|
30
103
|
description:
|
|
31
104
|
'GPT-5.1 — 针对编码和 agent 任务优化的旗舰模型,支持可配置的推理强度与更长上下文。',
|
|
32
105
|
displayName: 'GPT-5.1',
|
|
33
|
-
enabled: true,
|
|
34
106
|
id: 'gpt-5.1',
|
|
35
107
|
maxOutput: 128_000,
|
|
36
108
|
pricing: {
|
|
@@ -55,7 +127,6 @@ export const openaiChatModels: AIChatModelCard[] = [
|
|
|
55
127
|
contextWindowTokens: 128_000,
|
|
56
128
|
description: 'GPT-5.1 Chat:用于 ChatGPT 的 GPT-5.1 变体,适合聊天场景。',
|
|
57
129
|
displayName: 'GPT-5.1 Chat',
|
|
58
|
-
enabled: true,
|
|
59
130
|
id: 'gpt-5.1-chat-latest',
|
|
60
131
|
maxOutput: 16_384,
|
|
61
132
|
pricing: {
|
|
@@ -71,7 +142,6 @@ export const openaiChatModels: AIChatModelCard[] = [
|
|
|
71
142
|
{
|
|
72
143
|
abilities: {
|
|
73
144
|
functionCall: true,
|
|
74
|
-
imageOutput: true,
|
|
75
145
|
reasoning: true,
|
|
76
146
|
search: true,
|
|
77
147
|
vision: true,
|
|
@@ -99,7 +169,6 @@ export const openaiChatModels: AIChatModelCard[] = [
|
|
|
99
169
|
{
|
|
100
170
|
abilities: {
|
|
101
171
|
functionCall: true,
|
|
102
|
-
imageOutput: true,
|
|
103
172
|
reasoning: true,
|
|
104
173
|
search: true,
|
|
105
174
|
vision: true,
|
|
@@ -8,6 +8,80 @@ const zenmuxChatModels: AIChatModelCard[] = [
|
|
|
8
8
|
id: 'zenmux/auto',
|
|
9
9
|
type: 'chat',
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
abilities: {
|
|
13
|
+
functionCall: true,
|
|
14
|
+
reasoning: true,
|
|
15
|
+
search: true,
|
|
16
|
+
structuredOutput: true,
|
|
17
|
+
vision: true,
|
|
18
|
+
},
|
|
19
|
+
contextWindowTokens: 400_000,
|
|
20
|
+
description: 'GPT-5.2 — 面向编码与 agentic 工作流的旗舰模型,提供更强推理与长上下文能力。',
|
|
21
|
+
displayName: 'GPT-5.2',
|
|
22
|
+
enabled: true,
|
|
23
|
+
id: 'gpt-5.2',
|
|
24
|
+
maxOutput: 128_000,
|
|
25
|
+
pricing: {
|
|
26
|
+
units: [
|
|
27
|
+
{ name: 'textInput', rate: 1.75, strategy: 'fixed', unit: 'millionTokens' },
|
|
28
|
+
{ name: 'textInput_cacheRead', rate: 0.175, strategy: 'fixed', unit: 'millionTokens' },
|
|
29
|
+
{ name: 'textOutput', rate: 14, strategy: 'fixed', unit: 'millionTokens' },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
releasedAt: '2025-12-11',
|
|
33
|
+
settings: {
|
|
34
|
+
extendParams: ['gpt5_1ReasoningEffort', 'textVerbosity'],
|
|
35
|
+
searchImpl: 'params',
|
|
36
|
+
},
|
|
37
|
+
type: 'chat',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
abilities: {
|
|
41
|
+
functionCall: true,
|
|
42
|
+
reasoning: true,
|
|
43
|
+
search: true,
|
|
44
|
+
vision: true,
|
|
45
|
+
},
|
|
46
|
+
contextWindowTokens: 400_000,
|
|
47
|
+
description:
|
|
48
|
+
'GPT-5.2 pro:更聪明、更精确的 GPT-5.2 版本(Responses API Only),适合高难度问题与更长的多轮推理。',
|
|
49
|
+
displayName: 'GPT-5.2 pro',
|
|
50
|
+
id: 'gpt-5.2-pro',
|
|
51
|
+
maxOutput: 128_000,
|
|
52
|
+
pricing: {
|
|
53
|
+
units: [
|
|
54
|
+
{ name: 'textInput', rate: 21, strategy: 'fixed', unit: 'millionTokens' },
|
|
55
|
+
{ name: 'textOutput', rate: 168, strategy: 'fixed', unit: 'millionTokens' },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
releasedAt: '2025-12-11',
|
|
59
|
+
settings: {
|
|
60
|
+
searchImpl: 'params',
|
|
61
|
+
},
|
|
62
|
+
type: 'chat',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
abilities: {
|
|
66
|
+
functionCall: true,
|
|
67
|
+
vision: true,
|
|
68
|
+
},
|
|
69
|
+
contextWindowTokens: 128_000,
|
|
70
|
+
description: 'GPT-5.2 Chat:ChatGPT 使用的 GPT-5.2 变体(chat-latest),用于体验最新对话改进。',
|
|
71
|
+
displayName: 'GPT-5.2 Chat',
|
|
72
|
+
enabled: true,
|
|
73
|
+
id: 'gpt-5.2-chat-latest',
|
|
74
|
+
maxOutput: 16_384,
|
|
75
|
+
pricing: {
|
|
76
|
+
units: [
|
|
77
|
+
{ name: 'textInput', rate: 1.75, strategy: 'fixed', unit: 'millionTokens' },
|
|
78
|
+
{ name: 'textInput_cacheRead', rate: 0.175, strategy: 'fixed', unit: 'millionTokens' },
|
|
79
|
+
{ name: 'textOutput', rate: 14, strategy: 'fixed', unit: 'millionTokens' },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
releasedAt: '2025-12-11',
|
|
83
|
+
type: 'chat',
|
|
84
|
+
},
|
|
11
85
|
{
|
|
12
86
|
abilities: {
|
|
13
87
|
functionCall: true,
|
|
@@ -136,6 +136,10 @@ export const pruneReasoningPayload = (payload: ChatStreamPayload) => {
|
|
|
136
136
|
const shouldStream = !disableStreamModels.has(payload.model);
|
|
137
137
|
const { stream_options, ...cleanedPayload } = payload as any;
|
|
138
138
|
|
|
139
|
+
// When reasoning_effort is 'none', allow user-defined temperature/top_p
|
|
140
|
+
const effort = payload.reasoning?.effort || payload.reasoning_effort;
|
|
141
|
+
const isEffortNone = effort === 'none';
|
|
142
|
+
|
|
139
143
|
return {
|
|
140
144
|
...cleanedPayload,
|
|
141
145
|
frequency_penalty: 0,
|
|
@@ -152,8 +156,8 @@ export const pruneReasoningPayload = (payload: ChatStreamPayload) => {
|
|
|
152
156
|
stream: shouldStream,
|
|
153
157
|
// Only include stream_options when stream is enabled
|
|
154
158
|
...(shouldStream && stream_options && { stream_options }),
|
|
155
|
-
temperature: 1,
|
|
156
|
-
top_p: 1,
|
|
159
|
+
temperature: isEffortNone ? payload.temperature : 1,
|
|
160
|
+
top_p: isEffortNone ? payload.top_p : 1,
|
|
157
161
|
};
|
|
158
162
|
};
|
|
159
163
|
|
|
@@ -208,8 +208,8 @@ export const imageRouter = router({
|
|
|
208
208
|
|
|
209
209
|
log('Database transaction completed successfully. Starting async task triggers directly.');
|
|
210
210
|
|
|
211
|
-
//
|
|
212
|
-
log('Starting async image generation tasks
|
|
211
|
+
// Step 2: Trigger background image generation tasks using after() API
|
|
212
|
+
log('Starting async image generation tasks with after()');
|
|
213
213
|
|
|
214
214
|
try {
|
|
215
215
|
log('Creating unified async caller for userId: %s', userId);
|
|
@@ -228,18 +228,18 @@ export const imageRouter = router({
|
|
|
228
228
|
log('Unified async caller created successfully for userId: %s', ctx.userId);
|
|
229
229
|
log('Processing %d async image generation tasks', generationsWithTasks.length);
|
|
230
230
|
|
|
231
|
-
//
|
|
231
|
+
// Fire-and-forget: trigger async tasks without awaiting
|
|
232
|
+
// These calls go to the async router which handles them independently
|
|
233
|
+
// Do NOT use after() here as it would keep the lambda alive unnecessarily
|
|
232
234
|
generationsWithTasks.forEach(({ generation, asyncTaskId }) => {
|
|
233
235
|
log('Starting background async task %s for generation %s', asyncTaskId, generation.id);
|
|
234
236
|
|
|
235
|
-
// 不使用 await,让任务在后台异步执行
|
|
236
|
-
// 这里不应该 await 也不应该 .then.catch,让 runtime 早点释放计算资源
|
|
237
237
|
asyncCaller.image.createImage({
|
|
238
238
|
generationId: generation.id,
|
|
239
239
|
model,
|
|
240
240
|
params,
|
|
241
241
|
provider,
|
|
242
|
-
taskId: asyncTaskId,
|
|
242
|
+
taskId: asyncTaskId,
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
UserSettingsSchema,
|
|
11
11
|
} from '@lobechat/types';
|
|
12
12
|
import { TRPCError } from '@trpc/server';
|
|
13
|
+
import { after } from 'next/server';
|
|
13
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
14
15
|
import { z } from 'zod';
|
|
15
16
|
|
|
@@ -55,10 +56,17 @@ export const userRouter = router({
|
|
|
55
56
|
}),
|
|
56
57
|
|
|
57
58
|
getUserState: userProcedure.query(async ({ ctx }): Promise<UserInitializationState> => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
try {
|
|
60
|
+
after(async () => {
|
|
61
|
+
try {
|
|
62
|
+
await ctx.userModel.updateUser({ lastActiveAt: new Date() });
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error('update lastActiveAt failed, error:', err);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
} catch {
|
|
68
|
+
// `after` may fail outside request scope (e.g., in tests), ignore silently
|
|
69
|
+
}
|
|
62
70
|
|
|
63
71
|
let state: Awaited<ReturnType<UserModel['getUserState']>> | undefined;
|
|
64
72
|
|