@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.
Files changed (63) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/changelog/v1.json +18 -0
  3. package/locales/ar/image.json +8 -0
  4. package/locales/ar/models.json +110 -64
  5. package/locales/ar/providers.json +3 -0
  6. package/locales/bg-BG/image.json +8 -0
  7. package/locales/bg-BG/models.json +98 -68
  8. package/locales/bg-BG/providers.json +3 -0
  9. package/locales/de-DE/image.json +8 -0
  10. package/locales/de-DE/models.json +176 -38
  11. package/locales/de-DE/providers.json +3 -0
  12. package/locales/en-US/image.json +8 -0
  13. package/locales/en-US/models.json +176 -38
  14. package/locales/en-US/providers.json +3 -0
  15. package/locales/es-ES/image.json +8 -0
  16. package/locales/es-ES/models.json +176 -38
  17. package/locales/es-ES/providers.json +3 -0
  18. package/locales/fa-IR/image.json +8 -0
  19. package/locales/fa-IR/models.json +110 -64
  20. package/locales/fa-IR/providers.json +3 -0
  21. package/locales/fr-FR/image.json +8 -0
  22. package/locales/fr-FR/models.json +110 -64
  23. package/locales/fr-FR/providers.json +3 -0
  24. package/locales/it-IT/image.json +8 -0
  25. package/locales/it-IT/models.json +176 -38
  26. package/locales/it-IT/providers.json +3 -0
  27. package/locales/ja-JP/image.json +8 -0
  28. package/locales/ja-JP/models.json +110 -64
  29. package/locales/ja-JP/providers.json +3 -0
  30. package/locales/ko-KR/image.json +8 -0
  31. package/locales/ko-KR/models.json +110 -64
  32. package/locales/ko-KR/providers.json +3 -0
  33. package/locales/nl-NL/image.json +8 -0
  34. package/locales/nl-NL/models.json +176 -38
  35. package/locales/nl-NL/providers.json +3 -0
  36. package/locales/pl-PL/image.json +8 -0
  37. package/locales/pl-PL/models.json +110 -64
  38. package/locales/pl-PL/providers.json +3 -0
  39. package/locales/pt-BR/image.json +8 -0
  40. package/locales/pt-BR/models.json +176 -38
  41. package/locales/pt-BR/providers.json +3 -0
  42. package/locales/ru-RU/image.json +8 -0
  43. package/locales/ru-RU/models.json +98 -68
  44. package/locales/ru-RU/providers.json +3 -0
  45. package/locales/tr-TR/image.json +8 -0
  46. package/locales/tr-TR/models.json +110 -64
  47. package/locales/tr-TR/providers.json +3 -0
  48. package/locales/vi-VN/image.json +8 -0
  49. package/locales/vi-VN/models.json +176 -38
  50. package/locales/vi-VN/providers.json +3 -0
  51. package/locales/zh-CN/image.json +8 -0
  52. package/locales/zh-CN/models.json +179 -38
  53. package/locales/zh-CN/providers.json +3 -0
  54. package/locales/zh-TW/image.json +8 -0
  55. package/locales/zh-TW/models.json +176 -38
  56. package/locales/zh-TW/providers.json +3 -0
  57. package/package.json +1 -1
  58. package/packages/model-runtime/src/providers/google/createImage.test.ts +6 -5
  59. package/packages/model-runtime/src/providers/google/createImage.ts +12 -8
  60. package/packages/model-runtime/src/types/error.ts +11 -8
  61. package/packages/model-runtime/src/utils/googleErrorParser.ts +5 -0
  62. package/packages/model-runtime/src/utils/postProcessModelList.ts +15 -13
  63. 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
- // Blacklist: remove unnecessary properties, keep the rest
45
- const {
46
- files, // drop
47
- functionCall, // drop
48
- reasoning, // drop
49
- search, // drop
50
- imageOutput, // drop
51
- video, // drop
52
- vision, // drop
53
- type: _dropType, // will be overwritten
54
- parameters: _dropParams, // will be overwritten
55
- ...rest
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 = await initModelRuntimeWithUserPayload(provider, ctx.jwtPayload);
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(error, abortController.signal.aborted);
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),