@lobehub/chat 1.119.1 → 1.120.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.
Files changed (271) hide show
  1. package/.vscode/settings.json +2 -3
  2. package/CHANGELOG.md +58 -0
  3. package/changelog/v1.json +17 -0
  4. package/package.json +5 -6
  5. package/packages/const/src/auth.ts +0 -36
  6. package/packages/const/src/index.ts +3 -1
  7. package/packages/database/src/models/__tests__/aiModel.test.ts +1 -2
  8. package/packages/database/src/models/__tests__/generationBatch.test.ts +47 -1
  9. package/packages/database/src/models/aiModel.ts +2 -3
  10. package/packages/database/src/models/generationBatch.ts +8 -1
  11. package/packages/database/src/repositories/aiInfra/index.test.ts +1 -1
  12. package/packages/database/src/repositories/aiInfra/index.ts +4 -4
  13. package/packages/model-bank/src/aiModels/ai21.ts +1 -1
  14. package/packages/model-bank/src/aiModels/ai302.ts +1 -1
  15. package/packages/model-bank/src/aiModels/ai360.ts +1 -1
  16. package/packages/model-bank/src/aiModels/aihubmix.ts +3 -3
  17. package/packages/model-bank/src/aiModels/akashchat.ts +1 -1
  18. package/packages/model-bank/src/aiModels/anthropic.ts +1 -1
  19. package/packages/model-bank/src/aiModels/azure.ts +1 -1
  20. package/packages/model-bank/src/aiModels/azureai.ts +1 -1
  21. package/packages/model-bank/src/aiModels/baichuan.ts +1 -1
  22. package/packages/model-bank/src/aiModels/bedrock.ts +1 -1
  23. package/packages/model-bank/src/aiModels/bfl.ts +2 -3
  24. package/packages/model-bank/src/aiModels/cloudflare.ts +1 -1
  25. package/packages/model-bank/src/aiModels/cohere.ts +1 -1
  26. package/packages/model-bank/src/aiModels/deepseek.ts +1 -1
  27. package/packages/model-bank/src/aiModels/fal.ts +1 -1
  28. package/packages/model-bank/src/aiModels/fireworksai.ts +1 -1
  29. package/packages/model-bank/src/aiModels/giteeai.ts +1 -1
  30. package/packages/model-bank/src/aiModels/github.ts +1 -1
  31. package/packages/model-bank/src/aiModels/google.ts +6 -7
  32. package/packages/model-bank/src/aiModels/groq.ts +1 -1
  33. package/packages/model-bank/src/aiModels/higress.ts +1 -1
  34. package/packages/model-bank/src/aiModels/huggingface.ts +1 -1
  35. package/packages/model-bank/src/aiModels/hunyuan.ts +1 -1
  36. package/packages/model-bank/src/aiModels/index.ts +1 -1
  37. package/packages/model-bank/src/aiModels/infiniai.ts +1 -1
  38. package/packages/model-bank/src/aiModels/internlm.ts +1 -1
  39. package/packages/model-bank/src/aiModels/jina.ts +1 -1
  40. package/packages/model-bank/src/aiModels/lmstudio.ts +1 -1
  41. package/packages/model-bank/src/aiModels/lobehub.ts +1 -1
  42. package/packages/model-bank/src/aiModels/minimax.ts +1 -1
  43. package/packages/model-bank/src/aiModels/mistral.ts +1 -1
  44. package/packages/model-bank/src/aiModels/modelscope.ts +1 -1
  45. package/packages/model-bank/src/aiModels/moonshot.ts +1 -1
  46. package/packages/model-bank/src/aiModels/novita.ts +1 -1
  47. package/packages/model-bank/src/aiModels/nvidia.ts +1 -1
  48. package/packages/model-bank/src/aiModels/ollama.ts +1 -1
  49. package/packages/model-bank/src/aiModels/openai.ts +1 -1
  50. package/packages/model-bank/src/aiModels/openrouter.ts +3 -3
  51. package/packages/model-bank/src/aiModels/perplexity.ts +1 -1
  52. package/packages/model-bank/src/aiModels/ppio.ts +1 -1
  53. package/packages/model-bank/src/aiModels/qiniu.ts +1 -1
  54. package/packages/model-bank/src/aiModels/qwen.ts +4 -2
  55. package/packages/model-bank/src/aiModels/sambanova.ts +1 -1
  56. package/packages/model-bank/src/aiModels/search1api.ts +1 -1
  57. package/packages/model-bank/src/aiModels/sensenova.ts +1 -1
  58. package/packages/model-bank/src/aiModels/siliconcloud.ts +7 -1
  59. package/packages/model-bank/src/aiModels/spark.ts +1 -1
  60. package/packages/model-bank/src/aiModels/stepfun.ts +1 -1
  61. package/packages/model-bank/src/aiModels/taichu.ts +1 -1
  62. package/packages/model-bank/src/aiModels/tencentcloud.ts +1 -1
  63. package/packages/model-bank/src/aiModels/togetherai.ts +1 -1
  64. package/packages/model-bank/src/aiModels/upstage.ts +1 -1
  65. package/packages/model-bank/src/aiModels/v0.ts +1 -1
  66. package/packages/model-bank/src/aiModels/vertexai.ts +3 -3
  67. package/packages/model-bank/src/aiModels/vllm.ts +1 -1
  68. package/packages/model-bank/src/aiModels/volcengine.ts +1 -1
  69. package/packages/model-bank/src/aiModels/wenxin.ts +1 -1
  70. package/packages/model-bank/src/aiModels/xai.ts +1 -1
  71. package/packages/model-bank/src/aiModels/xinference.ts +1 -1
  72. package/packages/model-bank/src/aiModels/zeroone.ts +1 -1
  73. package/packages/model-bank/src/aiModels/zhipu.ts +1 -1
  74. package/packages/model-bank/src/index.ts +1 -0
  75. package/packages/model-bank/src/standard-parameters/index.ts +48 -0
  76. package/packages/{types/src → model-bank/src/types}/aiModel.ts +12 -1
  77. package/packages/model-bank/src/types/index.ts +1 -0
  78. package/packages/model-runtime/package.json +4 -1
  79. package/packages/model-runtime/src/BaseAI.ts +2 -2
  80. package/packages/model-runtime/src/ModelRuntime.test.ts +4 -4
  81. package/packages/model-runtime/src/RouterRuntime/createRuntime.ts +3 -7
  82. package/packages/model-runtime/src/ai302/index.ts +1 -1
  83. package/packages/model-runtime/src/aihubmix/index.ts +1 -2
  84. package/packages/model-runtime/src/anthropic/index.ts +1 -1
  85. package/packages/model-runtime/src/azureOpenai/index.ts +2 -3
  86. package/packages/model-runtime/src/azureai/index.ts +2 -3
  87. package/packages/model-runtime/src/bedrock/index.ts +1 -1
  88. package/packages/model-runtime/src/bfl/createImage.test.ts +4 -4
  89. package/packages/model-runtime/src/bfl/createImage.ts +2 -2
  90. package/packages/model-runtime/src/bfl/index.ts +1 -1
  91. package/packages/model-runtime/src/cloudflare/index.ts +1 -1
  92. package/packages/model-runtime/src/const/models.ts +64 -0
  93. package/packages/model-runtime/src/fal/index.test.ts +2 -3
  94. package/packages/model-runtime/src/fal/index.ts +1 -1
  95. package/packages/model-runtime/src/github/index.ts +1 -1
  96. package/packages/model-runtime/src/google/createImage.test.ts +1 -1
  97. package/packages/model-runtime/src/google/createImage.ts +53 -25
  98. package/packages/model-runtime/src/google/index.test.ts +1 -1
  99. package/packages/model-runtime/src/google/index.ts +4 -3
  100. package/packages/model-runtime/src/groq/index.ts +1 -1
  101. package/packages/model-runtime/src/helpers/parseToolCalls.ts +1 -2
  102. package/packages/model-runtime/src/huggingface/index.ts +1 -1
  103. package/packages/model-runtime/src/index.ts +3 -1
  104. package/packages/model-runtime/src/infiniai/index.ts +1 -1
  105. package/packages/model-runtime/src/ollama/index.test.ts +1 -1
  106. package/packages/model-runtime/src/ollama/index.ts +2 -3
  107. package/packages/model-runtime/src/openai/index.ts +16 -8
  108. package/packages/model-runtime/src/providerTestUtils.ts +1 -2
  109. package/packages/model-runtime/src/qiniu/index.test.ts +2 -3
  110. package/packages/model-runtime/src/qwen/index.ts +1 -1
  111. package/packages/model-runtime/src/siliconcloud/index.ts +2 -2
  112. package/packages/model-runtime/src/types/chat.ts +2 -22
  113. package/packages/model-runtime/src/{error.ts → types/error.ts} +29 -0
  114. package/packages/model-runtime/src/types/index.ts +4 -0
  115. package/packages/model-runtime/src/types/toolsCalling.ts +48 -0
  116. package/packages/model-runtime/src/types/type.ts +1 -1
  117. package/packages/model-runtime/src/types/usage.ts +27 -0
  118. package/packages/model-runtime/src/utils/anthropicHelpers.test.ts +2 -2
  119. package/packages/model-runtime/src/utils/anthropicHelpers.ts +1 -1
  120. package/packages/model-runtime/src/utils/createError.ts +1 -1
  121. package/packages/model-runtime/src/utils/errorResponse.test.ts +110 -0
  122. package/packages/model-runtime/src/utils/errorResponse.ts +64 -0
  123. package/packages/{utils/src → model-runtime/src/utils}/getFallbackModelProperty.ts +1 -1
  124. package/packages/model-runtime/src/utils/googleErrorParser.test.ts +1 -1
  125. package/packages/model-runtime/src/utils/googleErrorParser.ts +1 -1
  126. package/packages/model-runtime/src/utils/handleOpenAIError.ts +1 -1
  127. package/packages/model-runtime/src/utils/imageToBase64.test.ts +91 -0
  128. package/packages/model-runtime/src/utils/imageToBase64.ts +62 -0
  129. package/packages/model-runtime/src/utils/modelParse.test.ts +2 -2
  130. package/packages/model-runtime/src/utils/modelParse.ts +16 -10
  131. package/packages/model-runtime/src/utils/openaiCompatibleFactory/createImage.ts +1 -1
  132. package/packages/model-runtime/src/utils/openaiCompatibleFactory/index.ts +3 -3
  133. package/packages/model-runtime/src/utils/openaiHelpers.test.ts +2 -2
  134. package/packages/model-runtime/src/utils/openaiHelpers.ts +3 -4
  135. package/packages/model-runtime/src/utils/postProcessModelList.ts +2 -2
  136. package/packages/model-runtime/src/utils/safeParseJSON.test.ts +71 -0
  137. package/packages/model-runtime/src/utils/safeParseJSON.ts +12 -0
  138. package/packages/model-runtime/src/utils/streams/bedrock/claude.ts +1 -1
  139. package/packages/model-runtime/src/utils/streams/bedrock/llama.test.ts +1 -2
  140. package/packages/model-runtime/src/utils/streams/bedrock/llama.ts +1 -1
  141. package/packages/model-runtime/src/utils/streams/google-ai.test.ts +1 -1
  142. package/packages/model-runtime/src/utils/streams/google-ai.ts +1 -1
  143. package/packages/model-runtime/src/utils/streams/ollama.test.ts +1 -1
  144. package/packages/model-runtime/src/utils/streams/ollama.ts +2 -3
  145. package/packages/model-runtime/src/utils/streams/openai/openai.test.ts +1 -2
  146. package/packages/model-runtime/src/utils/streams/openai/openai.ts +1 -1
  147. package/packages/model-runtime/src/utils/streams/openai/responsesStream.ts +1 -1
  148. package/packages/model-runtime/src/utils/streams/protocol.ts +3 -3
  149. package/packages/model-runtime/src/utils/streams/vertex-ai.test.ts +1 -1
  150. package/packages/model-runtime/src/utils/streams/vertex-ai.ts +2 -2
  151. package/packages/model-runtime/src/utils/uuid.ts +7 -0
  152. package/packages/model-runtime/src/vertexai/index.ts +1 -1
  153. package/packages/types/src/agent/index.ts +2 -1
  154. package/packages/types/src/aiProvider.ts +10 -2
  155. package/packages/types/src/auth.ts +35 -0
  156. package/packages/types/src/discover/models.ts +1 -1
  157. package/packages/types/src/discover/providers.ts +1 -1
  158. package/packages/types/src/index.ts +4 -0
  159. package/packages/types/src/llm.ts +2 -47
  160. package/packages/types/src/session/agentSession.ts +3 -3
  161. package/packages/types/src/session/index.ts +2 -2
  162. package/packages/types/src/session/sessionGroup.ts +0 -2
  163. package/packages/types/src/user/settings/general.ts +1 -1
  164. package/packages/types/src/user/settings/modelProvider.ts +1 -1
  165. package/packages/utils/src/fetch/fetchSSE.ts +1 -1
  166. package/packages/utils/src/format.ts +2 -3
  167. package/packages/utils/src/index.ts +3 -1
  168. package/packages/utils/src/number.test.ts +1 -2
  169. package/packages/utils/src/number.ts +1 -2
  170. package/packages/utils/src/parseModels.test.ts +1 -2
  171. package/packages/utils/src/parseModels.ts +2 -3
  172. package/packages/utils/src/pricing.test.ts +1 -2
  173. package/packages/utils/src/pricing.ts +1 -1
  174. package/packages/utils/src/server/xor.ts +3 -1
  175. package/src/app/(backend)/middleware/auth/index.ts +1 -2
  176. package/src/app/(backend)/webapi/chat/vertexai/route.ts +1 -1
  177. package/src/app/(backend)/webapi/text-to-image/[provider]/route.ts +1 -2
  178. package/src/app/[variants]/(main)/(mobile)/me/settings/features/useCategory.tsx +2 -16
  179. package/src/app/[variants]/(main)/chat/@session/_layout/Desktop/SessionHeader.tsx +1 -3
  180. package/src/app/[variants]/(main)/chat/@session/_layout/Mobile/SessionHeader.tsx +1 -3
  181. package/src/app/[variants]/(main)/discover/(list)/model/features/List/ModelTypeIcon.tsx +1 -2
  182. package/src/app/[variants]/(main)/image/@menu/components/SeedNumberInput/index.tsx +1 -1
  183. package/src/app/[variants]/(main)/image/@menu/features/ConfigPanel/hooks/useAutoDimensions.ts +4 -3
  184. package/src/app/[variants]/(main)/settings/hooks/useCategory.tsx +3 -21
  185. package/src/app/[variants]/(main)/settings/provider/features/ModelList/CreateNewModelModal/Form.tsx +1 -1
  186. package/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelItem.tsx +1 -1
  187. package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/ListItem.tsx +1 -1
  188. package/src/app/[variants]/(main)/settings/provider/features/ModelList/SortModelModal/index.tsx +1 -1
  189. package/src/components/ModelSelect/index.tsx +1 -1
  190. package/src/config/featureFlags/schema.test.ts +1 -2
  191. package/src/config/featureFlags/schema.ts +0 -6
  192. package/src/config/featureFlags/utils/parser.test.ts +7 -7
  193. package/src/database/_deprecated/core/index.ts +0 -1
  194. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +2 -5
  195. package/src/database/_deprecated/core/model.ts +4 -38
  196. package/src/database/_deprecated/models/message.ts +1 -1
  197. package/src/features/Conversation/Extras/Usage/UsageDetail/ModelCard.tsx +1 -1
  198. package/src/features/Conversation/Extras/Usage/UsageDetail/pricing.ts +3 -4
  199. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.test.ts +1 -1
  200. package/src/features/Conversation/Extras/Usage/UsageDetail/tokens.ts +3 -2
  201. package/src/layout/GlobalProvider/StoreInitialization.tsx +0 -3
  202. package/src/libs/trpc/async/context.ts +2 -1
  203. package/src/libs/trpc/edge/context.ts +2 -6
  204. package/src/libs/trpc/lambda/context.ts +1 -1
  205. package/src/migrations/FromV5ToV6/types/v5.ts +2 -2
  206. package/src/migrations/FromV5ToV6/types/v6.ts +2 -1
  207. package/src/server/globalConfig/genServerAiProviderConfig.ts +3 -3
  208. package/src/server/modules/ModelRuntime/index.test.ts +1 -1
  209. package/src/server/modules/ModelRuntime/index.ts +1 -1
  210. package/src/server/routers/async/caller.ts +2 -1
  211. package/src/server/routers/async/image.ts +2 -2
  212. package/src/server/routers/lambda/aiModel.ts +1 -1
  213. package/src/server/services/chunk/index.ts +2 -1
  214. package/src/server/services/generation/index.ts +2 -2
  215. package/src/services/_auth.ts +2 -1
  216. package/src/services/aiModel/server.test.ts +1 -1
  217. package/src/services/aiModel/type.ts +1 -1
  218. package/src/services/chat.ts +1 -1
  219. package/src/services/upload.ts +3 -3
  220. package/src/store/agent/slices/chat/action.ts +1 -1
  221. package/src/store/aiInfra/slices/aiModel/action.ts +6 -6
  222. package/src/store/aiInfra/slices/aiModel/initialState.ts +1 -1
  223. package/src/store/aiInfra/slices/aiModel/selectors.test.ts +1 -1
  224. package/src/store/aiInfra/slices/aiModel/selectors.ts +2 -1
  225. package/src/store/aiInfra/slices/aiProvider/__tests__/action.test.ts +7 -7
  226. package/src/store/aiInfra/slices/aiProvider/action.ts +8 -8
  227. package/src/store/aiInfra/slices/aiProvider/initialState.ts +2 -1
  228. package/src/store/electron/actions/app.ts +1 -1
  229. package/src/store/image/slices/generationConfig/action.test.ts +1 -1
  230. package/src/store/image/slices/generationConfig/action.ts +1 -1
  231. package/src/store/image/slices/generationConfig/hooks.test.ts +1 -1
  232. package/src/store/image/slices/generationConfig/hooks.ts +6 -3
  233. package/src/store/image/slices/generationConfig/selectors.test.ts +1 -1
  234. package/src/store/serverConfig/selectors.test.ts +0 -1
  235. package/src/store/user/initialState.ts +1 -4
  236. package/src/store/user/selectors.ts +0 -1
  237. package/src/store/user/slices/auth/action.ts +1 -1
  238. package/src/store/user/slices/auth/selectors.ts +3 -4
  239. package/src/store/user/slices/modelList/action.ts +8 -7
  240. package/src/store/user/slices/modelList/selectors/modelProvider.ts +8 -5
  241. package/src/store/user/slices/preference/selectors.ts +3 -2
  242. package/src/store/user/slices/settings/selectors/settings.ts +1 -2
  243. package/src/store/user/store.ts +1 -4
  244. package/docs/self-hosting/advanced/webrtc.mdx +0 -86
  245. package/docs/self-hosting/advanced/webrtc.zh-CN.mdx +0 -80
  246. package/packages/const/src/image.ts +0 -51
  247. package/src/app/[variants]/(main)/settings/sync/features/Alert.tsx +0 -53
  248. package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/Card.tsx +0 -42
  249. package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/DeviceName.tsx +0 -62
  250. package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/SystemIcon.tsx +0 -31
  251. package/src/app/[variants]/(main)/settings/sync/features/DeviceInfo/index.tsx +0 -103
  252. package/src/app/[variants]/(main)/settings/sync/features/WebRTC/ChannelNameInput.tsx +0 -45
  253. package/src/app/[variants]/(main)/settings/sync/features/WebRTC/SyncSwitch/index.css +0 -238
  254. package/src/app/[variants]/(main)/settings/sync/features/WebRTC/SyncSwitch/index.tsx +0 -79
  255. package/src/app/[variants]/(main)/settings/sync/features/WebRTC/generateRandomRoomName.ts +0 -4
  256. package/src/app/[variants]/(main)/settings/sync/features/WebRTC/index.tsx +0 -103
  257. package/src/app/[variants]/(main)/settings/sync/index.tsx +0 -17
  258. package/src/app/[variants]/(main)/settings/sync/page.tsx +0 -29
  259. package/src/database/_deprecated/core/sync.ts +0 -321
  260. package/src/features/SyncStatusInspector/DisableSync.tsx +0 -79
  261. package/src/features/SyncStatusInspector/EnableSync.tsx +0 -132
  262. package/src/features/SyncStatusInspector/EnableTag.tsx +0 -66
  263. package/src/features/SyncStatusInspector/index.tsx +0 -27
  264. package/src/hooks/useSyncData.ts +0 -50
  265. package/src/services/__tests__/sync.test.ts +0 -56
  266. package/src/services/sync.ts +0 -19
  267. package/src/store/user/slices/sync/action.test.ts +0 -164
  268. package/src/store/user/slices/sync/action.ts +0 -101
  269. package/src/store/user/slices/sync/initialState.ts +0 -13
  270. package/src/store/user/slices/sync/selectors.ts +0 -20
  271. /package/packages/{utils/src → model-runtime/src/utils}/getFallbackModelProperty.test.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://novita.ai/pricing
