@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,7 +1,7 @@
1
- import * as uuidModule from '@lobechat/utils';
2
1
  import { ChatResponse } from 'ollama/browser';
3
2
  import { describe, expect, it, vi } from 'vitest';
4
3
 
4
+ import * as uuidModule from '../uuid';
5
5
  import { OllamaStream } from './ollama';
6
6
 
7
7
  describe('OllamaStream', () => {
@@ -1,8 +1,7 @@
1
- import { nanoid } from '@lobechat/utils';
2
1
  import { ChatResponse } from 'ollama/browser';
3
2
 
4
- import { ChatStreamCallbacks } from '@/libs/model-runtime';
5
-
3
+ import { ChatStreamCallbacks } from '../../types';
4
+ import { nanoid } from '../uuid';
6
5
  import {
7
6
  StreamContext,
8
7
  StreamProtocolChunk,
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, it, vi } from 'vitest';
2
2
 
3
- import { AgentRuntimeErrorType } from '@/libs/model-runtime';
4
-
3
+ import { AgentRuntimeErrorType } from '../../../types/error';
5
4
  import { FIRST_CHUNK_ERROR_KEY } from '../protocol';
6
5
  import { OpenAIStream } from './openai';
7
6
 
@@ -3,8 +3,8 @@ import type { Stream } from 'openai/streaming';
3
3
 
4
4
  import { ChatMessageError, CitationItem } from '@/types/message';
5
5
 
6
- import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../../error';
7
6
  import { ChatStreamCallbacks } from '../../../types';
7
+ import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../../types/error';
8
8
  import { convertUsage } from '../../usageConverter';
9
9
  import {
10
10
  FIRST_CHUNK_ERROR_KEY,
@@ -3,7 +3,7 @@ import type { Stream } from 'openai/streaming';
3
3
 
4
4
  import { ChatMessageError, CitationItem } from '@/types/message';
5
5
 
6
- import { AgentRuntimeErrorType } from '../../../error';
6
+ import { AgentRuntimeErrorType } from '../../../types/error';
7
7
  import { convertResponseUsage } from '../../usageConverter';
8
8
  import {
9
9
  FIRST_CHUNK_ERROR_KEY,
@@ -1,10 +1,10 @@
1
- import { nanoid, safeParseJSON } from '@lobechat/utils';
2
-
3
1
  import { CitationItem, ModelSpeed, ModelTokensUsage } from '@/types/message';
4
2
 
5
- import { AgentRuntimeErrorType } from '../../error';
6
3
  import { parseToolCalls } from '../../helpers';
7
4
  import { ChatStreamCallbacks } from '../../types';
5
+ import { AgentRuntimeErrorType } from '../../types/error';
6
+ import { safeParseJSON } from '../safeParseJSON';
7
+ import { nanoid } from '../uuid';
8
8
 
9
9
  /**
10
10
  * context in the stream to save temporarily data
@@ -1,6 +1,6 @@
1
- import * as uuidModule from '@lobechat/utils';
2
1
  import { describe, expect, it, vi } from 'vitest';
3
2
 
3
+ import * as uuidModule from '../uuid';
4
4
  import { VertexAIStream } from './vertex-ai';
5
5
 
6
6
  describe('VertexAIStream', () => {
@@ -1,9 +1,9 @@
1
1
  import { GenerateContentResponse } from '@google/genai';
2
- import { nanoid } from '@lobechat/utils';
3
2
 
4
- import { ModelTokensUsage } from '@/types/message';
5
3
  import { GroundingSearch } from '@/types/search';
6
4
 
5
+ import { ModelTokensUsage } from '../../types';
6
+ import { nanoid } from '../uuid';
7
7
  import { type GoogleAIStreamOptions } from './google-ai';
8
8
  import {
9
9
  StreamContext,
@@ -0,0 +1,7 @@
1
+ // generate('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 16); //=> "4f90d13a42"
2
+ import { customAlphabet } from 'nanoid/non-secure';
3
+
4
+ export const createNanoId = (size = 8) =>
5
+ customAlphabet('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', size);
6
+
7
+ export const nanoid = createNanoId();
@@ -1,7 +1,7 @@
1
1
  import { GoogleGenAI, GoogleGenAIOptions } from '@google/genai';
2
2
 
3
- import { AgentRuntimeErrorType } from '../error';
4
3
  import { LobeGoogleAI } from '../google';
4
+ import { AgentRuntimeErrorType } from '../types/error';
5
5
  import { AgentRuntimeError } from '../utils/createError';
6
6
 
7
7
  const DEFAULT_VERTEXAI_LOCATION = 'global';
@@ -1,6 +1,7 @@
1
+ import { LLMParams } from '../../../model-bank/src/types/aiModel';
1
2
  import { FileItem } from '../files';
2
3
  import { KnowledgeBaseItem } from '../knowledgeBase';
3
- import { FewShots, LLMParams } from '../llm';
4
+ import { FewShots } from '../llm';
4
5
  import { LobeAgentChatConfig } from './chatConfig';
5
6
 
6
7
  export type TTSServer = 'openai' | 'edge' | 'microsoft';
@@ -1,7 +1,15 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import { AiModelForSelect, EnabledAiModel, ModelSearchImplementType } from './aiModel';
4
- import { ResponseAnimation } from './llm';
3
+ import { AiModelForSelect, EnabledAiModel, ModelSearchImplementType } from '../../model-bank/src/types/aiModel';
4
+
5
+ export type ResponseAnimationStyle = 'smooth' | 'fadeIn' | 'none';
6
+ export type ResponseAnimation =
7
+ | {
8
+ speed?: number;
9
+ text?: ResponseAnimationStyle;
10
+ toolsCalling?: ResponseAnimationStyle;
11
+ }
12
+ | ResponseAnimationStyle;
5
13
 
6
14
  export const AiProviderSourceEnum = {
7
15
  Builtin: 'builtin',
@@ -0,0 +1,35 @@
1
+ /* eslint-disable typescript-sort-keys/interface */
2
+ export interface ClientSecretPayload {
3
+ /**
4
+ * password
5
+ */
6
+ accessCode?: string;
7
+ /**
8
+ * Represents the user's API key
9
+ *
10
+ * If provider need multi keys like bedrock,
11
+ * this will be used as the checker whether to use frontend key
12
+ */
13
+ apiKey?: string;
14
+ /**
15
+ * Represents the endpoint of provider
16
+ */
17
+ baseURL?: string;
18
+
19
+ azureApiVersion?: string;
20
+
21
+ awsAccessKeyId?: string;
22
+ awsRegion?: string;
23
+ awsSecretAccessKey?: string;
24
+ awsSessionToken?: string;
25
+
26
+ cloudflareBaseURLOrAccountID?: string;
27
+
28
+ /**
29
+ * user id
30
+ * in client db mode it's a uuid
31
+ * in server db mode it's a user id
32
+ */
33
+ userId?: string;
34
+ }
35
+ /* eslint-enable */
@@ -1,4 +1,4 @@
1
- import { LobeDefaultAiModelListItem } from '@/types/aiModel';
1
+ import { LobeDefaultAiModelListItem } from '../../../model-bank/src/types/aiModel';
2
2
  import { ModelProviderCard } from '@/types/llm';
3
3
 
4
4
  export enum ModelSorts {
@@ -1,4 +1,4 @@
1
- import { LobeDefaultAiModelListItem } from '@/types/aiModel';
1
+ import { LobeDefaultAiModelListItem } from '../../../model-bank/src/types/aiModel';
2
2
  import { ModelProviderCard } from '@/types/llm';
3
3
 
4
4
  export enum ProviderSorts {
@@ -1,5 +1,8 @@
1
1
  export * from './agent';
2
+ export * from './aiProvider';
2
3
  export * from './artifact';
4
+ export * from './asyncTask';
5
+ export * from './auth';
3
6
  export * from './chunk';
4
7
  export * from './clientDB';
5
8
  export * from './eval';
@@ -8,6 +11,7 @@ export * from './knowledgeBase';
8
11
  export * from './llm';
9
12
  export * from './message';
10
13
  export * from './meta';
14
+ export * from './serverConfig';
11
15
  export * from './user';
12
16
  export * from './user/settings';
13
17
  // FIXME: I think we need a refactor for the "openai" types
@@ -1,10 +1,7 @@
1
- import { ModelParamsSchema } from 'model-bank';
1
+ import { ModelParamsSchema , AiModelType, Pricing } from 'model-bank';
2
2
  import { ReactNode } from 'react';
3
3
 
4
- import { AiModelType, Pricing } from '@/types/aiModel';
5
- import { AiProviderSettings } from '@/types/aiProvider';
6
-
7
- export type ModelPriceCurrency = 'CNY' | 'USD';
4
+ import { AiProviderSettings } from './aiProvider';
8
5
 
9
6
  export interface ChatModelCard {
10
7
  /**
@@ -64,15 +61,6 @@ export interface ChatModelCard {
64
61
  vision?: boolean;
65
62
  }
66
63
 
67
- export type ResponseAnimationStyle = 'smooth' | 'fadeIn' | 'none';
68
- export type ResponseAnimation =
69
- | {
70
- speed?: number;
71
- text?: ResponseAnimationStyle;
72
- toolsCalling?: ResponseAnimationStyle;
73
- }
74
- | ResponseAnimationStyle;
75
-
76
64
  export interface ModelProviderCard {
77
65
  /**
78
66
  * url to get api key
@@ -155,39 +143,6 @@ export interface ModelProviderCard {
155
143
  url: string;
156
144
  }
157
145
 
158
- // 语言模型的设置参数
159
- export interface LLMParams {
160
- /**
161
- * 控制生成文本中的惩罚系数,用于减少重复性
162
- * @default 0
163
- */
164
- frequency_penalty?: number;
165
- /**
166
- * 生成文本的最大长度
167
- */
168
- max_tokens?: number;
169
- /**
170
- * 控制生成文本中的惩罚系数,用于减少主题的变化
171
- * @default 0
172
- */
173
- presence_penalty?: number;
174
- /**
175
- * 生成文本的随机度量,用于控制文本的创造性和多样性
176
- * @default 1
177
- */
178
- reasoning_effort?: string;
179
- /**
180
- * 控制模型推理能力
181
- * @default medium
182
- */
183
- temperature?: number;
184
- /**
185
- * 控制生成文本中最高概率的单个 token
186
- * @default 1
187
- */
188
- top_p?: number;
189
- }
190
-
191
146
  export type LLMRoleType = 'user' | 'system' | 'assistant' | 'tool';
192
147
 
193
148
  export interface LLMMessage {
@@ -1,7 +1,7 @@
1
- import { LobeAgentConfig } from '@/types/agent';
2
-
1
+ import { LobeAgentConfig } from '../agent';
3
2
  import { MetaData } from '../meta';
4
- import { SessionGroupId } from './sessionGroup';
3
+
4
+ export type SessionGroupId = 'default' | 'pinned' | string;
5
5
 
6
6
  export enum LobeSessionType {
7
7
  Agent = 'agent',
@@ -1,5 +1,5 @@
1
- import { LobeSessions } from '@/types/session/agentSession';
2
- import { LobeSessionGroups, SessionGroupId } from '@/types/session/sessionGroup';
1
+ import { LobeSessions, SessionGroupId } from './agentSession';
2
+ import { LobeSessionGroups } from './sessionGroup';
3
3
 
4
4
  export * from './agentSession';
5
5
  export * from './sessionGroup';
@@ -5,8 +5,6 @@ export enum SessionDefaultGroup {
5
5
  Pinned = 'pinned',
6
6
  }
7
7
 
8
- export type SessionGroupId = SessionDefaultGroup | string;
9
-
10
8
  export interface SessionGroupItem {
11
9
  createdAt: Date;
12
10
  id: string;
@@ -1,6 +1,6 @@
1
1
  import type { HighlighterProps, MermaidProps, NeutralColors, PrimaryColors } from '@lobehub/ui';
2
2
 
3
- import { ResponseAnimationStyle } from '@/types/llm';
3
+ import type { ResponseAnimationStyle } from '../../aiProvider';
4
4
 
5
5
  export type AnimationMode = 'disabled' | 'agile' | 'elegant';
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { ModelProviderKey } from '@/libs/model-runtime';
2
- import { AiFullModelCard } from '@/types/aiModel';
2
+ import { AiFullModelCard } from '../../../../model-bank/src/types/aiModel';
3
3
  import { ChatModelCard } from '@/types/llm';
4
4
 
5
5
  export interface ProviderConfig {
@@ -3,7 +3,7 @@ import { ChatErrorType } from '@lobechat/types';
3
3
 
4
4
  import { MESSAGE_CANCEL_FLAT } from '@/const/message';
5
5
  import { LOBE_CHAT_OBSERVATION_ID, LOBE_CHAT_TRACE_ID } from '@/const/trace';
6
- import { ResponseAnimation, ResponseAnimationStyle } from '@/types/llm';
6
+ import { ResponseAnimation, ResponseAnimationStyle } from '@lobechat/types';
7
7
  import {
8
8
  ChatMessageError,
9
9
  MessageToolCall,
@@ -1,10 +1,9 @@
1
+ import { USD_TO_CNY } from '@lobechat/const';
1
2
  import dayjs from 'dayjs';
2
3
  import { isNumber } from 'lodash-es';
4
+ import { ModelPriceCurrency } from 'model-bank';
3
5
  import numeral from 'numeral';
4
6
 
5
- import { USD_TO_CNY } from '@/const/currency';
6
- import { ModelPriceCurrency } from '@/types/llm';
7
-
8
7
  export const formatSize = (bytes: number, fractionDigits: number = 1): string => {
9
8
  if (!bytes && bytes !== 0) return '--';
10
9
 
@@ -1,5 +1,7 @@
1
1
  export * from './client/cookie';
2
- export * from './getFallbackModelProperty';
2
+ export * from './format';
3
3
  export * from './imageToBase64';
4
+ export * from './parseModels';
5
+ export * from './pricing';
4
6
  export * from './safeParseJSON';
5
7
  export * from './uuid';
@@ -1,7 +1,6 @@
1
+ import { MAX_SEED } from 'model-bank';
1
2
  import { describe, expect, it, vi } from 'vitest';
2
3
 
3
- import { MAX_SEED } from '@/const/image';
4
-
5
4
  import { calculateThumbnailDimensions, generateUniqueSeeds } from './number';
6
5
 
7
6
  describe('number utilities', () => {
@@ -1,7 +1,6 @@
1
+ import { IMAGE_GENERATION_CONFIG, MAX_SEED } from 'model-bank';
1
2
  import prand from 'pure-rand';
2
3
 
3
- import { IMAGE_GENERATION_CONFIG, MAX_SEED } from '@/const/image';
4
-
5
4
  export function generateUniqueSeeds(seedCount: number): number[] {
6
5
  // Use current timestamp as the initial seed
7
6
  const initialSeed = Date.now();
@@ -1,8 +1,7 @@
1
1
  import { LOBE_DEFAULT_MODEL_LIST, openaiChatModels } from 'model-bank';
2
+ import { AiFullModelCard } from 'model-bank';
2
3
  import { describe, expect, it } from 'vitest';
3
4
 
4
- import { AiFullModelCard } from '@/types/aiModel';
5
-
6
5
  import { extractEnabledModels, parseModelString, transformToAiModelList } from './parseModels';
7
6
 
8
7
  describe('parseModelString', () => {
@@ -1,8 +1,7 @@
1
+ import { getModelPropertyWithFallback } from '@lobechat/model-runtime';
1
2
  import { produce } from 'immer';
3
+ import { AiFullModelCard, AiModelType } from 'model-bank';
2
4
 
3
- import { AiFullModelCard, AiModelType } from '@/types/aiModel';
4
-
5
- import { getModelPropertyWithFallback } from './getFallbackModelProperty';
6
5
  import { merge } from './merge';
7
6
 
8
7
  /**
@@ -1,7 +1,6 @@
1
+ import { Pricing } from 'model-bank';
1
2
  import { describe, expect, it } from 'vitest';
2
3
 
3
- import { Pricing } from '@/types/aiModel';
4
-
5
4
  import {
6
5
  getAudioInputUnitRate,
7
6
  getAudioOutputUnitRate,
@@ -1,4 +1,4 @@
1
- import { Pricing, PricingUnit, PricingUnitName } from '@/types/aiModel';
1
+ import { Pricing, PricingUnit, PricingUnitName } from 'model-bank';
2
2
 
3
3
  /**
4
4
  * Internal helper to extract the displayed unit rate from a pricing unit by strategy
@@ -1,4 +1,6 @@
1
- import { ClientSecretPayload, SECRET_XOR_KEY } from '@/const/auth';
1
+ import { ClientSecretPayload } from '@lobechat/types';
2
+
3
+ import { SECRET_XOR_KEY } from '@/const/auth';
2
4
 
3
5
  /**
4
6
  * 将 Base64 字符串转换为 Uint8Array
@@ -4,12 +4,11 @@ import {
4
4
  ChatCompletionErrorPayload,
5
5
  ModelRuntime,
6
6
  } from '@lobechat/model-runtime';
7
- import { ChatErrorType } from '@lobechat/types';
7
+ import { ChatErrorType, ClientSecretPayload } from '@lobechat/types';
8
8
  import { getXorPayload } from '@lobechat/utils/server';
9
9
  import { NextRequest } from 'next/server';
10
10
 
11
11
  import {
12
- ClientSecretPayload,
13
12
  LOBE_CHAT_AUTH_HEADER,
14
13
  LOBE_CHAT_OIDC_AUTH_HEADER,
15
14
  OAUTH_AUTHORIZED,
@@ -1,7 +1,7 @@
1
1
  import { ModelProvider, ModelRuntime } from '@lobechat/model-runtime';
2
+ import { LobeVertexAI } from '@lobechat/model-runtime/vertexai';
2
3
 
3
4
  import { checkAuth } from '@/app/(backend)/middleware/auth';
4
- import { LobeVertexAI } from '@/libs/model-runtime/vertexai';
5
5
  import { safeParseJSON } from '@/utils/safeParseJSON';
6
6
 
7
7
  import { POST as UniverseRoute } from '../[provider]/route';
@@ -1,9 +1,8 @@
1
- import { ChatCompletionErrorPayload } from '@lobechat/model-runtime';
1
+ import { ChatCompletionErrorPayload, TextToImagePayload } from '@lobechat/model-runtime';
2
2
  import { ChatErrorType } from '@lobechat/types';
3
3
  import { NextResponse } from 'next/server';
4
4
 
5
5
  import { checkAuth } from '@/app/(backend)/middleware/auth';
6
- import { TextToImagePayload } from '@/libs/model-runtime/types';
7
6
  import { initModelRuntimeWithUserPayload } from '@/server/modules/ModelRuntime';
8
7
  import { createErrorResponse } from '@/utils/errorResponse';
9
8
 
@@ -1,8 +1,6 @@
1
- import { Tag } from '@lobehub/ui';
2
- import { Bot, Brain, Cloudy, Info, Mic2, Settings2, Sparkles } from 'lucide-react';
1
+ import { Bot, Brain, Info, Mic2, Settings2, Sparkles } from 'lucide-react';
3
2
  import { useRouter } from 'next/navigation';
4
3
  import { useTranslation } from 'react-i18next';
5
- import { Flexbox } from 'react-layout-kit';
6
4
  import urlJoin from 'url-join';
7
5
 
8
6
  import { CellProps } from '@/components/Cell';
@@ -13,7 +11,7 @@ import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfi
13
11
  export const useCategory = () => {
14
12
  const router = useRouter();
15
13
  const { t } = useTranslation('setting');
16
- const { enableWebrtc, showLLM } = useServerConfigStore(featureFlagsSelectors);
14
+ const { showLLM } = useServerConfigStore(featureFlagsSelectors);
17
15
 
18
16
  const items: CellProps[] = [
19
17
  {
@@ -26,18 +24,6 @@ export const useCategory = () => {
26
24
  key: SettingsTabs.SystemAgent,
27
25
  label: t('tab.system-agent'),
28
26
  },
29
- enableWebrtc && {
30
- icon: Cloudy,
31
- key: SettingsTabs.Sync,
32
- label: (
33
- <Flexbox align={'center'} gap={8} horizontal>
34
- {t('tab.sync')}
35
- <Tag bordered={false} color={'warning'}>
36
- {t('tab.experiment')}
37
- </Tag>
38
- </Flexbox>
39
- ),
40
- },
41
27
  showLLM &&
42
28
  (isDeprecatedEdition
43
29
  ? {
@@ -9,7 +9,6 @@ import { Flexbox } from 'react-layout-kit';
9
9
 
10
10
  import { ProductLogo } from '@/components/Branding';
11
11
  import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
12
- import SyncStatusTag from '@/features/SyncStatusInspector';
13
12
  import { useActionSWR } from '@/libs/swr';
14
13
  import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
15
14
  import { useSessionStore } from '@/store/session';
@@ -33,7 +32,7 @@ const Header = memo(() => {
33
32
  const { styles } = useStyles();
34
33
  const { t } = useTranslation('chat');
35
34
  const [createSession] = useSessionStore((s) => [s.createSession]);
36
- const { enableWebrtc, showCreateSession } = useServerConfigStore(featureFlagsSelectors);
35
+ const { showCreateSession } = useServerConfigStore(featureFlagsSelectors);
37
36
 
38
37
  const { mutate, isValidating } = useActionSWR('session.createSession', () => createSession());
39
38
 
@@ -50,7 +49,6 @@ const Header = memo(() => {
50
49
  }}
51
50
  >
52
51
  <ProductLogo className={styles.logo} size={36} type={'text'} />
53
- {enableWebrtc && <SyncStatusTag />}
54
52
  </Flexbox>
55
53
  <Flexbox align={'center'} gap={4} horizontal>
56
54
  <TogglePanelButton />
@@ -9,7 +9,6 @@ import { Flexbox } from 'react-layout-kit';
9
9
 
10
10
  import { ProductLogo } from '@/components/Branding';
11
11
  import { MOBILE_HEADER_ICON_SIZE } from '@/const/layoutTokens';
12
- import SyncStatusInspector from '@/features/SyncStatusInspector';
13
12
  import UserAvatar from '@/features/User/UserAvatar';
14
13
  import { featureFlagsSelectors, useServerConfigStore } from '@/store/serverConfig';
15
14
  import { useSessionStore } from '@/store/session';
@@ -18,7 +17,7 @@ import { mobileHeaderSticky } from '@/styles/mobileHeader';
18
17
  const Header = memo(() => {
19
18
  const [createSession] = useSessionStore((s) => [s.createSession]);
20
19
  const router = useRouter();
21
- const { enableWebrtc, showCreateSession } = useServerConfigStore(featureFlagsSelectors);
20
+ const { showCreateSession } = useServerConfigStore(featureFlagsSelectors);
22
21
 
23
22
  return (
24
23
  <ChatHeader
@@ -26,7 +25,6 @@ const Header = memo(() => {
26
25
  <Flexbox align={'center'} gap={8} horizontal style={{ marginLeft: 8 }}>
27
26
  <UserAvatar onClick={() => router.push('/me')} size={32} />
28
27
  <ProductLogo type={'text'} />
29
- {enableWebrtc && <SyncStatusInspector placement={'bottom'} />}
30
28
  </Flexbox>
31
29
  }
32
30
  right={
@@ -12,10 +12,9 @@ import {
12
12
  PhoneIcon,
13
13
  VideoIcon,
14
14
  } from 'lucide-react';
15
+ import { AiModelType } from 'model-bank';
15
16
  import { memo } from 'react';
16
17
 
17
- import { AiModelType } from '@/types/aiModel';
18
-
19
18
  const icons: Record<AiModelType, LucideIcon> = {
20
19
  chat: MessageSquareTextIcon,
21
20
  embedding: BoltIcon,
@@ -2,11 +2,11 @@
2
2
 
3
3
  import { Button, InputNumber, Tooltip } from '@lobehub/ui';
4
4
  import { Dices } from 'lucide-react';
5
+ import { MAX_SEED } from 'model-bank';
5
6
  import { CSSProperties, memo, useCallback } from 'react';
6
7
  import { useTranslation } from 'react-i18next';
7
8
  import { Flexbox } from 'react-layout-kit';
8
9
 
9
- import { MAX_SEED } from '@/const/image';
10
10
  import { generateUniqueSeeds } from '@/utils/number';
11
11
 
12
12
  export interface SeedNumberInputProps {
@@ -1,8 +1,9 @@
1
- import { DEFAULT_DIMENSION_CONSTRAINTS } from '@lobechat/const';
1
+ import { DEFAULT_DIMENSION_CONSTRAINTS } from 'model-bank';
2
2
 
3
- import { constrainDimensions } from '@/app/[variants]/(main)/image/@menu/features/ConfigPanel/utils/dimensionConstraints';
4
3
  import { useImageStore } from '@/store/image';
5
- import { imageGenerationConfigSelectors } from '@/store/image/slices/generationConfig/selectors';
4
+ import { imageGenerationConfigSelectors } from '@/store/image/selectors';
5
+
6
+ import { constrainDimensions } from '../utils/dimensionConstraints';
6
7
 
7
8
  /**
8
9
  * Extract URL and dimensions from callback data (supports both old and new API)