@lobehub/chat 0.146.2 → 0.147.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 (358) hide show
  1. package/.env.example +3 -5
  2. package/.github/workflows/issue-close-require.yml +1 -1
  3. package/.github/workflows/release.yml +1 -1
  4. package/.github/workflows/test.yml +3 -1
  5. package/.i18nrc.js +13 -8
  6. package/.seorc.cjs +9 -0
  7. package/CHANGELOG.md +73 -0
  8. package/README.md +25 -25
  9. package/README.zh-CN.md +25 -25
  10. package/contributing/Home.md +1 -1
  11. package/docs/self-hosting/advanced/analytics.mdx +12 -0
  12. package/docs/self-hosting/advanced/analytics.zh-CN.mdx +10 -0
  13. package/docs/self-hosting/advanced/authentication.mdx +19 -0
  14. package/docs/self-hosting/advanced/authentication.zh-CN.mdx +15 -0
  15. package/docs/self-hosting/advanced/sso-providers/auth0.mdx +19 -2
  16. package/docs/self-hosting/advanced/sso-providers/auth0.zh-CN.mdx +15 -2
  17. package/docs/self-hosting/advanced/sso-providers/authentik.mdx +18 -3
  18. package/docs/self-hosting/advanced/sso-providers/authentik.zh-CN.mdx +14 -2
  19. package/docs/self-hosting/advanced/sso-providers/github.mdx +13 -0
  20. package/docs/self-hosting/advanced/sso-providers/github.zh-CN.mdx +13 -3
  21. package/docs/self-hosting/advanced/sso-providers/microsoft-entra-id.mdx +18 -2
  22. package/docs/self-hosting/advanced/sso-providers/microsoft-entra-id.zh-CN.mdx +15 -2
  23. package/docs/self-hosting/advanced/sso-providers/zitadel.mdx +17 -2
  24. package/docs/self-hosting/advanced/sso-providers/zitadel.zh-CN.mdx +14 -2
  25. package/docs/self-hosting/advanced/upstream-sync.mdx +13 -0
  26. package/docs/self-hosting/advanced/upstream-sync.zh-CN.mdx +10 -0
  27. package/docs/self-hosting/environment-variables/analytics.mdx +15 -0
  28. package/docs/self-hosting/environment-variables/analytics.zh-CN.mdx +13 -0
  29. package/docs/self-hosting/environment-variables/auth.mdx +14 -0
  30. package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +15 -1
  31. package/docs/self-hosting/environment-variables/basic.mdx +15 -0
  32. package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +11 -0
  33. package/docs/self-hosting/environment-variables/model-provider.mdx +26 -0
  34. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +10 -0
  35. package/docs/self-hosting/environment-variables.mdx +13 -2
  36. package/docs/self-hosting/environment-variables.zh-CN.mdx +9 -0
  37. package/docs/self-hosting/examples/azure-openai.mdx +12 -0
  38. package/docs/self-hosting/examples/azure-openai.zh-CN.mdx +12 -0
  39. package/docs/self-hosting/examples/ollama.mdx +13 -0
  40. package/docs/self-hosting/examples/ollama.zh-CN.mdx +11 -0
  41. package/docs/self-hosting/faq/no-v1-suffix.mdx +12 -0
  42. package/docs/self-hosting/faq/no-v1-suffix.zh-CN.mdx +9 -0
  43. package/docs/self-hosting/faq/proxy-with-unable-to-verify-leaf-signature.mdx +14 -0
  44. package/docs/self-hosting/faq/proxy-with-unable-to-verify-leaf-signature.zh-CN.mdx +11 -0
  45. package/docs/self-hosting/platform/docker-compose.mdx +21 -5
  46. package/docs/self-hosting/platform/docker-compose.zh-CN.mdx +18 -5
  47. package/docs/self-hosting/platform/docker.mdx +26 -8
  48. package/docs/self-hosting/platform/docker.zh-CN.mdx +27 -9
  49. package/docs/self-hosting/platform/netlify.mdx +18 -2
  50. package/docs/self-hosting/platform/netlify.zh-CN.mdx +14 -1
  51. package/docs/self-hosting/platform/railway.mdx +12 -0
  52. package/docs/self-hosting/platform/railway.zh-CN.mdx +11 -0
  53. package/docs/self-hosting/platform/repocloud.mdx +12 -0
  54. package/docs/self-hosting/platform/repocloud.zh-CN.mdx +10 -0
  55. package/docs/self-hosting/platform/sealos.mdx +11 -0
  56. package/docs/self-hosting/platform/sealos.zh-CN.mdx +10 -0
  57. package/docs/self-hosting/platform/vercel.mdx +12 -0
  58. package/docs/self-hosting/platform/vercel.zh-CN.mdx +11 -0
  59. package/docs/self-hosting/platform/zeabur.mdx +11 -0
  60. package/docs/self-hosting/platform/zeabur.zh-CN.mdx +10 -0
  61. package/docs/self-hosting/start.mdx +12 -0
  62. package/docs/self-hosting/start.zh-CN.mdx +13 -0
  63. package/docs/usage/agents/concepts.mdx +13 -0
  64. package/docs/usage/agents/concepts.zh-CN.mdx +10 -0
  65. package/docs/usage/agents/custom-agent.mdx +16 -2
  66. package/docs/usage/agents/custom-agent.zh-CN.mdx +14 -2
  67. package/docs/usage/agents/model.mdx +11 -2
  68. package/docs/usage/agents/model.zh-CN.mdx +12 -0
  69. package/docs/usage/agents/prompt.mdx +15 -0
  70. package/docs/usage/agents/prompt.zh-CN.mdx +10 -0
  71. package/docs/usage/agents/topics.mdx +13 -0
  72. package/docs/usage/agents/topics.zh-CN.mdx +11 -0
  73. package/docs/usage/features/agent-market.mdx +11 -1
  74. package/docs/usage/features/agent-market.zh-CN.mdx +13 -0
  75. package/docs/usage/features/local-llm.mdx +12 -2
  76. package/docs/usage/features/local-llm.zh-CN.mdx +3 -3
  77. package/docs/usage/features/mobile.mdx +10 -1
  78. package/docs/usage/features/mobile.zh-CN.mdx +11 -0
  79. package/docs/usage/features/more.mdx +13 -0
  80. package/docs/usage/features/more.zh-CN.mdx +10 -0
  81. package/docs/usage/features/multi-ai-providers.mdx +14 -1
  82. package/docs/usage/features/multi-ai-providers.zh-CN.mdx +16 -0
  83. package/docs/usage/features/plugin-system.mdx +12 -1
  84. package/docs/usage/features/plugin-system.zh-CN.mdx +9 -0
  85. package/docs/usage/features/pwa.mdx +11 -1
  86. package/docs/usage/features/pwa.zh-CN.mdx +13 -0
  87. package/docs/usage/features/text-to-image.mdx +11 -1
  88. package/docs/usage/features/text-to-image.zh-CN.mdx +13 -0
  89. package/docs/usage/features/theme.mdx +12 -1
  90. package/docs/usage/features/theme.zh-CN.mdx +11 -0
  91. package/docs/usage/features/tts.mdx +14 -1
  92. package/docs/usage/features/tts.zh-CN.mdx +12 -0
  93. package/docs/usage/features/vision.mdx +11 -1
  94. package/docs/usage/features/vision.zh-CN.mdx +10 -0
  95. package/docs/usage/plugins/basic-usage.mdx +12 -0
  96. package/docs/usage/plugins/basic-usage.zh-CN.mdx +10 -0
  97. package/docs/usage/plugins/custom-plugin.mdx +12 -0
  98. package/docs/usage/plugins/custom-plugin.zh-CN.mdx +10 -0
  99. package/docs/usage/plugins/development.mdx +18 -0
  100. package/docs/usage/plugins/development.zh-CN.mdx +12 -0
  101. package/docs/usage/plugins/store.mdx +12 -0
  102. package/docs/usage/plugins/store.zh-CN.mdx +9 -0
  103. package/docs/usage/providers/groq.mdx +14 -2
  104. package/docs/usage/providers/groq.zh-CN.mdx +12 -2
  105. package/docs/usage/providers/ollama/gemma.mdx +13 -3
  106. package/docs/usage/providers/ollama/gemma.zh-CN.mdx +12 -3
  107. package/docs/usage/providers/ollama/qwen.mdx +12 -4
  108. package/docs/usage/providers/ollama/qwen.zh-CN.mdx +10 -3
  109. package/docs/usage/providers/ollama.mdx +19 -9
  110. package/docs/usage/providers/ollama.zh-CN.mdx +20 -9
  111. package/docs/usage/start.mdx +13 -2
  112. package/docs/usage/start.zh-CN.mdx +11 -2
  113. package/locales/ar/common.json +0 -26
  114. package/locales/ar/components.json +15 -0
  115. package/locales/ar/error.json +1 -52
  116. package/locales/ar/modelProvider.json +226 -0
  117. package/locales/ar/setting.json +48 -199
  118. package/locales/bg-BG/common.json +0 -26
  119. package/locales/bg-BG/components.json +15 -0
  120. package/locales/bg-BG/error.json +1 -52
  121. package/locales/bg-BG/modelProvider.json +226 -0
  122. package/locales/bg-BG/setting.json +48 -199
  123. package/locales/de-DE/common.json +0 -26
  124. package/locales/de-DE/components.json +15 -0
  125. package/locales/de-DE/error.json +1 -52
  126. package/locales/de-DE/modelProvider.json +226 -0
  127. package/locales/de-DE/setting.json +48 -199
  128. package/locales/en-US/common.json +0 -26
  129. package/locales/en-US/components.json +15 -0
  130. package/locales/en-US/error.json +1 -52
  131. package/locales/en-US/modelProvider.json +226 -0
  132. package/locales/en-US/setting.json +48 -199
  133. package/locales/es-ES/common.json +0 -26
  134. package/locales/es-ES/components.json +15 -0
  135. package/locales/es-ES/error.json +1 -52
  136. package/locales/es-ES/modelProvider.json +226 -0
  137. package/locales/es-ES/setting.json +48 -199
  138. package/locales/fr-FR/common.json +0 -26
  139. package/locales/fr-FR/components.json +15 -0
  140. package/locales/fr-FR/error.json +1 -52
  141. package/locales/fr-FR/modelProvider.json +226 -0
  142. package/locales/fr-FR/setting.json +48 -199
  143. package/locales/it-IT/common.json +0 -26
  144. package/locales/it-IT/components.json +15 -0
  145. package/locales/it-IT/error.json +1 -52
  146. package/locales/it-IT/modelProvider.json +226 -0
  147. package/locales/it-IT/setting.json +59 -210
  148. package/locales/ja-JP/common.json +0 -26
  149. package/locales/ja-JP/components.json +15 -0
  150. package/locales/ja-JP/error.json +1 -52
  151. package/locales/ja-JP/modelProvider.json +226 -0
  152. package/locales/ja-JP/setting.json +59 -210
  153. package/locales/ko-KR/common.json +0 -26
  154. package/locales/ko-KR/components.json +15 -0
  155. package/locales/ko-KR/error.json +1 -52
  156. package/locales/ko-KR/modelProvider.json +226 -0
  157. package/locales/ko-KR/setting.json +48 -199
  158. package/locales/nl-NL/common.json +0 -26
  159. package/locales/nl-NL/components.json +15 -0
  160. package/locales/nl-NL/error.json +4 -55
  161. package/locales/nl-NL/modelProvider.json +226 -0
  162. package/locales/nl-NL/setting.json +49 -200
  163. package/locales/pl-PL/common.json +0 -26
  164. package/locales/pl-PL/components.json +15 -0
  165. package/locales/pl-PL/error.json +1 -52
  166. package/locales/pl-PL/modelProvider.json +226 -0
  167. package/locales/pl-PL/setting.json +48 -199
  168. package/locales/pt-BR/common.json +0 -26
  169. package/locales/pt-BR/components.json +15 -0
  170. package/locales/pt-BR/error.json +1 -52
  171. package/locales/pt-BR/modelProvider.json +226 -0
  172. package/locales/pt-BR/setting.json +48 -199
  173. package/locales/ru-RU/common.json +0 -26
  174. package/locales/ru-RU/components.json +15 -0
  175. package/locales/ru-RU/error.json +1 -52
  176. package/locales/ru-RU/modelProvider.json +226 -0
  177. package/locales/ru-RU/setting.json +48 -199
  178. package/locales/tr-TR/common.json +0 -26
  179. package/locales/tr-TR/components.json +15 -0
  180. package/locales/tr-TR/error.json +1 -52
  181. package/locales/tr-TR/modelProvider.json +226 -0
  182. package/locales/tr-TR/setting.json +48 -199
  183. package/locales/vi-VN/common.json +0 -26
  184. package/locales/vi-VN/components.json +15 -0
  185. package/locales/vi-VN/error.json +1 -52
  186. package/locales/vi-VN/modelProvider.json +226 -0
  187. package/locales/vi-VN/setting.json +48 -199
  188. package/locales/zh-CN/common.json +0 -26
  189. package/locales/zh-CN/components.json +15 -0
  190. package/locales/zh-CN/error.json +2 -53
  191. package/locales/zh-CN/modelProvider.json +226 -0
  192. package/locales/zh-CN/setting.json +48 -199
  193. package/locales/zh-TW/common.json +0 -26
  194. package/locales/zh-TW/components.json +15 -0
  195. package/locales/zh-TW/error.json +1 -52
  196. package/locales/zh-TW/modelProvider.json +226 -0
  197. package/locales/zh-TW/setting.json +48 -199
  198. package/package.json +120 -116
  199. package/scripts/mdxWorkflow/index.ts +48 -0
  200. package/src/app/api/chat/[provider]/route.test.ts +4 -9
  201. package/src/app/api/chat/[provider]/route.ts +6 -23
  202. package/src/app/api/chat/{[provider]/agentRuntime.test.ts → agentRuntime.test.ts} +12 -12
  203. package/src/app/api/chat/{[provider]/agentRuntime.ts → agentRuntime.ts} +11 -30
  204. package/src/app/api/chat/auth/index.ts +42 -0
  205. package/src/app/api/chat/models/[provider]/route.ts +45 -0
  206. package/src/app/api/config/__snapshots__/route.test.ts.snap +127 -0
  207. package/src/app/api/config/route.test.ts +170 -0
  208. package/src/app/api/config/route.ts +46 -11
  209. package/src/app/api/plugin/gateway/route.ts +1 -1
  210. package/src/app/settings/llm/Azure/index.tsx +36 -43
  211. package/src/app/settings/llm/Bedrock/index.tsx +12 -20
  212. package/src/app/settings/llm/Ollama/index.tsx +2 -2
  213. package/src/app/settings/llm/OpenAI/index.tsx +9 -121
  214. package/src/app/settings/llm/OpenRouter/index.tsx +1 -1
  215. package/src/app/settings/llm/TogetherAI/index.tsx +0 -1
  216. package/src/app/settings/llm/components/ProviderConfig/index.tsx +48 -32
  217. package/src/app/settings/llm/components/ProviderModelList/CustomModelOption.tsx +94 -0
  218. package/src/app/settings/llm/components/ProviderModelList/MaxTokenSlider.tsx +88 -0
  219. package/src/app/settings/llm/components/ProviderModelList/ModelConfigModal.tsx +128 -0
  220. package/src/app/settings/llm/components/ProviderModelList/ModelFetcher.tsx +81 -0
  221. package/src/app/settings/llm/components/ProviderModelList/Option.tsx +38 -0
  222. package/src/app/settings/llm/components/ProviderModelList/index.tsx +142 -0
  223. package/src/app/settings/llm/const.ts +1 -1
  224. package/src/app/settings/llm/index.tsx +7 -6
  225. package/src/app/settings/tts/TTS/index.tsx +1 -1
  226. package/src/components/AntdStaticMethods/index.test.tsx +43 -0
  227. package/src/components/ModelIcon/index.tsx +25 -7
  228. package/src/components/ModelSelect/index.tsx +67 -56
  229. package/src/config/modelProviders/anthropic.ts +6 -1
  230. package/src/config/modelProviders/azure.ts +42 -0
  231. package/src/config/modelProviders/bedrock.ts +4 -1
  232. package/src/config/modelProviders/google.ts +2 -14
  233. package/src/config/modelProviders/groq.ts +3 -0
  234. package/src/config/modelProviders/index.ts +19 -14
  235. package/src/config/modelProviders/mistral.ts +5 -0
  236. package/src/config/modelProviders/moonshot.ts +3 -1
  237. package/src/config/modelProviders/ollama.ts +6 -17
  238. package/src/config/modelProviders/openai.ts +9 -13
  239. package/src/config/modelProviders/openrouter.ts +6 -1
  240. package/src/config/modelProviders/perplexity.ts +2 -0
  241. package/src/config/modelProviders/togetherai.ts +11 -0
  242. package/src/config/modelProviders/zeroone.ts +3 -0
  243. package/src/config/modelProviders/zhipu.ts +3 -0
  244. package/src/config/server/provider.ts +52 -7
  245. package/src/const/auth.ts +0 -1
  246. package/src/const/{settings.ts → settings/index.ts} +31 -4
  247. package/src/const/url.ts +1 -1
  248. package/src/database/core/db.ts +14 -0
  249. package/src/database/schemas/user.ts +1 -25
  250. package/src/features/AgentSetting/AgentConfig/ModelSelect.tsx +7 -11
  251. package/src/features/ChatInput/STT/common.tsx +80 -78
  252. package/src/features/ChatInput/STT/index.tsx +8 -6
  253. package/src/features/Conversation/Error/APIKeyForm/Bedrock.tsx +8 -8
  254. package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +73 -0
  255. package/src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx +74 -0
  256. package/src/features/Conversation/Error/APIKeyForm/index.tsx +25 -49
  257. package/src/features/ModelSwitchPanel/index.tsx +40 -13
  258. package/src/hooks/_header.ts +5 -20
  259. package/src/libs/agent-runtime/BaseAI.ts +17 -1
  260. package/src/libs/agent-runtime/anthropic/index.ts +3 -7
  261. package/src/libs/agent-runtime/azureOpenai/index.test.ts +166 -0
  262. package/src/libs/agent-runtime/azureOpenai/index.ts +16 -8
  263. package/src/libs/agent-runtime/bedrock/index.test.ts +199 -22
  264. package/src/libs/agent-runtime/bedrock/index.ts +11 -18
  265. package/src/libs/agent-runtime/groq/index.test.ts +350 -0
  266. package/src/libs/agent-runtime/groq/index.ts +14 -77
  267. package/src/libs/agent-runtime/mistral/index.test.ts +25 -19
  268. package/src/libs/agent-runtime/mistral/index.ts +24 -86
  269. package/src/libs/agent-runtime/moonshot/index.test.ts +2 -2
  270. package/src/libs/agent-runtime/moonshot/index.ts +14 -77
  271. package/src/libs/agent-runtime/openai/__snapshots__/index.test.ts.snap +99 -0
  272. package/src/libs/agent-runtime/openai/fixtures/openai-models.json +170 -0
  273. package/src/libs/agent-runtime/openai/index.test.ts +15 -50
  274. package/src/libs/agent-runtime/openai/index.ts +15 -107
  275. package/src/libs/agent-runtime/openrouter/__snapshots__/index.test.ts.snap +82 -0
  276. package/src/libs/agent-runtime/openrouter/fixtures/models.json +62 -0
  277. package/src/libs/agent-runtime/openrouter/index.test.ts +25 -9
  278. package/src/libs/agent-runtime/openrouter/index.ts +42 -84
  279. package/src/libs/agent-runtime/openrouter/type.ts +28 -0
  280. package/src/libs/agent-runtime/togetherai/index.test.ts +12 -9
  281. package/src/libs/agent-runtime/togetherai/index.ts +20 -85
  282. package/src/libs/agent-runtime/utils/anthropicHelpers.test.ts +14 -22
  283. package/src/libs/agent-runtime/utils/anthropicHelpers.ts +4 -10
  284. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +147 -0
  285. package/src/libs/agent-runtime/zeroone/index.test.ts +350 -0
  286. package/src/libs/agent-runtime/zeroone/index.ts +14 -77
  287. package/src/locales/default/common.ts +0 -28
  288. package/src/locales/default/components.ts +15 -0
  289. package/src/locales/default/error.ts +2 -54
  290. package/src/locales/default/index.ts +4 -0
  291. package/src/locales/default/modelProvider.ts +229 -0
  292. package/src/locales/default/setting.ts +51 -202
  293. package/src/migrations/FromV3ToV4/fixtures/azure-input-v3.json +79 -0
  294. package/src/migrations/FromV3ToV4/fixtures/azure-output-v4.json +75 -0
  295. package/src/migrations/FromV3ToV4/fixtures/ollama-input-v3.json +85 -0
  296. package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +86 -0
  297. package/src/migrations/FromV3ToV4/fixtures/openai-input-v3.json +77 -0
  298. package/src/migrations/FromV3ToV4/fixtures/openai-output-v4.json +79 -0
  299. package/src/migrations/FromV3ToV4/fixtures/openrouter-input-v3.json +82 -0
  300. package/src/migrations/FromV3ToV4/fixtures/openrouter-output-v4.json +89 -0
  301. package/src/migrations/FromV3ToV4/fixtures/output-v4-from-v1.json +203 -0
  302. package/src/migrations/FromV3ToV4/index.ts +96 -0
  303. package/src/migrations/FromV3ToV4/migrations.test.ts +195 -0
  304. package/src/migrations/FromV3ToV4/types/v3.ts +59 -0
  305. package/src/migrations/FromV3ToV4/types/v4.ts +37 -0
  306. package/src/migrations/index.ts +11 -3
  307. package/src/services/_auth.test.ts +4 -6
  308. package/src/services/_auth.ts +8 -60
  309. package/src/services/_header.ts +5 -22
  310. package/src/services/_url.ts +1 -0
  311. package/src/services/chat.ts +16 -6
  312. package/src/services/global.ts +1 -1
  313. package/src/services/models.ts +23 -0
  314. package/src/services/ollama.ts +2 -2
  315. package/src/store/chat/slices/share/action.test.ts +113 -0
  316. package/src/store/chat/slices/share/action.ts +1 -1
  317. package/src/store/global/slices/common/action.test.ts +166 -1
  318. package/src/store/global/slices/common/action.ts +2 -1
  319. package/src/store/global/slices/settings/{action.test.ts → actions/general.test.ts} +1 -19
  320. package/src/store/global/slices/settings/{action.ts → actions/general.ts} +4 -19
  321. package/src/store/global/slices/settings/actions/index.ts +18 -0
  322. package/src/store/global/slices/settings/actions/llm.test.ts +60 -0
  323. package/src/store/global/slices/settings/actions/llm.ts +88 -0
  324. package/src/store/global/slices/settings/initialState.ts +3 -1
  325. package/src/store/global/slices/settings/reducers/customModelCard.test.ts +204 -0
  326. package/src/store/global/slices/settings/reducers/customModelCard.ts +64 -0
  327. package/src/store/global/slices/settings/selectors/index.ts +1 -0
  328. package/src/store/global/slices/settings/selectors/modelConfig.test.ts +189 -0
  329. package/src/store/global/slices/settings/selectors/modelConfig.ts +179 -0
  330. package/src/store/global/slices/settings/selectors/modelProvider.test.ts +47 -138
  331. package/src/store/global/slices/settings/selectors/modelProvider.ts +102 -243
  332. package/src/store/global/store.ts +1 -1
  333. package/src/types/llm.ts +12 -1
  334. package/src/types/serverConfig.ts +22 -0
  335. package/src/types/settings/index.ts +0 -12
  336. package/src/types/settings/modelProvider.ts +34 -90
  337. package/src/utils/client/switchLang.test.ts +34 -0
  338. package/src/utils/difference.test.ts +46 -0
  339. package/src/utils/difference.ts +15 -2
  340. package/src/utils/fetch.ts +1 -3
  341. package/src/utils/parseModels.ts +62 -0
  342. package/vercel.json +1 -1
  343. package/docs/package.json +0 -5
  344. package/src/features/Conversation/Error/APIKeyForm/Anthropic.tsx +0 -40
  345. package/src/features/Conversation/Error/APIKeyForm/Google.tsx +0 -61
  346. package/src/features/Conversation/Error/APIKeyForm/Groq.tsx +0 -60
  347. package/src/features/Conversation/Error/APIKeyForm/Mistral.tsx +0 -60
  348. package/src/features/Conversation/Error/APIKeyForm/Moonshot.tsx +0 -60
  349. package/src/features/Conversation/Error/APIKeyForm/OpenAI.tsx +0 -63
  350. package/src/features/Conversation/Error/APIKeyForm/OpenRouter.tsx +0 -40
  351. package/src/features/Conversation/Error/APIKeyForm/Perplexity.tsx +0 -60
  352. package/src/features/Conversation/Error/APIKeyForm/TogetherAI.tsx +0 -40
  353. package/src/features/Conversation/Error/APIKeyForm/ZeroOne.tsx +0 -60
  354. package/src/features/Conversation/Error/APIKeyForm/Zhipu.tsx +0 -62
  355. package/src/libs/agent-runtime/utils/env.ts +0 -1
  356. package/src/store/global/slices/settings/selectors/__snapshots__/modelProvider.test.ts.snap +0 -230
  357. /package/src/app/api/chat/{auth.ts → auth/utils.ts} +0 -0
  358. /package/src/components/{AntdStaticMethods.tsx → AntdStaticMethods/index.tsx} +0 -0
