@lobehub/lobehub 2.0.0-next.105 → 2.0.0-next.107
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/locales/ar/image.json +8 -0
- package/locales/ar/models.json +110 -64
- package/locales/ar/providers.json +3 -0
- package/locales/bg-BG/image.json +8 -0
- package/locales/bg-BG/models.json +98 -68
- package/locales/bg-BG/providers.json +3 -0
- package/locales/de-DE/image.json +8 -0
- package/locales/de-DE/models.json +176 -38
- package/locales/de-DE/providers.json +3 -0
- package/locales/en-US/image.json +8 -0
- package/locales/en-US/models.json +176 -38
- package/locales/en-US/providers.json +3 -0
- package/locales/es-ES/image.json +8 -0
- package/locales/es-ES/models.json +176 -38
- package/locales/es-ES/providers.json +3 -0
- package/locales/fa-IR/image.json +8 -0
- package/locales/fa-IR/models.json +110 -64
- package/locales/fa-IR/providers.json +3 -0
- package/locales/fr-FR/image.json +8 -0
- package/locales/fr-FR/models.json +110 -64
- package/locales/fr-FR/providers.json +3 -0
- package/locales/it-IT/image.json +8 -0
- package/locales/it-IT/models.json +176 -38
- package/locales/it-IT/providers.json +3 -0
- package/locales/ja-JP/image.json +8 -0
- package/locales/ja-JP/models.json +110 -64
- package/locales/ja-JP/providers.json +3 -0
- package/locales/ko-KR/image.json +8 -0
- package/locales/ko-KR/models.json +110 -64
- package/locales/ko-KR/providers.json +3 -0
- package/locales/nl-NL/image.json +8 -0
- package/locales/nl-NL/models.json +176 -38
- package/locales/nl-NL/providers.json +3 -0
- package/locales/pl-PL/image.json +8 -0
- package/locales/pl-PL/models.json +110 -64
- package/locales/pl-PL/providers.json +3 -0
- package/locales/pt-BR/image.json +8 -0
- package/locales/pt-BR/models.json +176 -38
- package/locales/pt-BR/providers.json +3 -0
- package/locales/ru-RU/image.json +8 -0
- package/locales/ru-RU/models.json +98 -68
- package/locales/ru-RU/providers.json +3 -0
- package/locales/tr-TR/image.json +8 -0
- package/locales/tr-TR/models.json +110 -64
- package/locales/tr-TR/providers.json +3 -0
- package/locales/vi-VN/image.json +8 -0
- package/locales/vi-VN/models.json +176 -38
- package/locales/vi-VN/providers.json +3 -0
- package/locales/zh-CN/image.json +8 -0
- package/locales/zh-CN/models.json +179 -38
- package/locales/zh-CN/providers.json +3 -0
- package/locales/zh-TW/image.json +8 -0
- package/locales/zh-TW/models.json +176 -38
- package/locales/zh-TW/providers.json +3 -0
- package/package.json +1 -1
- package/packages/model-runtime/src/providers/google/createImage.test.ts +6 -5
- package/packages/model-runtime/src/providers/google/createImage.ts +12 -8
- package/packages/model-runtime/src/types/error.ts +11 -8
- package/packages/model-runtime/src/utils/googleErrorParser.ts +5 -0
- package/packages/model-runtime/src/utils/postProcessModelList.ts +15 -13
- package/src/server/routers/async/image.ts +20 -2
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ChatModelCard } from '@lobechat/types';
|
|
2
|
+
import { omit } from 'lodash-es';
|
|
2
3
|
import { AiModelType, CHAT_MODEL_IMAGE_GENERATION_PARAMS } from 'model-bank';
|
|
3
4
|
|
|
4
5
|
// Whitelist for automatic image model generation
|
|
5
6
|
export const IMAGE_GENERATION_MODEL_WHITELIST = [
|
|
6
7
|
'gemini-2.5-flash-image-preview',
|
|
7
8
|
'gemini-2.5-flash-image-preview:free',
|
|
9
|
+
'gemini-3-pro-image-preview',
|
|
10
|
+
'gemini-3-pro-image-preview:free',
|
|
8
11
|
// More models can be added in the future
|
|
9
12
|
] as const;
|
|
10
13
|
|
|
@@ -41,19 +44,18 @@ export async function postProcessModelList(
|
|
|
41
44
|
const matchingModels = finalModels.filter((model) => model.id.endsWith(whitelistPattern));
|
|
42
45
|
|
|
43
46
|
for (const model of matchingModels) {
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
files,
|
|
47
|
-
functionCall,
|
|
48
|
-
reasoning,
|
|
49
|
-
search,
|
|
50
|
-
imageOutput,
|
|
51
|
-
video,
|
|
52
|
-
vision,
|
|
53
|
-
type
|
|
54
|
-
parameters
|
|
55
|
-
|
|
56
|
-
} = model;
|
|
47
|
+
// Remove unnecessary properties, keep the rest
|
|
48
|
+
const rest = omit(model, [
|
|
49
|
+
'files',
|
|
50
|
+
'functionCall',
|
|
51
|
+
'reasoning',
|
|
52
|
+
'search',
|
|
53
|
+
'imageOutput',
|
|
54
|
+
'video',
|
|
55
|
+
'vision',
|
|
56
|
+
'type',
|
|
57
|
+
'parameters',
|
|
58
|
+
]);
|
|
57
59
|
|
|
58
60
|
imageModels.push({
|
|
59
61
|
...rest, // Keep other fields (such as displayName, pricing, enabled, contextWindowTokens, etc.)
|
|
@@ -65,6 +65,7 @@ const checkAbortSignal = (signal: AbortSignal) => {
|
|
|
65
65
|
const categorizeError = (
|
|
66
66
|
error: any,
|
|
67
67
|
isAborted: boolean,
|
|
68
|
+
isEditingImage: boolean,
|
|
68
69
|
): { errorMessage: string; errorType: AsyncTaskErrorType } => {
|
|
69
70
|
log('🔥🔥🔥 [ASYNC] categorizeError called:', {
|
|
70
71
|
errorMessage: error?.message,
|
|
@@ -73,6 +74,7 @@ const categorizeError = (
|
|
|
73
74
|
errorType: error?.errorType,
|
|
74
75
|
fullError: JSON.stringify(error, null, 2),
|
|
75
76
|
isAborted,
|
|
77
|
+
isEditingImage,
|
|
76
78
|
});
|
|
77
79
|
// Handle Comfy UI errors
|
|
78
80
|
if (error.errorType === AgentRuntimeErrorType.ComfyUIServiceUnavailable) {
|
|
@@ -127,6 +129,15 @@ const categorizeError = (
|
|
|
127
129
|
};
|
|
128
130
|
}
|
|
129
131
|
|
|
132
|
+
if (error.errorType === AgentRuntimeErrorType.ProviderNoImageGenerated) {
|
|
133
|
+
return {
|
|
134
|
+
errorMessage: isEditingImage
|
|
135
|
+
? 'Provider returned no image (maybe content review). Try a safer source image or milder prompt.'
|
|
136
|
+
: 'Provider returned no image (maybe content review). Try a milder prompt or another model.',
|
|
137
|
+
errorType: AsyncTaskErrorType.ServerError,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
130
141
|
// FIXME: 401 的问题应该放到 agentRuntime 中处理会更好
|
|
131
142
|
if (error.errorType === AgentRuntimeErrorType.InvalidProviderAPIKey || error?.status === 401) {
|
|
132
143
|
return {
|
|
@@ -195,11 +206,14 @@ export const imageRouter = router({
|
|
|
195
206
|
const abortController = new AbortController();
|
|
196
207
|
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
|
197
208
|
|
|
209
|
+
const isEditingImage =
|
|
210
|
+
Boolean((params as any).imageUrl) || Boolean(params.imageUrls && params.imageUrls.length > 0);
|
|
211
|
+
|
|
198
212
|
try {
|
|
199
213
|
const imageGenerationPromise = async (signal: AbortSignal) => {
|
|
200
214
|
log('Initializing agent runtime for provider: %s', provider);
|
|
201
215
|
|
|
202
|
-
const agentRuntime =
|
|
216
|
+
const agentRuntime = initModelRuntimeWithUserPayload(provider, ctx.jwtPayload);
|
|
203
217
|
|
|
204
218
|
// Check if operation has been cancelled
|
|
205
219
|
checkAbortSignal(signal);
|
|
@@ -328,7 +342,11 @@ export const imageRouter = router({
|
|
|
328
342
|
});
|
|
329
343
|
|
|
330
344
|
// Improved error categorization logic
|
|
331
|
-
const { errorType, errorMessage } = categorizeError(
|
|
345
|
+
const { errorType, errorMessage } = categorizeError(
|
|
346
|
+
error,
|
|
347
|
+
abortController.signal.aborted,
|
|
348
|
+
isEditingImage,
|
|
349
|
+
);
|
|
332
350
|
|
|
333
351
|
await ctx.asyncTaskModel.update(taskId, {
|
|
334
352
|
error: new AsyncTaskError(errorType, errorMessage),
|