4
4
  const novitaChatModels: AIChatModelCard[] = [
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const nvidiaChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const ollamaChatModels: AIChatModelCard[] = [
4
4
  {
@@ -6,7 +6,7 @@ import {
6
6
  AIRealtimeModelCard,
7
7
  AISTTModelCard,
8
8
  AITTSModelCard,
9
- } from '@/types/aiModel';
9
+ } from '../types/aiModel';
10
10
 
11
11
  export const gptImage1ParamsSchema: ModelParamsSchema = {
12
12
  imageUrls: { default: [] },
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://openrouter.ai/docs/api-reference/list-available-models
4
4
  const openrouterChatModels: AIChatModelCard[] = [
@@ -37,7 +37,7 @@ const openrouterChatModels: AIChatModelCard[] = [
37
37
  },
38
38
  contextWindowTokens: 32_768 + 8192,
39
39
  description: 'Gemini 2.5 Flash 实验模型,支持图像生成',
40
- displayName: 'Gemini 2.5 Flash Image Preview',
40
+ displayName: 'Nano Banana',
41
41
  id: 'google/gemini-2.5-flash-image-preview',
42
42
  maxOutput: 8192,
43
43
  pricing: {
@@ -57,7 +57,7 @@ const openrouterChatModels: AIChatModelCard[] = [
57
57
  },
58
58
  contextWindowTokens: 32_768 + 8192,
59
59
  description: 'Gemini 2.5 Flash 实验模型,支持图像生成',
60
- displayName: 'Gemini 2.5 Flash Image Preview (free)',
60
+ displayName: 'Nano Banana (free)',
61
61
  id: 'google/gemini-2.5-flash-image-preview:free',
62
62
  maxOutput: 8192,
63
63
  releasedAt: '2025-08-26',
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const perplexityChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const ppioChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://developer.qiniu.com/aitokenapi
4
4
 
@@ -1,11 +1,10 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://help.aliyun.com/zh/model-studio/models?spm=a2c4g.11186623
4
4
 
5
5
  const qwenChatModels: AIChatModelCard[] = [
6
6
  {
7
7
  abilities: {
8
- functionCall: true,
9
8
  reasoning: true,
10
9
  },
11
10
  contextWindowTokens: 131_072,
@@ -20,6 +19,9 @@ const qwenChatModels: AIChatModelCard[] = [
20
19
  { name: 'textOutput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
21
20
  ],
22
21
  },
22
+ settings: {
23
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
24
+ },
23
25
  type: 'chat',
24
26
  },
25
27
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const sambanovaChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const search1apiChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://platform.sensenova.cn/pricing
4
4
  // https://www.sensecore.cn/help/docs/model-as-a-service/nova/release
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://siliconflow.cn/zh-cn/models
4
4
  const siliconcloudChatModels: AIChatModelCard[] = [
@@ -20,6 +20,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
20
20
  { name: 'textOutput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
21
21
  ],
22
22
  },
23
+ settings: {
24
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
25
+ },
23
26
  type: 'chat',
24
27
  },
25
28
  {
@@ -39,6 +42,9 @@ const siliconcloudChatModels: AIChatModelCard[] = [
39
42
  { name: 'textOutput', rate: 12, strategy: 'fixed', unit: 'millionTokens' },
40
43
  ],
41
44
  },
45
+ settings: {
46
+ extendParams: ['enableReasoning', 'reasoningBudgetToken'],
47
+ },
42
48
  type: 'chat',
43
49
  },
44
50
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const sparkChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://platform.stepfun.com/docs/pricing/details
4
4
 
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://docs.wair.ac.cn/maas/jiage.html
4
4
 
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://cloud.tencent.com/document/product/1772/115969
4
4
  const tencentCloudChatModels: AIChatModelCard[] = [
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const togetheraiChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://console.upstage.ai/docs/capabilities/chat
4
4
 
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const v0ChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  // ref: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models
4
4
  const vertexaiChatModels: AIChatModelCard[] = [
@@ -126,8 +126,8 @@ const vertexaiChatModels: AIChatModelCard[] = [
126
126
  },
127
127
  contextWindowTokens: 32_768 + 8192,
128
128
  description:
129
- 'Gemini 2.5 Flash Image Preview 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
130
- displayName: 'Gemini 2.5 Flash Image Preview',
129
+ 'Nano Banana 是 Google 最新、最快、最高效的原生多模态模型,它允许您通过对话生成和编辑图像。',
130
+ displayName: 'Nano Banana',
131
131
  enabled: true,
132
132
  id: 'gemini-2.5-flash-image-preview',
133
133
  maxOutput: 8192,
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const vllmChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  // modelInfo https://www.volcengine.com/docs/82379/1330310
4
4
  // pricing https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  const wenxinChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  // https://docs.x.ai/docs/models
4
4
  const xaiChatModels: AIChatModelCard[] = [
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const xinferenceChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard } from '../types/aiModel';
2
2
 
3
3
  const zerooneChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,4 +1,4 @@
1
- import { AIChatModelCard, AIImageModelCard } from '@/types/aiModel';
1
+ import { AIChatModelCard, AIImageModelCard } from '../types/aiModel';
2
2
 
3
3
  const zhipuChatModels: AIChatModelCard[] = [
4
4
  {
@@ -1,2 +1,3 @@
1
1
  export * from './aiModels';
2
2
  export * from './standard-parameters';
3
+ export * from './types';
@@ -3,6 +3,54 @@ import { z } from 'zod';
3
3
 
4
4
  export const MAX_SEED = 2 ** 31 - 1;
5
5
 
6
+ /**
7
+ * 默认宽高比,当模型不支持原生宽高比时使用
8
+ */
9
+ export const DEFAULT_ASPECT_RATIO = '1:1';
10
+
11
+ export const PRESET_ASPECT_RATIOS = [
12
+ DEFAULT_ASPECT_RATIO, // '1:1' - 正方形,最常用
13
+ '16:9', // 现代显示器/电视/视频标准
14
+ '9:16', // 手机竖屏/短视频
15
+ '4:3', // 传统显示器/照片
16
+ '3:4', // 传统竖屏照片
17
+ '3:2', // 经典照片比例横屏
18
+ '2:3', // 经典照片比例竖屏
19
+ ];
20
+
21
+ /**
22
+ * Image generation and processing configuration constants
23
+ */
24
+ export const IMAGE_GENERATION_CONFIG = {
25
+ /**
26
+ * Maximum cover image size in pixels (longest edge)
27
+ * Used for generating cover images from source images
28
+ */
29
+ COVER_MAX_SIZE: 256,
30
+
31
+ /**
32
+ * Maximum thumbnail size in pixels (longest edge)
33
+ * Used for generating thumbnail images from original images
34
+ */
35
+ THUMBNAIL_MAX_SIZE: 512,
36
+ } as const;
37
+
38
+ /**
39
+ * Default dimension constraints for image upload auto-setting
40
+ * Used when model schema doesn't provide min/max values
41
+ */
42
+ export const DEFAULT_DIMENSION_CONSTRAINTS = {
43
+ MAX_SIZE: 1024,
44
+ MIN_SIZE: 512,
45
+ } as const;
46
+
47
+ export const CHAT_MODEL_IMAGE_GENERATION_PARAMS: ModelParamsSchema = {
48
+ imageUrl: {
49
+ default: null,
50
+ },
51
+ prompt: { default: '' },
52
+ };
53
+
6
54
  // 定义顶层的元规范 - 平铺结构
7
55
  export const ModelParamsMetaSchema = z.object({
8
56
  aspectRatio: z
@@ -1,6 +1,7 @@
1
- import { ModelParamsSchema } from 'model-bank';
2
1
  import { z } from 'zod';
3
2
 
3
+ import { ModelParamsSchema } from '../standard-parameters';
4
+
4
5
  export type ModelPriceCurrency = 'CNY' | 'USD';
5
6
 
6
7
  export const AiModelSourceEnum = {
@@ -8,6 +9,7 @@ export const AiModelSourceEnum = {
8
9
  Custom: 'custom',
9
10
  Remote: 'remote',
10
11
  } as const;
12
+
11
13
  export type AiModelSourceType = (typeof AiModelSourceEnum)[keyof typeof AiModelSourceEnum];
12
14
 
13
15
  export type AiModelType =
@@ -41,6 +43,10 @@ export interface ModelAbilities {
41
43
  * whether model supports search web
42
44
  */
43
45
  search?: boolean;
46
+ /**
47
+ * whether model supports video
48
+ */
49
+ video?: boolean;
44
50
  /**
45
51
  * whether model supports vision
46
52
  */
@@ -71,6 +77,11 @@ export interface LLMParams {
71
77
  * @default 0
72
78
  */
73
79
  presence_penalty?: number;
80
+ /**
81
+ * 生成文本的随机度量,用于控制文本的创造性和多样性
82
+ * @default 1
83
+ */
84
+ reasoning_effort?: string;
74
85
  /**
75
86
  * 生成文本的随机度量,用于控制文本的创造性和多样性
76
87
  * @default 1
@@ -0,0 +1 @@
1
+ export * from './aiModel';
@@ -2,7 +2,10 @@
2
2
  "name": "@lobechat/model-runtime",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
- "main": "./src/index.ts",
5
+ "exports": {
6
+ ".": "./src/index.ts",
7
+ "./vertexai": "./src/vertexai/index.ts"
8
+ },
6
9
  "scripts": {
7
10
  "test": "vitest",
8
11
  "test:coverage": "vitest --coverage"
@@ -1,6 +1,6 @@
1
1
  import OpenAI from 'openai';
2
2
 
3
- import { ChatModelCard } from '@/types/llm';
3
+ import { AIBaseModelCard } from 'model-bank';
4
4
 
5
5
  import {
6
6
  ChatMethodOptions,
@@ -45,7 +45,7 @@ export abstract class LobeOpenAICompatibleRuntime {
45
45
  abstract chat(payload: ChatStreamPayload, options?: ChatMethodOptions): Promise<Response>;
46
46
  abstract createImage(payload: CreateImagePayload): Promise<CreateImageResponse>;
47
47
 
48
- abstract models(): Promise<ChatModelCard[]>;
48
+ abstract models(): Promise<AIBaseModelCard[]>;
49
49
 
50
50
  abstract embeddings(
51
51
  payload: EmbeddingsPayload,
@@ -1,17 +1,17 @@
1
1
  // @vitest-environment node
2
2
  import { TraceNameMap } from '@lobechat/types';
3
+ import { ClientSecretPayload } from '@lobechat/types';
3
4
  import { Langfuse } from 'langfuse';
4
5
  import { LangfuseGenerationClient, LangfuseTraceClient } from 'langfuse-core';
5
6
  import { beforeEach, describe, expect, it, vi } from 'vitest';
6
7
 
7
8
  import * as langfuseCfg from '@/config/langfuse';
8
- import { ClientSecretPayload } from '@/const/auth';
9
- import { ChatStreamPayload, LobeOpenAI, ModelProvider, ModelRuntime } from '@/libs/model-runtime';
10
- import { providerRuntimeMap } from '@/libs/model-runtime/runtimeMap';
11
- import { CreateImagePayload } from '@/libs/model-runtime/types/image';
12
9
  import { createTraceOptions } from '@/server/modules/ModelRuntime';
13
10
 
11
+ import { ChatStreamPayload, LobeOpenAI, ModelProvider, ModelRuntime } from '.';
14
12
  import { AgentChatOptions } from './ModelRuntime';
13
+ import { providerRuntimeMap } from './runtimeMap';
14
+ import { CreateImagePayload } from './types/image';
15
15
 
16
16
  const specialProviders = [
17
17
  { id: 'openai', payload: { apiKey: 'user-openai-key', baseURL: 'user-endpoint' } },
@@ -4,17 +4,11 @@
4
4
  import OpenAI, { ClientOptions } from 'openai';
5
5
  import { Stream } from 'openai/streaming';
6
6
 
7
- import { ILobeAgentRuntimeErrorType } from '@/libs/model-runtime';
8
- import { CreateImagePayload, CreateImageResponse } from '@/libs/model-runtime/types/image';
9
- import {
10
- CreateImageOptions,
11
- CustomClientOptions,
12
- } from '@/libs/model-runtime/utils/openaiCompatibleFactory';
13
- import { postProcessModelList } from '@/libs/model-runtime/utils/postProcessModelList';
14
7
  import type { ChatModelCard } from '@/types/llm';
15
8
 
16
9
  import { LobeRuntimeAI } from '../BaseAI';
17
10
  import { LobeOpenAI } from '../openai';
11
+ import { CreateImagePayload, CreateImageResponse, ILobeAgentRuntimeErrorType } from '../types';
18
12
  import {
19
13
  type ChatCompletionErrorPayload,
20
14
  ChatMethodOptions,
@@ -25,6 +19,8 @@ import {
25
19
  TextToImagePayload,
26
20
  TextToSpeechPayload,
27
21
  } from '../types';
22
+ import { CreateImageOptions, CustomClientOptions } from '../utils/openaiCompatibleFactory';
23
+ import { postProcessModelList } from '../utils/postProcessModelList';
28
24
  import { baseRuntimeMap } from './baseRuntimeMap';
29
25
 
30
26
  export interface RuntimeItem {
@@ -1,5 +1,5 @@
1
- import { AgentRuntimeErrorType } from '../error';
2
1
  import { ChatCompletionErrorPayload, ModelProvider } from '../types';
2
+ import { AgentRuntimeErrorType } from '../types/error';
3
3
  import { processMultiProviderModelList } from '../utils/modelParse';
4
4
  import { createOpenAICompatibleRuntime } from '../utils/openaiCompatibleFactory';
5
5
 
@@ -1,9 +1,8 @@
1
1
  import { LOBE_DEFAULT_MODEL_LIST } from 'model-bank';
2
2
  import urlJoin from 'url-join';
3
3
 
4
- import { responsesAPIModels } from '@/const/models';
5
-
6
4
  import { createRouterRuntime } from '../RouterRuntime';
5
+ import { responsesAPIModels } from '../const/models';
7
6
  import { ModelProvider } from '../types';
8
7
  import { ChatStreamPayload } from '../types/chat';
9
8
  import { detectModelProvider, processMultiProviderModelList } from '../utils/modelParse';
@@ -1,13 +1,13 @@
1
1
  import Anthropic, { ClientOptions } from '@anthropic-ai/sdk';
2
2
 
3
3
  import { LobeRuntimeAI } from '../BaseAI';
4
- import { AgentRuntimeErrorType } from '../error';
5
4
  import {
6
5
  type ChatCompletionErrorPayload,
7
6
  ChatMethodOptions,
8
7
  ChatStreamPayload,
9
8
  ModelProvider,
10
9
  } from '../types';
10
+ import { AgentRuntimeErrorType } from '../types/error';
11
11
  import { buildAnthropicMessages, buildAnthropicTools } from '../utils/anthropicHelpers';
12
12
  import { AgentRuntimeError } from '../utils/createError';
13
13
  import { debugStream } from '../utils/debugStream';
@@ -2,10 +2,8 @@ import debug from 'debug';
2
2
  import OpenAI, { AzureOpenAI } from 'openai';
3
3
  import type { Stream } from 'openai/streaming';
4
4
 
5
- import { systemToUserModels } from '@/const/models';
6
-
7
5
  import { LobeRuntimeAI } from '../BaseAI';
8
- import { AgentRuntimeErrorType } from '../error';
6
+ import { systemToUserModels } from '../const/models';
9
7
  import {
10
8
  ChatMethodOptions,
11
9
  ChatStreamPayload,
@@ -14,6 +12,7 @@ import {
14
12
  EmbeddingsPayload,
15
13
  ModelProvider,
16
14
  } from '../types';
15
+ import { AgentRuntimeErrorType } from '../types/error';
17
16
  import { CreateImagePayload, CreateImageResponse } from '../types/image';
18
17
  import { AgentRuntimeError } from '../utils/createError';
19
18
  import { debugStream } from '../utils/debugStream';
@@ -2,11 +2,10 @@ import createClient, { ModelClient } from '@azure-rest/ai-inference';
2
2
  import { AzureKeyCredential } from '@azure/core-auth';
3
3
  import OpenAI from 'openai';
4
4
 
5
- import { systemToUserModels } from '@/const/models';
6
-
7
5
  import { LobeRuntimeAI } from '../BaseAI';
8
- import { AgentRuntimeErrorType } from '../error';
6
+ import { systemToUserModels } from '../const/models';
9
7
  import { ChatMethodOptions, ChatStreamPayload, ModelProvider } from '../types';
8
+ import { AgentRuntimeErrorType } from '../types/error';
10
9
  import { AgentRuntimeError } from '../utils/createError';
11
10
  import { debugStream } from '../utils/debugStream';
12
11
  import { transformResponseToStream } from '../utils/openaiCompatibleFactory';
@@ -5,7 +5,6 @@ import {
5
5
  } from '@aws-sdk/client-bedrock-runtime';
6
6
 
7
7
  import { LobeRuntimeAI } from '../BaseAI';
8
- import { AgentRuntimeErrorType } from '../error';
9
8
  import {
10
9
  ChatMethodOptions,
11
10
  ChatStreamPayload,
@@ -14,6 +13,7 @@ import {
14
13
  EmbeddingsPayload,
15
14
  ModelProvider,
16
15
  } from '../types';
16
+ import { AgentRuntimeErrorType } from '../types/error';
17
17
  import { buildAnthropicMessages, buildAnthropicTools } from '../utils/anthropicHelpers';
18
18
  import { AgentRuntimeError } from '../utils/createError';
19
19
  import { debugStream } from '../utils/debugStream';
@@ -7,7 +7,7 @@ import { createBflImage } from './createImage';
7
7
  import { BflStatusResponse } from './types';
8
8
 
9
9
  // Mock external dependencies
10
- vi.mock('@lobechat/utils', () => ({
10
+ vi.mock('../utils/imageToBase64', () => ({
11
11
  imageUrlToBase64: vi.fn(),
12
12
  }));
13
13
 
@@ -188,7 +188,7 @@ describe('createBflImage', () => {
188
188
  it('should convert single imageUrl to image_prompt base64', async () => {
189
189
  // Arrange
190
190
  const { parseDataUri } = await import('../utils/uriParser');
191
- const { imageUrlToBase64 } = await import('@lobechat/utils');
191
+ const { imageUrlToBase64 } = await import('../utils/imageToBase64');
192
192
  const { asyncifyPolling } = await import('../utils/asyncifyPolling');
193
193
 
194
194
  const mockParseDataUri = vi.mocked(parseDataUri);
@@ -291,7 +291,7 @@ describe('createBflImage', () => {
291
291
  it('should convert multiple imageUrls for Kontext models', async () => {
292
292
  // Arrange
293
293
  const { parseDataUri } = await import('../utils/uriParser');
294
- const { imageUrlToBase64 } = await import('@lobechat/utils');
294
+ const { imageUrlToBase64 } = await import('../utils/imageToBase64');
295
295
  const { asyncifyPolling } = await import('../utils/asyncifyPolling');
296
296
 
297
297
  const mockParseDataUri = vi.mocked(parseDataUri);
@@ -351,7 +351,7 @@ describe('createBflImage', () => {
351
351
  it('should limit imageUrls to maximum 4 images', async () => {
352
352
  // Arrange
353
353
  const { parseDataUri } = await import('../utils/uriParser');
354
- const { imageUrlToBase64 } = await import('@lobechat/utils');
354
+ const { imageUrlToBase64 } = await import('../utils/imageToBase64');
355
355
  const { asyncifyPolling } = await import('../utils/asyncifyPolling');
356
356
 
357
357
  const mockParseDataUri = vi.mocked(parseDataUri);
@@ -1,11 +1,11 @@
1
- import { imageUrlToBase64 } from '@lobechat/utils';
2
1
  import createDebug from 'debug';
3
2
  import { RuntimeImageGenParamsValue } from 'model-bank';
4
3
 
5
- import { AgentRuntimeErrorType } from '../error';
4
+ import { AgentRuntimeErrorType } from '../types/error';
6
5
  import { CreateImagePayload, CreateImageResponse } from '../types/image';
7
6
  import { type TaskResult, asyncifyPolling } from '../utils/asyncifyPolling';
8
7
  import { AgentRuntimeError } from '../utils/createError';
8
+ import { imageUrlToBase64 } from '../utils/imageToBase64';
9
9
  import { parseDataUri } from '../utils/uriParser';
10
10
  import {
11
11
  BFL_ENDPOINTS,
@@ -2,7 +2,7 @@ import createDebug from 'debug';
2
2
  import { ClientOptions } from 'openai';
3
3
 
4
4
  import { LobeRuntimeAI } from '../BaseAI';
5
- import { AgentRuntimeErrorType } from '../error';
5
+ import { AgentRuntimeErrorType } from '../types/error';
6
6
  import { CreateImagePayload, CreateImageResponse } from '../types/image';
7
7
  import { AgentRuntimeError } from '../utils/createError';
8
8
  import { createBflImage } from './createImage';
@@ -1,8 +1,8 @@
1
1
  import { ChatModelCard } from '@/types/llm';
2
2
 
3
3
  import { LobeRuntimeAI } from '../BaseAI';
4
- import { AgentRuntimeErrorType } from '../error';
5
4
  import { ChatMethodOptions, ChatStreamPayload, ModelProvider } from '../types';
5
+ import { AgentRuntimeErrorType } from '../types/error';
6
6
  import {
7
7
  CloudflareStreamTransformer,
8
8
  DEFAULT_BASE_URL_PREFIX,