@@ -31,215 +31,63 @@
31
31
  "sessionWithName": "對話設定 · {{name}}"
32
32
  },
33
33
  "llm": {
34
- "anthropic": {
35
- "endpoint": {
36
- "desc": "除了預設地址外,必須包含 http(s)://",
37
- "placeholder": "https://api.anthropic.com",
38
- "title": "API 代理地址"
39
- },
40
- "title": "Anthropic",
41
- "token": {
42
- "desc": "填入來自 Anthropics 的 API Key",
43
- "placeholder": "Anthropic API Key",
44
- "title": "API Key"
45
- }
46
- },
47
- "azure": {
48
- "azureApiVersion": {
49
- "desc": "Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查閱[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
50
- "fetch": "獲取列表",
51
- "title": "Azure API 版本"
52
- },
53
- "deployments": {
54
- "desc": "使用 id=name 的語法填寫你的部署模型(如部署名和模型同名,可以只填寫模型名稱),多個模型使用逗號(,) 隔開",
55
- "title": "Azure 部署模型列表"
56
- },
57
- "endpoint": {
58
- "desc": "從 Azure 門戶檢查資源時,可在「密鑰和終端點」部分中找到此值",
59
- "placeholder": "https://docs-test-001.openai.azure.com",
60
- "title": "Azure API 地址"
61
- },
62
- "models": {
63
- "desc": "支援的模型",
64
- "title": "模型列表"
65
- },
66
- "title": "Azure OpenAI",
67
- "token": {
68
- "desc": "從 Azure 門戶檢查資源時,可在「密鑰和終端點」部分中找到此值。 可以使用 KEY1 或 KEY2",
69
- "placeholder": "Azure API Key",
70
- "title": "API Key"
71
- }
72
- },
73
- "bedrock": {
74
- "accessKeyId": {
75
- "desc": "填入 AWS Access Key ID",
76
- "placeholder": "AWS Access Key ID",
77
- "title": "AWS Access Key ID"
78
- },
79
- "checker": {
80
- "desc": "測試 AccessKeyId / SecretAccessKey 是否填寫正確"
81
- },
82
- "region": {
83
- "desc": "填入 AWS Region",
84
- "placeholder": "AWS Region",
85
- "title": "AWS Region"
86
- },
87
- "secretAccessKey": {
88
- "desc": "填入 AWS Secret Access Key",
89
- "placeholder": "AWS Secret Access Key",
90
- "title": "AWS Secret Access Key"
91
- },
92
- "title": "Bedrock"
93
- },
94
34
  "checker": {
95
35
  "button": "檢查",
96
36
  "desc": "測試 API 金鑰與代理地址是否正確填寫",
37
+ "ollamaDesc": "測試代理地址是否正確填寫",
97
38
  "pass": "檢查通過",
98
39
  "title": "連通性檢查"
99
40
  },
100
- "google": {
101
- "title": "Google",
102
- "token": {
103
- "desc": "填入來自 Google 的 API Key",
104
- "placeholder": "Google API Key",
105
- "title": "API Key"
106
- }
107
- },
108
- "groq": {
109
- "title": "Groq",
110
- "token": {
111
- "desc": "填入來自 Groq 的 API Key",
112
- "placeholder": "Groq API Key",
113
- "title": "API Key"
114
- }
115
- },
116
- "mistral": {
117
- "title": "Mistral AI",
118
- "token": {
119
- "desc": "填入來自 Mistral AI 的 API Key",
120
- "placeholder": "Mistral AI API Key",
121
- "title": "API Key"
122
- }
123
- },
124
- "moonshot": {
125
- "title": "月之暗面",
126
- "token": {
127
- "desc": "填入來自 Moonshot AI 的 API Key",
128
- "placeholder": "Moonshot AI API Key",
129
- "title": "API Key"
130
- }
131
- },
132
- "ollama": {
133
- "checker": {
134
- "desc": "檢查代理地址是否正確填寫"
135
- },
136
- "customModelName": {
137
- "desc": "新增自定義模型,多個模型使用逗號(,)隔開",
138
- "placeholder": "vicuna,llava,codellama,llama2:13b-text",
139
- "title": "自定義模型名稱"
140
- },
141
- "endpoint": {
142
- "desc": "填入 Ollama 接口代理地址,本地未額外指定可留空",
143
- "placeholder": "http://127.0.0.1:11434/v1",
144
- "title": "接口代理地址"
145
- },
146
- "title": "Ollama"
147
- },
148
- "openai": {
149
- "azureApiVersion": {
150
- "desc": "Azure 的 API 版本,遵循 YYYY-MM-DD 格式,查閱[最新版本](https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference#chat-completions)",
151
- "fetch": "獲取列表",
152
- "title": "Azure Api 版本"
153
- },
154
- "customModelName": {
155
- "desc": "增加自訂模型,多個模型使用逗號(,) 隔開",
156
- "placeholder": "model1,model2,model3",
157
- "title": "自訂模型名稱"
158
- },
159
- "endpoint": {
160
- "desc": "除預設地址外,必須包含 http(s)://",
161
- "placeholder": "https://api.openai.com/v1",
162
- "title": "接口代理地址"
163
- },
164
- "models": {
165
- "count": "共支援 {{count}} 個模型",
166
- "desc": "支援的模型",
167
- "fetch": "獲取模型列表",
168
- "notSupport": "Azure OpenAI 暫不支援查看模型列表",
169
- "notSupportTip": "你需要自行確保部署名稱與模型名稱一致",
170
- "refetch": "重新獲取模型列表",
171
- "title": "模型列表"
172
- },
173
- "title": "OpenAI",
174
- "token": {
175
- "desc": "使用自己的 OpenAI Key",
176
- "placeholder": "OpenAI API Key",
177
- "title": "OpenAI API Key"
178
- },
179
- "useAzure": {
180
- "desc": "使用 Azure 提供的 OpenAI 服務",
181
- "fetch": "獲取列表",
182
- "serverConfig": "管理員在服務端配置開啟了 Azure OpenAI,禁止切換",
183
- "title": "Azure OpenAI"
41
+ "customModelCards": {
42
+ "addNew": "創建並添加 {{id}} 模型",
43
+ "config": "配置模型",
44
+ "confirmDelete": "即將刪除該自定義模型,刪除後將不可恢復,請謹慎操作。",
45
+ "modelConfig": {
46
+ "azureDeployName": {
47
+ "extra": "在 Azure OpenAI 中實際請求的字段",
48
+ "placeholder": "請輸入 Azure 中的模型部署名稱",
49
+ "title": "模型部署名稱"
50
+ },
51
+ "displayName": {
52
+ "placeholder": "請輸入模型的展示名稱,例如 ChatGPT、GPT-4 ",
53
+ "title": "模型展示名稱"
54
+ },
55
+ "files": {
56
+ "extra": "當前 LobeChat 的文件上傳實現僅為一種 Hack 方案,僅限自行嘗試。完整文件上傳能力請等待後續實現",
57
+ "title": "支援文件上傳"
58
+ },
59
+ "functionCall": {
60
+ "extra": "此配置將僅開啟 LobeChat 中的函數調用能力,是否支持函數調用完全取決於模型本身,請自行測試該模型的函數調用能力可用性",
61
+ "title": "支援函數調用"
62
+ },
63
+ "id": {
64
+ "extra": "將作為模型標籤進行展示",
65
+ "placeholder": "請輸入模型id,例如 gpt-4-turbo-preview 或 claude-2.1",
66
+ "title": "模型 ID"
67
+ },
68
+ "modalTitle": "自定義模型配置",
69
+ "tokens": {
70
+ "title": "最大 token 數"
71
+ },
72
+ "vision": {
73
+ "extra": "此配置將僅開啟 LobeChat 中的圖片上傳配置,是否支持識別完全取決於模型本身,請自行測試該模型的視覺識別能力可用性",
74
+ "title": "支援視覺識別"
75
+ }
184
76
  }
185
77
  },
186
- "openrouter": {
187
- "checker": {
188
- "desc": "測試代理地址是否正確填寫"
189
- },
190
- "customModelName": {
191
- "desc": "增加自定義模型,多個模型使用逗號(,)隔開",
192
- "placeholder": "mistralai/mistral-7b-instruct:free,openchat/openchat-7b:free",
193
- "title": "自定義模型名稱"
194
- },
195
- "title": "OpenRouter",
196
- "token": {
197
- "desc": "填入來自 OpenRouter AI 的 API Key",
198
- "placeholder": "OpenRouter AI API Key",
199
- "title": "API Key"
200
- }
201
- },
202
- "perplexity": {
203
- "title": "Perplexity",
204
- "token": {
205
- "desc": "填入來自 Perplexity AI 的 API Key",
206
- "placeholder": "Perplexity AI API Key",
207
- "title": "API Key"
208
- }
78
+ "fetcher": {
79
+ "fetch": "獲取模型列表",
80
+ "fetching": "正在獲取模型列表...",
81
+ "latestTime": "上次更新時間:{{time}}",
82
+ "noLatestTime": "暫未獲取列表"
209
83
  },
210
- "togetherai": {
211
- "checker": {
212
- "desc": "測試代理地址是否正確填寫"
213
- },
214
- "customModelName": {
215
- "desc": "增加自定義模型,多個模型使用逗號(,)隔開",
216
- "placeholder": "mistralai/mistral-7b-instruct:free,openchat/openchat-7b:free",
217
- "title": "自定義模型名稱"
218
- },
219
- "title": "TogetherAI",
220
- "token": {
221
- "desc": "填入來自 TogetherAI AI 的 API Key",
222
- "placeholder": "TogetherAI AI API Key",
223
- "title": "API Key"
224
- }
84
+ "modelList": {
85
+ "desc": "選擇在會話中展示的模型,選擇的模型會在模型列表中展示",
86
+ "placeholder": "請從列表中選擇模型",
87
+ "title": "模型列表",
88
+ "total": "共 {{count}} 個模型可用"
225
89
  },
226
- "waitingForMore": "更多模型正在 <1>計劃接入</1> 中,敬請期待 ✨",
227
- "zeroone": {
228
- "title": "01.AI 零一萬物",
229
- "token": {
230
- "desc": "填入來自 01.AI 零一萬物的 API Key",
231
- "placeholder": "01.AI 零一萬物 API Key",
232
- "title": "API Key"
233
- }
234
- },
235
- "zhipu": {
236
- "title": "智譜",
237
- "token": {
238
- "desc": "填入來自智譜的 API Key",
239
- "placeholder": "Zhipu API Key",
240
- "title": "API Key"
241
- }
242
- }
90
+ "waitingForMore": "更多模型正在 <1>計劃接入</1> 中,敬請期待 ✨"
243
91
  },
244
92
  "ollama": {
245
93
  "download": {
@@ -395,6 +243,7 @@
395
243
  "settingTTS": {
396
244
  "openai": {
397
245
  "sttModel": "OpenAI 語音識別模型",
246
+ "title": "OpenAI",
398
247
  "ttsModel": "OpenAI 語音合成模型"
399
248
  },
400
249
  "showAllLocaleVoice": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.146.2",
3
+ "version": "0.147.0",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -32,13 +32,13 @@
32
32
  "build:analyze": "ANALYZE=true next build",
33
33
  "build:docker": "DOCKER=true next build && npm run build-sitemap",
34
34
  "dev": "next dev -p 3010",
35
- "docs": "lobe-i18n md && npm run workflow:docs",
35
+ "docs:i18n": "lobe-i18n md && npm run workflow:docs && npm run lint:mdx",
36
+ "docs:seo": "lobe-seo && npm run workflow:mdx && npm run lint:mdx",
36
37
  "i18n": "npm run workflow:i18n && lobe-i18n",
37
- "i18n:docs": "lobe-i18n md && npm run workflow:docs",
38
38
  "lint": "npm run lint:ts && npm run lint:style && npm run type-check && npm run lint:circular",
39
39
  "lint:circular": "dpdm src/**/*.ts --warning false --tree false --exit-code circular:1 -T true --skip-dynamic-imports circular",
40
40
  "lint:md": "remark . --quiet --frail --output",
41
- "lint:mdx": "eslint \"{contributing,docs}/**/*.mdx\" --fix",
41
+ "lint:mdx": "eslint \"{contributing,docs}/**/*.mdx\" --quiet --fix",
42
42
  "lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
43
43
  "lint:ts": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
44
44
  "prepare": "husky",
@@ -53,6 +53,7 @@
53
53
  "type-check": "tsc --noEmit",
54
54
  "workflow:docs": "tsx scripts/docsWorkflow/index.ts",
55
55
  "workflow:i18n": "tsx scripts/i18nWorkflow/index.ts",
56
+ "workflow:mdx": "tsx scripts/mdxWorkflow/index.ts",
56
57
  "workflow:readme": "tsx scripts/readmeWorkflow/index.ts"
57
58
  },
58
59
  "lint-staged": {
@@ -61,7 +62,8 @@
61
62
  "prettier --write --no-error-on-unmatched-pattern"
62
63
  ],
63
64
  "*.mdx": [
64
- "eslint --fix --quiet"
65
+ "npm run workflow:mdx",
66
+ "eslint --quiet --fix"
65
67
  ],
66
68
  "*.json": [
67
69
  "prettier --write --no-error-on-unmatched-pattern"
@@ -78,143 +80,145 @@
78
80
  ]
79
81
  },
80
82
  "dependencies": {
81
- "@ant-design/icons": "^5",
83
+ "@ant-design/icons": "^5.3.6",
82
84
  "@anthropic-ai/sdk": "^0.18.0",
83
85
  "@auth/core": "0.28.0",
84
- "@aws-sdk/client-bedrock-runtime": "^3.525.0",
85
- "@azure/openai": "^1.0.0-beta.11",
86
- "@cfworker/json-schema": "^1",
86
+ "@aws-sdk/client-bedrock-runtime": "^3.549.0",
87
+ "@azure/openai": "^1.0.0-beta.12",
88
+ "@cfworker/json-schema": "^1.12.8",
87
89
  "@google/generative-ai": "^0.3.1",
88
- "@icons-pack/react-simple-icons": "^9",
90
+ "@icons-pack/react-simple-icons": "^9.4.0",
89
91
  "@lobehub/chat-plugin-sdk": "latest",
90
92
  "@lobehub/chat-plugins-gateway": "latest",
91
93
  "@lobehub/icons": "latest",
92
94
  "@lobehub/tts": "latest",
93
- "@lobehub/ui": "^1.137.4",
95
+ "@lobehub/ui": "^1.137.7",
94
96
  "@next/third-parties": "^14.1.4",
95
- "@vercel/analytics": "^1",
97
+ "@vercel/analytics": "^1.2.2",
96
98
  "@vercel/speed-insights": "^1.0.10",
97
- "ahooks": "^3",
99
+ "ahooks": "^3.7.11",
98
100
  "ai": "3.0.19",
99
- "antd": "^5",
100
- "antd-style": "^3",
101
- "brotli-wasm": "^2",
102
- "chroma-js": "^2",
103
- "dayjs": "^1",
104
- "debug": "^4",
105
- "dexie": "^3",
106
- "diff": "^5",
107
- "fast-deep-equal": "^3",
108
- "gpt-tokenizer": "^2",
109
- "i18next": "^23",
110
- "i18next-browser-languagedetector": "^7",
111
- "i18next-resources-to-backend": "^1",
112
- "idb-keyval": "^6",
113
- "immer": "^10",
114
- "jose": "^5",
115
- "langfuse": "^3",
116
- "langfuse-core": "^3",
117
- "lodash-es": "^4",
101
+ "antd": "^5.16.1",
102
+ "antd-style": "^3.6.2",
103
+ "brotli-wasm": "^2.0.1",
104
+ "chroma-js": "^2.4.2",
105
+ "dayjs": "^1.11.10",
106
+ "debug": "^4.3.4",
107
+ "dexie": "^3.2.7",
108
+ "diff": "^5.2.0",
109
+ "fast-deep-equal": "^3.1.3",
110
+ "gpt-tokenizer": "^2.1.2",
111
+ "i18next": "^23.11.0",
112
+ "i18next-browser-languagedetector": "^7.2.1",
113
+ "i18next-resources-to-backend": "^1.2.0",
114
+ "idb-keyval": "^6.2.1",
115
+ "immer": "^10.0.4",
116
+ "jose": "^5.2.4",
117
+ "langfuse": "^3.4.0",
118
+ "langfuse-core": "^3.4.0",
119
+ "lodash-es": "^4.17.21",
118
120
  "lucide-react": "latest",
119
- "modern-screenshot": "^4",
120
- "nanoid": "^5",
121
- "next": "^14.1",
121
+ "modern-screenshot": "^4.4.38",
122
+ "nanoid": "^5.0.7",
123
+ "next": "^14.1.4",
122
124
  "next-auth": "5.0.0-beta.15",
123
- "next-sitemap": "^4",
124
- "numeral": "^2",
125
- "nuqs": "^1",
125
+ "next-sitemap": "^4.2.3",
126
+ "numeral": "^2.0.6",
127
+ "nuqs": "^1.17.1",
126
128
  "ollama": "^0.5.0",
127
- "openai": "^4.22",
128
- "polished": "^4",
129
- "posthog-js": "^1",
130
- "query-string": "^9",
129
+ "openai": "^4.33.0",
130
+ "polished": "^4.3.1",
131
+ "posthog-js": "^1.120.2",
132
+ "query-string": "^9.0.0",
131
133
  "random-words": "^2.0.1",
132
- "react": "^18",
133
- "react-dom": "^18",
134
- "react-hotkeys-hook": "^4",
135
- "react-i18next": "^14",
134
+ "react": "^18.2.0",
135
+ "react-dom": "^18.2.0",
136
+ "react-hotkeys-hook": "^4.5.0",
137
+ "react-i18next": "^14.1.0",
136
138
  "react-layout-kit": "^1.9.0",
137
- "react-lazy-load": "^4",
138
- "react-virtuoso": "^4",
139
- "react-wrap-balancer": "^1",
140
- "remark": "^14",
141
- "remark-gfm": "^3",
142
- "remark-html": "^15",
143
- "rtl-detect": "^1",
144
- "semver": "^7",
145
- "sharp": "^0.33",
146
- "swr": "^2",
147
- "systemjs": "^6",
148
- "ts-md5": "^1",
149
- "ua-parser-js": "^1",
150
- "url-join": "^5",
151
- "use-merge-value": "^1",
152
- "utility-types": "^3",
153
- "uuid": "^9",
139
+ "react-lazy-load": "^4.0.1",
140
+ "react-virtuoso": "^4.7.8",
141
+ "react-wrap-balancer": "^1.1.0",
142
+ "remark": "^14.0.3",
143
+ "remark-gfm": "^3.0.1",
144
+ "remark-html": "^15.0.2",
145
+ "rtl-detect": "^1.1.2",
146
+ "semver": "^7.6.0",
147
+ "sharp": "^0.33.3",
148
+ "swr": "^2.2.5",
149
+ "systemjs": "^6.14.3",
150
+ "ts-md5": "^1.3.1",
151
+ "ua-parser-js": "^1.0.37",
152
+ "url-join": "^5.0.0",
153
+ "use-merge-value": "^1.2.0",
154
+ "utility-types": "^3.11.0",
155
+ "uuid": "^9.0.1",
154
156
  "y-protocols": "^1.0.6",
155
157
  "y-webrtc": "^10.3.0",
156
- "yaml": "^2",
158
+ "yaml": "^2.4.1",
157
159
  "yjs": "^13.6.14",
158
- "zod": "^3",
160
+ "zod": "^3.22.4",
159
161
  "zustand": "^4.5.2",
160
162
  "zustand-utils": "^1.3.2"
161
163
  },
162
164
  "devDependencies": {
163
- "@commitlint/cli": "^19",
164
- "@ducanh2912/next-pwa": "^10",
165
- "@edge-runtime/vm": "^3",
166
- "@lobehub/i18n-cli": "latest",
167
- "@lobehub/lint": "latest",
168
- "@next/bundle-analyzer": "^14",
169
- "@next/eslint-plugin-next": "^14",
170
- "@peculiar/webcrypto": "^1",
171
- "@testing-library/jest-dom": "^6",
172
- "@testing-library/react": "^14",
173
- "@types/chroma-js": "^2",
165
+ "@commitlint/cli": "^19.2.1",
166
+ "@ducanh2912/next-pwa": "^10.2.6",
167
+ "@edge-runtime/vm": "^3.2.0",
168
+ "@lobehub/i18n-cli": "^1.18.1",
169
+ "@lobehub/lint": "^1.23.3",
170
+ "@lobehub/seo-cli": "^1.4.1",
171
+ "@next/bundle-analyzer": "^14.1.4",
172
+ "@next/eslint-plugin-next": "^14.1.4",
173
+ "@peculiar/webcrypto": "^1.4.6",
174
+ "@testing-library/jest-dom": "^6.4.2",
175
+ "@testing-library/react": "^14.3.0",
176
+ "@types/chroma-js": "^2.4.4",
174
177
  "@types/debug": "^4.1.12",
175
- "@types/diff": "^5",
176
- "@types/json-schema": "^7",
177
- "@types/lodash": "^4",
178
- "@types/lodash-es": "^4",
179
- "@types/node": "^20",
180
- "@types/numeral": "^2",
181
- "@types/react": "^18.2.67",
182
- "@types/react-dom": "^18",
183
- "@types/rtl-detect": "^1",
184
- "@types/semver": "^7",
185
- "@types/systemjs": "^6",
186
- "@types/ua-parser-js": "^0.7",
187
- "@types/uuid": "^9",
188
- "@umijs/lint": "^4",
178
+ "@types/diff": "^5.0.9",
179
+ "@types/json-schema": "^7.0.15",
180
+ "@types/lodash": "^4.17.0",
181
+ "@types/lodash-es": "^4.17.12",
182
+ "@types/node": "^20.12.6",
183
+ "@types/numeral": "^2.0.5",
184
+ "@types/react": "^18.2.75",
185
+ "@types/react-dom": "^18.2.24",
186
+ "@types/rtl-detect": "^1.0.3",
187
+ "@types/semver": "^7.5.8",
188
+ "@types/systemjs": "^6.13.5",
189
+ "@types/ua-parser-js": "^0.7.39",
190
+ "@types/uuid": "^9.0.8",
191
+ "@umijs/lint": "^4.1.8",
189
192
  "@vitest/coverage-v8": "~1.2.2",
190
- "ajv-keywords": "^5",
191
- "commitlint": "^19",
192
- "consola": "^3",
193
- "dpdm": "^3",
194
- "eslint": "^8",
195
- "eslint-plugin-mdx": "^2",
196
- "fake-indexeddb": "^5",
197
- "glob": "^10",
198
- "husky": "^9",
193
+ "ajv-keywords": "^5.1.0",
194
+ "commitlint": "^19.2.1",
195
+ "consola": "^3.2.3",
196
+ "dpdm": "^3.14.0",
197
+ "eslint": "^8.57.0",
198
+ "eslint-plugin-mdx": "^2.3.4",
199
+ "fake-indexeddb": "^5.0.2",
200
+ "glob": "^10.3.12",
201
+ "gray-matter": "^4.0.3",
202
+ "husky": "^9.0.11",
199
203
  "jsdom": "^24.0.0",
200
- "just-diff": "^6",
201
- "lint-staged": "^15",
202
- "lodash": "^4",
203
- "markdown-table": "^3",
204
- "node-fetch": "^3",
205
- "p-map": "^7",
206
- "prettier": "^3",
207
- "remark-cli": "^11",
208
- "remark-parse": "^10",
209
- "semantic-release": "^21",
210
- "stylelint": "^15",
211
- "tsx": "^4",
212
- "typescript": "^5",
213
- "unified": "^11",
214
- "unist-util-visit": "^5",
215
- "vite": "^5",
204
+ "just-diff": "^6.0.2",
205
+ "lint-staged": "^15.2.2",
206
+ "lodash": "^4.17.21",
207
+ "markdown-table": "^3.0.3",
208
+ "node-fetch": "^3.3.2",
209
+ "p-map": "^7.0.2",
210
+ "prettier": "^3.2.5",
211
+ "remark-cli": "^11.0.0",
212
+ "remark-parse": "^10.0.2",
213
+ "semantic-release": "^21.1.2",
214
+ "stylelint": "^15.11.0",
215
+ "tsx": "^4.7.2",
216
+ "typescript": "^5.4.4",
217
+ "unified": "^11.0.4",
218
+ "unist-util-visit": "^5.0.0",
219
+ "vite": "^5.2.8",
216
220
  "vitest": "~1.2.2",
217
- "vitest-canvas-mock": "^0.3"
221
+ "vitest-canvas-mock": "^0.3.3"
218
222
  },
219
223
  "publishConfig": {
220
224
  "access": "public",
@@ -0,0 +1,48 @@
1
+ import { consola } from 'consola';
2
+ import { globSync } from 'glob';
3
+ import matter from 'gray-matter';
4
+ import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
5
+ import { resolve } from 'node:path';
6
+
7
+ const fixWinPath = (path: string) => path.replaceAll('\\', '/');
8
+
9
+ export const root = resolve(__dirname, '../..');
10
+
11
+ const run = () => {
12
+ const posts = globSync(fixWinPath(resolve(root, 'docs/**/*.mdx')));
13
+
14
+ for (const post of posts) {
15
+ try {
16
+ const mdx = readFileSync(post, 'utf8');
17
+ if (!mdx || mdx.replaceAll(' ', '').replaceAll('\n', '') === '') {
18
+ consola.error(post, 'is EMPTY !!!!!');
19
+ unlinkSync(post);
20
+ continue;
21
+ }
22
+ const { data, content } = matter(mdx);
23
+ const formatedContent = content
24
+ .replaceAll('\\<', '<')
25
+ .replaceAll("{' '}\n", '')
26
+ .replaceAll(`'<`, `'`)
27
+ .replaceAll(`"<`, `"`)
28
+ .replaceAll(`>'`, `'`)
29
+ .replaceAll(`>"`, `"`)
30
+ .replaceAll(' </', '\n</')
31
+ .replaceAll(' </', '\n</')
32
+ .replaceAll('}> width', '} width')
33
+ .replaceAll("'[https", "'https")
34
+ .replaceAll('"[https', '"https')
35
+ .replaceAll(/]\(http(.*)\/>\)/g, '')
36
+ .replaceAll(`\\*\\* `, '** ')
37
+ .replaceAll(` \\*\\*`, ' **')
38
+ .replaceAll(/\n{2,}/g, '\n\n');
39
+
40
+ writeFileSync(post, matter.stringify(formatedContent, data));
41
+ } catch (error) {
42
+ consola.error(post);
43
+ consola.error(error);
44
+ }
45
+ }
46
+ };
47
+
48
+ run();
@@ -5,11 +5,11 @@ import { LOBE_CHAT_AUTH_HEADER, OAUTH_AUTHORIZED } from '@/const/auth';
5
5
  import { LobeRuntimeAI } from '@/libs/agent-runtime';
6
6
  import { ChatErrorType } from '@/types/fetch';
7
7
 
8
- import { getJWTPayload } from '../auth';
9
- import AgentRuntime from './agentRuntime';
8
+ import AgentRuntime from '../agentRuntime';
9
+ import { getJWTPayload } from '../auth/utils';
10
10
  import { POST } from './route';
11
11
 
12
- vi.mock('../auth', () => ({
12
+ vi.mock('../auth/utils', () => ({
13
13
  getJWTPayload: vi.fn(),
14
14
  checkAuthMethod: vi.fn(),
15
15
  }));
@@ -42,7 +42,6 @@ describe('POST handler', () => {
42
42
  accessCode: 'test-access-code',
43
43
  apiKey: 'test-api-key',
44
44
  azureApiVersion: 'v1',
45
- useAzure: true,
46
45
  });
47
46
 
48
47
  const mockRuntime: LobeRuntimeAI = { baseURL: 'abc', chat: vi.fn() };
@@ -56,11 +55,7 @@ describe('POST handler', () => {
56
55
 
57
56
  // 验证是否正确调用了模拟函数
58
57
  expect(getJWTPayload).toHaveBeenCalledWith('Bearer some-valid-token');
59
- expect(spy).toHaveBeenCalledWith('test-provider', expect.anything(), {
60
- apiVersion: 'v1',
61
- model: 'test-model',
62
- useAzure: true,
63
- });
58
+ expect(spy).toHaveBeenCalledWith('test-provider', expect.anything());
64
59
  });
65
60
 
66
61
  it('should return Unauthorized error when LOBE_CHAT_AUTH_HEADER is missing', async () => {