@lobehub/lobehub 1.143.0-next.2 → 2.0.0-next.10

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 (244) hide show
  1. package/.github/workflows/desktop-pr-build.yml +12 -10
  2. package/.github/workflows/docker.yml +25 -20
  3. package/.github/workflows/e2e.yml +3 -3
  4. package/.github/workflows/release-desktop-beta.yml +8 -8
  5. package/.github/workflows/release.yml +1 -1
  6. package/.github/workflows/test.yml +4 -4
  7. package/CHANGELOG.md +265 -0
  8. package/README.md +7 -0
  9. package/README.zh-CN.md +7 -0
  10. package/apps/desktop/src/main/utils/next-electron-rsc.ts +7 -5
  11. package/changelog/v1.json +85 -0
  12. package/docs/development/database-schema.dbml +11 -1
  13. package/docs/self-hosting/advanced/auth/next-auth/auth0.mdx +2 -2
  14. package/docs/self-hosting/advanced/auth/next-auth/auth0.zh-CN.mdx +2 -2
  15. package/docs/self-hosting/advanced/auth/next-auth/authelia.mdx +2 -2
  16. package/docs/self-hosting/advanced/auth/next-auth/authelia.zh-CN.mdx +2 -2
  17. package/docs/self-hosting/advanced/auth/next-auth/authentik.mdx +2 -2
  18. package/docs/self-hosting/advanced/auth/next-auth/authentik.zh-CN.mdx +2 -2
  19. package/docs/self-hosting/advanced/auth/next-auth/casdoor.mdx +2 -2
  20. package/docs/self-hosting/advanced/auth/next-auth/casdoor.zh-CN.mdx +2 -2
  21. package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.mdx +2 -2
  22. package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.zh-CN.mdx +2 -2
  23. package/docs/self-hosting/advanced/auth/next-auth/github.mdx +2 -2
  24. package/docs/self-hosting/advanced/auth/next-auth/github.zh-CN.mdx +2 -2
  25. package/docs/self-hosting/advanced/auth/next-auth/google.mdx +32 -29
  26. package/docs/self-hosting/advanced/auth/next-auth/keycloak.mdx +2 -2
  27. package/docs/self-hosting/advanced/auth/next-auth/keycloak.zh-CN.mdx +2 -2
  28. package/docs/self-hosting/advanced/auth/next-auth/logto.mdx +5 -3
  29. package/docs/self-hosting/advanced/auth/next-auth/logto.zh-CN.mdx +5 -3
  30. package/docs/self-hosting/advanced/auth/next-auth/microsoft-entra-id.mdx +2 -2
  31. package/docs/self-hosting/advanced/auth/next-auth/microsoft-entra-id.zh-CN.mdx +2 -2
  32. package/docs/self-hosting/advanced/auth/next-auth/okta.mdx +2 -2
  33. package/docs/self-hosting/advanced/auth/next-auth/okta.zh-CN.mdx +2 -2
  34. package/docs/self-hosting/advanced/auth/next-auth/wechat.mdx +2 -2
  35. package/docs/self-hosting/advanced/auth/next-auth/wechat.zh-CN.mdx +2 -2
  36. package/docs/self-hosting/advanced/auth/next-auth/zitadel.mdx +2 -2
  37. package/docs/self-hosting/advanced/auth/next-auth/zitadel.zh-CN.mdx +2 -2
  38. package/docs/self-hosting/advanced/auth.mdx +32 -21
  39. package/docs/self-hosting/advanced/auth.zh-CN.mdx +30 -19
  40. package/docs/self-hosting/advanced/online-search.mdx +30 -25
  41. package/docs/self-hosting/advanced/online-search.zh-CN.mdx +25 -23
  42. package/locales/ar/models.json +15 -6
  43. package/locales/bg-BG/models.json +15 -6
  44. package/locales/de-DE/models.json +15 -6
  45. package/locales/en-US/models.json +15 -6
  46. package/locales/es-ES/models.json +15 -6
  47. package/locales/fa-IR/models.json +15 -6
  48. package/locales/fr-FR/models.json +15 -6
  49. package/locales/it-IT/models.json +15 -6
  50. package/locales/ja-JP/models.json +15 -6
  51. package/locales/ko-KR/models.json +15 -6
  52. package/locales/nl-NL/models.json +15 -6
  53. package/locales/pl-PL/models.json +15 -6
  54. package/locales/pt-BR/models.json +15 -6
  55. package/locales/ru-RU/models.json +15 -6
  56. package/locales/tr-TR/models.json +15 -6
  57. package/locales/vi-VN/models.json +15 -6
  58. package/locales/zh-CN/models.json +15 -6
  59. package/locales/zh-TW/models.json +15 -6
  60. package/next.config.ts +2 -3
  61. package/package.json +13 -19
  62. package/packages/const/src/index.ts +0 -1
  63. package/packages/const/src/models.ts +13 -0
  64. package/packages/const/src/url.ts +1 -4
  65. package/packages/context-engine/src/index.ts +1 -6
  66. package/packages/context-engine/src/processors/GroupMessageFlatten.ts +12 -2
  67. package/packages/context-engine/src/processors/__tests__/GroupMessageFlatten.test.ts +73 -9
  68. package/packages/context-engine/src/providers/index.ts +0 -2
  69. package/packages/database/migrations/0041_improve_index.sql +10 -0
  70. package/packages/database/migrations/meta/0041_snapshot.json +7784 -0
  71. package/packages/database/migrations/meta/_journal.json +7 -0
  72. package/packages/database/package.json +1 -1
  73. package/packages/database/src/core/migrations.json +17 -0
  74. package/packages/database/src/models/__tests__/message.grouping.test.ts +812 -0
  75. package/packages/database/src/models/__tests__/message.test.ts +322 -170
  76. package/packages/database/src/models/message.ts +62 -24
  77. package/packages/database/src/models/session.ts +60 -19
  78. package/packages/database/src/schemas/agent.ts +10 -11
  79. package/packages/database/src/schemas/message.ts +5 -1
  80. package/packages/database/src/schemas/relations.ts +6 -4
  81. package/packages/database/src/schemas/session.ts +2 -0
  82. package/packages/database/src/schemas/topic.ts +6 -1
  83. package/packages/database/src/utils/__tests__/groupMessages.test.ts +145 -2
  84. package/packages/database/src/utils/groupMessages.ts +7 -5
  85. package/packages/electron-client-ipc/package.json +4 -1
  86. package/packages/file-loaders/package.json +1 -0
  87. package/packages/model-bank/src/aiModels/anthropic.ts +0 -63
  88. package/packages/model-bank/src/aiModels/azure.ts +155 -0
  89. package/packages/model-bank/src/aiModels/bedrock.ts +44 -0
  90. package/packages/model-bank/src/aiModels/higress.ts +0 -55
  91. package/packages/model-bank/src/aiModels/infiniai.ts +21 -0
  92. package/packages/model-bank/src/aiModels/ollamacloud.ts +13 -0
  93. package/packages/model-bank/src/aiModels/siliconcloud.ts +19 -0
  94. package/packages/model-runtime/src/core/openaiCompatibleFactory/createImage.ts +1 -1
  95. package/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts +33 -3
  96. package/packages/model-runtime/src/core/parameterResolver.ts +3 -0
  97. package/packages/model-runtime/src/core/streams/openai/__snapshots__/responsesStream.test.ts.snap +0 -38
  98. package/packages/model-runtime/src/providers/azureOpenai/index.ts +2 -1
  99. package/packages/model-runtime/src/providers/minimax/index.ts +5 -5
  100. package/packages/model-runtime/src/providers/search1api/index.test.ts +2 -2
  101. package/packages/types/src/message/common/base.ts +13 -0
  102. package/packages/types/src/message/common/image.ts +8 -0
  103. package/packages/types/src/message/common/metadata.ts +39 -0
  104. package/packages/types/src/message/common/tools.ts +10 -0
  105. package/packages/types/src/message/db/params.ts +47 -1
  106. package/packages/types/src/message/ui/chat.ts +4 -1
  107. package/packages/types/src/search.ts +16 -0
  108. package/packages/web-crawler/src/crawImpl/firecrawl.ts +39 -12
  109. package/scripts/migrateServerDB/index.ts +2 -1
  110. package/src/app/(backend)/oidc/consent/route.ts +0 -1
  111. package/src/app/(backend)/webapi/revalidate/route.ts +1 -1
  112. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/V1Mobile/index.tsx +2 -2
  113. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/V1Mobile/useSend.ts +6 -4
  114. package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/useSend.ts +15 -10
  115. package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/index.tsx +4 -2
  116. package/src/app/[variants]/(main)/settings/_layout/SettingsContent.tsx +0 -3
  117. package/src/app/[variants]/layout.tsx +1 -0
  118. package/src/app/sitemap.tsx +7 -1
  119. package/src/components/Thinking/index.tsx +4 -3
  120. package/src/config/modelProviders/anthropic.ts +0 -23
  121. package/src/config/modelProviders/higress.ts +0 -23
  122. package/src/config/modelProviders/minimax.ts +1 -1
  123. package/src/config/modelProviders/qiniu.ts +1 -1
  124. package/src/envs/auth.ts +0 -179
  125. package/src/features/AgentSetting/AgentPlugin/index.tsx +21 -13
  126. package/src/features/ChatInput/ActionBar/STT/browser.tsx +2 -2
  127. package/src/features/ChatInput/ActionBar/STT/openai.tsx +2 -2
  128. package/src/features/ChatInput/ActionBar/Tools/useControls.tsx +1 -3
  129. package/src/features/Conversation/Error/ErrorJsonViewer.tsx +4 -3
  130. package/src/features/Conversation/Error/OllamaBizError/index.tsx +7 -2
  131. package/src/features/Conversation/Error/index.tsx +15 -5
  132. package/src/features/Conversation/MarkdownElements/LobeArtifact/Render/index.tsx +2 -2
  133. package/src/features/Conversation/Messages/Assistant/Extra/index.tsx +2 -2
  134. package/src/features/Conversation/Messages/Assistant/MessageContent.tsx +5 -3
  135. package/src/features/Conversation/Messages/Assistant/Tool/Inspector/BuiltinPluginTitle.tsx +2 -2
  136. package/src/features/Conversation/Messages/Assistant/Tool/Inspector/ToolTitle.tsx +4 -2
  137. package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +2 -2
  138. package/src/features/Conversation/Messages/Assistant/Tool/Render/index.tsx +2 -2
  139. package/src/features/Conversation/Messages/Assistant/Tool/index.tsx +2 -2
  140. package/src/features/Conversation/Messages/Assistant/index.tsx +4 -4
  141. package/src/features/Conversation/Messages/Default.tsx +2 -2
  142. package/src/features/Conversation/Messages/User/Extra.tsx +2 -2
  143. package/src/features/Conversation/Messages/User/index.tsx +4 -4
  144. package/src/features/Conversation/Messages/index.tsx +3 -3
  145. package/src/features/Conversation/components/AutoScroll.tsx +2 -2
  146. package/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx +9 -6
  147. package/src/features/PluginTag/index.tsx +1 -3
  148. package/src/features/PluginsUI/Render/BuiltinType/index.test.tsx +37 -28
  149. package/src/features/Portal/Artifacts/Body/index.tsx +2 -2
  150. package/src/libs/next-auth/auth.config.ts +1 -1
  151. package/src/libs/next-auth/sso-providers/auth0.ts +0 -7
  152. package/src/libs/next-auth/sso-providers/authelia.ts +3 -5
  153. package/src/libs/next-auth/sso-providers/authentik.ts +0 -7
  154. package/src/libs/next-auth/sso-providers/cloudflare-zero-trust.ts +3 -6
  155. package/src/libs/next-auth/sso-providers/cognito.ts +1 -5
  156. package/src/libs/next-auth/sso-providers/generic-oidc.ts +3 -5
  157. package/src/libs/next-auth/sso-providers/github.ts +0 -6
  158. package/src/libs/next-auth/sso-providers/google.ts +0 -2
  159. package/src/libs/next-auth/sso-providers/index.ts +0 -2
  160. package/src/libs/next-auth/sso-providers/keycloak.ts +0 -3
  161. package/src/libs/next-auth/sso-providers/logto.ts +3 -5
  162. package/src/libs/next-auth/sso-providers/okta.ts +0 -4
  163. package/src/libs/next-auth/sso-providers/zitadel.ts +0 -7
  164. package/src/libs/oidc-provider/provider.ts +1 -1
  165. package/src/server/modules/AssistantStore/index.ts +1 -1
  166. package/src/server/modules/ModelRuntime/trace.ts +11 -4
  167. package/src/server/routers/lambda/message.ts +14 -3
  168. package/src/server/routers/lambda/session.ts +8 -5
  169. package/src/server/services/search/impls/firecrawl/index.ts +51 -11
  170. package/src/server/services/search/impls/firecrawl/type.ts +60 -9
  171. package/src/services/chat/chat.test.ts +1 -40
  172. package/src/services/chat/contextEngineering.test.ts +0 -30
  173. package/src/services/chat/contextEngineering.ts +1 -12
  174. package/src/services/chat/index.ts +2 -7
  175. package/src/services/chat/types.ts +1 -1
  176. package/src/services/message/_deprecated.ts +1 -1
  177. package/src/services/message/client.ts +8 -2
  178. package/src/services/message/server.ts +7 -2
  179. package/src/services/message/type.ts +6 -1
  180. package/src/services/user/client.test.ts +4 -1
  181. package/src/store/chat/helpers.test.ts +99 -0
  182. package/src/store/chat/helpers.ts +21 -2
  183. package/src/store/chat/selectors.ts +1 -1
  184. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +3 -3
  185. package/src/store/chat/slices/builtinTool/actions/index.ts +1 -4
  186. package/src/store/chat/slices/message/action.test.ts +5 -1
  187. package/src/store/chat/slices/message/action.ts +102 -14
  188. package/src/store/chat/slices/message/reducer.test.ts +363 -5
  189. package/src/store/chat/slices/message/reducer.ts +87 -3
  190. package/src/store/chat/slices/message/{selectors.test.ts → selectors/chat.test.ts} +266 -30
  191. package/src/store/chat/slices/message/{selectors.ts → selectors/chat.ts} +29 -79
  192. package/src/store/chat/slices/message/selectors/index.ts +2 -0
  193. package/src/store/chat/slices/message/selectors/messageState.test.ts +36 -0
  194. package/src/store/chat/slices/message/selectors/messageState.ts +80 -0
  195. package/src/store/chat/slices/plugin/action.test.ts +34 -132
  196. package/src/store/chat/slices/plugin/action.ts +1 -44
  197. package/src/store/tool/selectors/tool.test.ts +1 -1
  198. package/src/store/tool/selectors/tool.ts +6 -8
  199. package/src/store/tool/slices/builtin/action.test.ts +83 -35
  200. package/src/store/tool/slices/builtin/action.ts +0 -9
  201. package/src/store/tool/slices/builtin/selectors.test.ts +4 -30
  202. package/src/store/tool/slices/builtin/selectors.ts +15 -21
  203. package/src/tools/index.ts +0 -6
  204. package/src/tools/renders.ts +0 -3
  205. package/src/tools/web-browsing/Portal/Search/Footer.tsx +2 -2
  206. package/tsconfig.json +9 -2
  207. package/packages/const/src/guide.ts +0 -89
  208. package/packages/context-engine/src/providers/InboxGuide.ts +0 -102
  209. package/packages/context-engine/src/providers/__tests__/InboxGuideProvider.test.ts +0 -121
  210. package/src/app/[variants]/(main)/settings/llm/ProviderList/Azure/index.tsx +0 -93
  211. package/src/app/[variants]/(main)/settings/llm/ProviderList/Bedrock/index.tsx +0 -70
  212. package/src/app/[variants]/(main)/settings/llm/ProviderList/Cloudflare/index.tsx +0 -39
  213. package/src/app/[variants]/(main)/settings/llm/ProviderList/Github/index.tsx +0 -52
  214. package/src/app/[variants]/(main)/settings/llm/ProviderList/HuggingFace/index.tsx +0 -52
  215. package/src/app/[variants]/(main)/settings/llm/ProviderList/Ollama/index.tsx +0 -20
  216. package/src/app/[variants]/(main)/settings/llm/ProviderList/OpenAI/index.tsx +0 -17
  217. package/src/app/[variants]/(main)/settings/llm/ProviderList/providers.tsx +0 -132
  218. package/src/app/[variants]/(main)/settings/llm/components/Checker.tsx +0 -118
  219. package/src/app/[variants]/(main)/settings/llm/components/ProviderConfig/index.tsx +0 -303
  220. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/CustomModelOption.tsx +0 -98
  221. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelConfigModal/Form.tsx +0 -104
  222. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelConfigModal/index.tsx +0 -77
  223. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/ModelFetcher.tsx +0 -105
  224. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/Option.tsx +0 -68
  225. package/src/app/[variants]/(main)/settings/llm/components/ProviderModelList/index.tsx +0 -146
  226. package/src/app/[variants]/(main)/settings/llm/const.ts +0 -20
  227. package/src/app/[variants]/(main)/settings/llm/features/Footer.tsx +0 -35
  228. package/src/app/[variants]/(main)/settings/llm/index.tsx +0 -30
  229. package/src/app/[variants]/(main)/settings/llm/type.ts +0 -5
  230. package/src/envs/__tests__/auth.test.ts +0 -200
  231. package/src/libs/next-auth/sso-providers/azure-ad.ts +0 -33
  232. package/src/services/chat/__snapshots__/chat.test.ts.snap +0 -110
  233. package/src/store/chat/slices/builtinTool/actions/__tests__/dalle.test.ts +0 -121
  234. package/src/store/chat/slices/builtinTool/actions/dalle.ts +0 -124
  235. package/src/tools/dalle/Render/GalleyGrid.tsx +0 -60
  236. package/src/tools/dalle/Render/Item/EditMode.tsx +0 -66
  237. package/src/tools/dalle/Render/Item/Error.tsx +0 -49
  238. package/src/tools/dalle/Render/Item/Image.tsx +0 -44
  239. package/src/tools/dalle/Render/Item/ImageFileItem.tsx +0 -57
  240. package/src/tools/dalle/Render/Item/index.tsx +0 -88
  241. package/src/tools/dalle/Render/ToolBar.tsx +0 -56
  242. package/src/tools/dalle/Render/index.tsx +0 -52
  243. package/src/tools/dalle/index.ts +0 -92
  244. /package/src/{middleware.ts → proxy.ts} +0 -0
@@ -2,15 +2,12 @@ import { BuiltinRender } from '@lobechat/types';
2
2
 
3
3
  import { CodeInterpreterManifest } from './code-interpreter';
4
4
  import CodeInterpreterRender from './code-interpreter/Render';
5
- import { DalleManifest } from './dalle';
6
- import DalleRender from './dalle/Render';
7
5
  import { LocalSystemManifest } from './local-system';
8
6
  import LocalFilesRender from './local-system/Render';
9
7
  import { WebBrowsingManifest } from './web-browsing';
10
8
  import WebBrowsing from './web-browsing/Render';
11
9
 
12
10
  export const BuiltinToolsRenders: Record<string, BuiltinRender> = {
13
- [DalleManifest.identifier]: DalleRender as BuiltinRender,
14
11
  [WebBrowsingManifest.identifier]: WebBrowsing as BuiltinRender,
15
12
  [LocalSystemManifest.identifier]: LocalFilesRender as BuiltinRender,
16
13
  [CodeInterpreterManifest.identifier]: CodeInterpreterRender as BuiltinRender,
@@ -4,12 +4,12 @@ import { useTranslation } from 'react-i18next';
4
4
  import { Flexbox } from 'react-layout-kit';
5
5
 
6
6
  import { useChatStore } from '@/store/chat';
7
- import { chatPortalSelectors, chatSelectors } from '@/store/chat/selectors';
7
+ import { chatPortalSelectors, messageStateSelectors } from '@/store/chat/selectors';
8
8
 
9
9
  const Footer = () => {
10
10
  const [messageId, isAIGenerating, triggerAIMessage, saveSearchResult] = useChatStore((s) => [
11
11
  chatPortalSelectors.toolMessageId(s),
12
- chatSelectors.isAIGenerating(s),
12
+ messageStateSelectors.isAIGenerating(s),
13
13
  s.triggerAIMessage,
14
14
  s.saveSearchResult,
15
15
  ]);
package/tsconfig.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "moduleResolution": "bundler",
14
14
  "resolveJsonModule": true,
15
15
  "isolatedModules": true,
16
- "jsx": "preserve",
16
+ "jsx": "react-jsx",
17
17
  "incremental": true,
18
18
  "baseUrl": ".",
19
19
  "types": ["vitest/globals", "@serwist/next/typings"],
@@ -41,5 +41,12 @@
41
41
  ".temp",
42
42
  "e2e"
43
43
  ],
44
- "include": ["**/*.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "next-env.d.ts"]
44
+ "include": [
45
+ "**/*.d.ts",
46
+ "**/*.ts",
47
+ "**/*.tsx",
48
+ ".next/types/**/*.ts",
49
+ "next-env.d.ts",
50
+ ".next/dev/types/**/*.ts"
51
+ ]
45
52
  }
@@ -1,89 +0,0 @@
1
- import urlJoin from 'url-join';
2
-
3
- import { BRANDING_EMAIL } from './branding';
4
- import {
5
- BLOG,
6
- DOCKER_IMAGE,
7
- GITHUB,
8
- OFFICIAL_PREVIEW_URL,
9
- OFFICIAL_SITE,
10
- OFFICIAL_URL,
11
- SELF_HOSTING_DOCUMENTS,
12
- USAGE_DOCUMENTS,
13
- WIKI,
14
- } from './url';
15
-
16
- export const INBOX_GUIDE_SYSTEMROLE = `# Role: LobeChat Support Assistant
17
-
18
- ## About [LobeHub](${OFFICIAL_SITE})
19
-
20
- LobeHub is an organization of design-engineers dedicated to providing advanced design components and tools for AI-generated content (AIGC).
21
- It aims to create a technology-driven community platform that enables the sharing of knowledge and ideas, fostering inspiration and collaboration.
22
-
23
- Adopting a Bootstrapping approach, LobeHub is committed to delivering an open, transparent, and user-friendly product ecosystem for both casual users and professional developers.
24
- LobeHub serves as an AI Agent playground, where creativity and innovation meet.
25
-
26
- ## About [LobeChat](${OFFICIAL_URL})
27
-
28
- LobeChat, a product of LobeHub, is an open-source ChatGPT/LLMs UI/Framework designed for modern LLMs/AI applications.
29
- Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Perplexity / Bedrock / Azure / Mistral / Ollama ), Multi-Modals (Vision/TTS) and plugin system.
30
- and offers a one-click FREE deployment for a private ChatGPT chat application, making it accessible and customizable for a wide range of users.
31
-
32
- ### Features
33
-
34
- - [Multi-Model Service Provider Support](${urlJoin(USAGE_DOCUMENTS, '/features/multi-ai-providers')})
35
- - [Local Large Language Model (LLM) Support](${urlJoin(USAGE_DOCUMENTS, '/features/local-llm')})
36
- - [Model Visual Recognition](${urlJoin(USAGE_DOCUMENTS, '/features/vision')})
37
- - [TTS & STT Voice Conversation](${urlJoin(USAGE_DOCUMENTS, '/features/tts')})
38
- - [Text to Image Generation](${urlJoin(USAGE_DOCUMENTS, '/features/text-to-image')})
39
- - [Plugin System (Function Calling)](${urlJoin(USAGE_DOCUMENTS, '/features/plugin-system')})
40
- - [Agent Market (GPTs)](${urlJoin(USAGE_DOCUMENTS, '/features/agent-market')})
41
-
42
- ### Community Edition and Cloud Version
43
-
44
- LobeChat is currently available as a community preview version, completely open-source and free of charge.
45
-
46
- In the LobeChat Cloud version, we provide 500,000 free computing credits to all registered users. It is ready to use without complex configurations.
47
- If you require more usage, you can subscribe to the Basic, Advanced, or Professional versions for a fee.
48
-
49
- ### Self Hosting
50
-
51
- LobeChat provides Self-Hosted Version with [Vercel](${urlJoin(SELF_HOSTING_DOCUMENTS, '/platform/vercel')}) and [Docker Image](${DOCKER_IMAGE}).
52
- This allows you to deploy your own chatbot within a few minutes without any prior knowledge.
53
-
54
- **IMPORTANT**
55
-
56
- When users ask about usage or deployment, DO NOT MAKE UP ANSWERS. Instead, guide them to the relevant documentation!!!
57
-
58
- Learn more about [Build your own LobeChat](${SELF_HOSTING_DOCUMENTS}) by checking it out.
59
-
60
- ## Resources Links
61
-
62
- In the response, please try to pick and include the relevant links below, and if a relevant answer cannot be provided, also offer the user these related links:
63
-
64
- - Official Website: ${OFFICIAL_SITE}
65
- - Cloud Version: ${OFFICIAL_URL}
66
- - Community Edition: ${OFFICIAL_PREVIEW_URL}
67
- - GitHub Repository: ${GITHUB}
68
- - Latest News: ${BLOG}
69
- - Usage Documentation: ${USAGE_DOCUMENTS}
70
- - Self-Hosting Documentation: ${SELF_HOSTING_DOCUMENTS}
71
- - Development Guide: ${WIKI}
72
- - Email Support: ${BRANDING_EMAIL.support}
73
- - Business Inquiries: ${BRANDING_EMAIL.business}
74
-
75
- ## Workflow
76
-
77
- 1. Greet users and introduce the role and purpose of LobeHub LobeChat Support Assistant.
78
- 2. Understand and address user inquiries related to the LobeHub ecosystem and LobeChat application.
79
- 3. If unable to resolve user queries, pick and guide them to appropriate resources listed above.
80
-
81
- ## Initialization
82
-
83
- As the role <Role>, I will adhere to the following guidelines:
84
- - Provide accurate and helpful information to users.
85
- - Maintain a friendly and professional demeanor.
86
- - Direct users to the appropriate resources when necessary.
87
- - Keep the language of the response consistent with the language of the user input; if they are not consistent, then translate.
88
-
89
- Welcome users to LobeChat, introduce myself as the <Role>, and inform them about the services and support available. Then, guide users through the <Workflow> for assistance.`;
@@ -1,102 +0,0 @@
1
- import debug from 'debug';
2
-
3
- import { BaseProvider } from '../base/BaseProvider';
4
- import type { PipelineContext, ProcessorOptions } from '../types';
5
-
6
- const log = debug('context-engine:provider:InboxGuideProvider');
7
-
8
- /**
9
- * Inbox Guide System Role Configuration
10
- */
11
- export interface InboxGuideConfig {
12
- /** Inbox guide system role content */
13
- inboxGuideSystemRole: string;
14
- /** Inbox session ID constant */
15
- inboxSessionId: string;
16
- /** Whether it's a welcome question */
17
- isWelcomeQuestion?: boolean;
18
- /** Session ID */
19
- sessionId?: string;
20
- }
21
-
22
- /**
23
- * Inbox Guide Provider
24
- * Responsible for injecting guide system role for welcome questions in inbox sessions
25
- */
26
- export class InboxGuideProvider extends BaseProvider {
27
- readonly name = 'InboxGuideProvider';
28
-
29
- constructor(
30
- private config: InboxGuideConfig,
31
- options: ProcessorOptions = {},
32
- ) {
33
- super(options);
34
- }
35
-
36
- protected async doProcess(context: PipelineContext): Promise<PipelineContext> {
37
- const clonedContext = this.cloneContext(context);
38
-
39
- // 检查是否需要注入收件箱引导
40
- const shouldInject = this.shouldInjectInboxGuide();
41
-
42
- if (!shouldInject) {
43
- log('Inbox guide injection conditions not met, skipping processing');
44
- return this.markAsExecuted(clonedContext);
45
- }
46
-
47
- // 注入收件箱引导系统角色
48
- this.injectInboxGuideSystemRole(clonedContext);
49
-
50
- // 更新元数据
51
- clonedContext.metadata.inboxGuide = {
52
- contentLength: this.config.inboxGuideSystemRole.length,
53
- injected: true,
54
- isWelcomeQuestion: this.config.isWelcomeQuestion,
55
- sessionId: this.config.sessionId,
56
- };
57
-
58
- log('Inbox guide system role injection completed');
59
- return this.markAsExecuted(clonedContext);
60
- }
61
-
62
- /**
63
- * Check if inbox guide should be injected
64
- */
65
- private shouldInjectInboxGuide(): boolean {
66
- return (
67
- (this.config.isWelcomeQuestion &&
68
- this.config.sessionId === this.config.inboxSessionId &&
69
- !!this.config.inboxGuideSystemRole) ||
70
- false
71
- );
72
- }
73
-
74
- /**
75
- * Inject inbox guide system role
76
- */
77
- private injectInboxGuideSystemRole(context: PipelineContext): void {
78
- const existingSystemMessage = context.messages.find((msg) => msg.role === 'system');
79
-
80
- if (existingSystemMessage) {
81
- // 合并到现有系统消息
82
- existingSystemMessage.content = [
83
- existingSystemMessage.content,
84
- this.config.inboxGuideSystemRole,
85
- ]
86
- .filter(Boolean)
87
- .join('\n\n');
88
-
89
- log(
90
- `Inbox guide merged to existing system message, final length: ${existingSystemMessage.content.length}`,
91
- );
92
- } else {
93
- context.messages.unshift({
94
- content: this.config.inboxGuideSystemRole,
95
- role: 'system' as const,
96
- } as any);
97
- log(
98
- `New inbox guide system message created, content length: ${this.config.inboxGuideSystemRole.length}`,
99
- );
100
- }
101
- }
102
- }
@@ -1,121 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
-
3
- import type { PipelineContext } from '../../types';
4
- import { InboxGuideProvider } from '../InboxGuide';
5
-
6
- const createContext = (messages: any[]): PipelineContext => ({
7
- initialState: { messages: [] } as any,
8
- messages,
9
- metadata: { model: 'gpt-4', maxTokens: 4096 },
10
- isAborted: false,
11
- });
12
-
13
- describe('InboxGuideProvider', () => {
14
- const mockInboxGuideContent = '# Role: LobeChat Support Assistant\n\nWelcome to LobeChat!';
15
- const INBOX_SESSION_ID = 'inbox';
16
-
17
- it('should inject inbox guide for welcome questions in inbox session', async () => {
18
- const provider = new InboxGuideProvider({
19
- isWelcomeQuestion: true,
20
- sessionId: INBOX_SESSION_ID,
21
- inboxSessionId: INBOX_SESSION_ID,
22
- inboxGuideSystemRole: mockInboxGuideContent,
23
- });
24
-
25
- const messages = [{ id: 'u1', role: 'user', content: 'Hello, this is my first question' }];
26
-
27
- const ctx = createContext(messages);
28
- const result = await provider.process(ctx);
29
-
30
- // Should have system message with inbox guide content
31
- const systemMessage = result.messages.find((msg) => msg.role === 'system');
32
- expect(systemMessage).toBeDefined();
33
- expect(systemMessage!.content).toBe(mockInboxGuideContent);
34
-
35
- // Should update metadata
36
- expect(result.metadata.inboxGuide).toEqual({
37
- injected: true,
38
- sessionId: INBOX_SESSION_ID,
39
- isWelcomeQuestion: true,
40
- contentLength: mockInboxGuideContent.length,
41
- });
42
- });
43
-
44
- it('should merge inbox guide with existing system message', async () => {
45
- const provider = new InboxGuideProvider({
46
- isWelcomeQuestion: true,
47
- sessionId: INBOX_SESSION_ID,
48
- inboxSessionId: INBOX_SESSION_ID,
49
- inboxGuideSystemRole: mockInboxGuideContent,
50
- });
51
-
52
- const existingSystemContent = 'Existing system message';
53
- const messages = [
54
- { id: 's1', role: 'system', content: existingSystemContent },
55
- { id: 'u1', role: 'user', content: 'Hello' },
56
- ];
57
-
58
- const ctx = createContext(messages);
59
- const result = await provider.process(ctx);
60
-
61
- const systemMessage = result.messages.find((msg) => msg.role === 'system');
62
- expect(systemMessage!.content).toBe(`${existingSystemContent}\n\n${mockInboxGuideContent}`);
63
- });
64
-
65
- it('should skip injection when not welcome question', async () => {
66
- const provider = new InboxGuideProvider({
67
- isWelcomeQuestion: false,
68
- sessionId: INBOX_SESSION_ID,
69
- inboxSessionId: INBOX_SESSION_ID,
70
- inboxGuideSystemRole: mockInboxGuideContent,
71
- });
72
-
73
- const messages = [{ id: 'u1', role: 'user', content: 'Regular question' }];
74
-
75
- const ctx = createContext(messages);
76
- const result = await provider.process(ctx);
77
-
78
- // Should not have system message
79
- const systemMessage = result.messages.find((msg) => msg.role === 'system');
80
- expect(systemMessage).toBeUndefined();
81
-
82
- // Should not have metadata
83
- expect(result.metadata.inboxGuide).toBeUndefined();
84
- });
85
-
86
- it('should skip injection when not in inbox session', async () => {
87
- const provider = new InboxGuideProvider({
88
- isWelcomeQuestion: true,
89
- sessionId: 'other-session',
90
- inboxSessionId: INBOX_SESSION_ID,
91
- inboxGuideSystemRole: mockInboxGuideContent,
92
- });
93
-
94
- const messages = [{ id: 'u1', role: 'user', content: 'Hello' }];
95
-
96
- const ctx = createContext(messages);
97
- const result = await provider.process(ctx);
98
-
99
- // Should not have system message
100
- const systemMessage = result.messages.find((msg) => msg.role === 'system');
101
- expect(systemMessage).toBeUndefined();
102
- });
103
-
104
- it('should skip injection when no inbox guide content', async () => {
105
- const provider = new InboxGuideProvider({
106
- isWelcomeQuestion: true,
107
- sessionId: INBOX_SESSION_ID,
108
- inboxSessionId: INBOX_SESSION_ID,
109
- inboxGuideSystemRole: '',
110
- });
111
-
112
- const messages = [{ id: 'u1', role: 'user', content: 'Hello' }];
113
-
114
- const ctx = createContext(messages);
115
- const result = await provider.process(ctx);
116
-
117
- // Should not have system message
118
- const systemMessage = result.messages.find((msg) => msg.role === 'system');
119
- expect(systemMessage).toBeUndefined();
120
- });
121
- });
@@ -1,93 +0,0 @@
1
- 'use client';
2
-
3
- import { AutoComplete, Input, InputPassword, Markdown } from '@lobehub/ui';
4
- import { createStyles } from 'antd-style';
5
- import { ModelProvider } from 'model-bank';
6
- import { useTranslation } from 'react-i18next';
7
-
8
- import { AzureProviderCard } from '@/config/modelProviders';
9
- import { useUserStore } from '@/store/user';
10
- import { modelProviderSelectors } from '@/store/user/selectors';
11
-
12
- import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
13
- import { ProviderItem } from '../../type';
14
-
15
- const useStyles = createStyles(({ css, token }) => ({
16
- markdown: css`
17
- p {
18
- color: ${token.colorTextDescription} !important;
19
- }
20
- `,
21
- tip: css`
22
- font-size: 12px;
23
- color: ${token.colorTextDescription};
24
- `,
25
- }));
26
-
27
- const providerKey = ModelProvider.Azure;
28
-
29
- export const useAzureProvider = (): ProviderItem => {
30
- const { t } = useTranslation('modelProvider');
31
- const { styles } = useStyles();
32
-
33
- // Get the first model card's deployment name as the check model
34
- const checkModel = useUserStore((s) => {
35
- const chatModelCards = modelProviderSelectors.getModelCardsById(providerKey)(s);
36
-
37
- if (chatModelCards.length > 0) {
38
- return chatModelCards[0].deploymentName;
39
- }
40
-
41
- return 'gpt-35-turbo';
42
- });
43
- return {
44
- ...AzureProviderCard,
45
- apiKeyItems: [
46
- {
47
- children: (
48
- <InputPassword autoComplete={'new-password'} placeholder={t('azure.token.placeholder')} />
49
- ),
50
- desc: t('azure.token.desc'),
51
- label: t('azure.token.title'),
52
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
53
- },
54
- {
55
- children: <Input allowClear placeholder={t('azure.endpoint.placeholder')} />,
56
- desc: t('azure.endpoint.desc'),
57
- label: t('azure.endpoint.title'),
58
- name: [KeyVaultsConfigKey, providerKey, 'endpoint'],
59
- },
60
- {
61
- children: (
62
- <AutoComplete
63
- options={[
64
- '2024-06-01',
65
- '2024-02-01',
66
- '2024-05-01-preview',
67
- '2024-04-01-preview',
68
- '2024-03-01-preview',
69
- '2024-02-15-preview',
70
- '2023-10-01-preview',
71
- '2023-06-01-preview',
72
- '2023-05-15',
73
- ].map((i) => ({ label: i, value: i }))}
74
- placeholder={'20XX-XX-XX'}
75
- />
76
- ),
77
- desc: (
78
- <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
79
- {t('azure.azureApiVersion.desc')}
80
- </Markdown>
81
- ),
82
- label: t('azure.azureApiVersion.title'),
83
- name: [KeyVaultsConfigKey, providerKey, 'apiVersion'],
84
- },
85
- ],
86
- checkModel,
87
- modelList: {
88
- azureDeployName: true,
89
- notFoundContent: t('azure.empty'),
90
- placeholder: t('azure.modelListPlaceholder'),
91
- },
92
- };
93
- };
@@ -1,70 +0,0 @@
1
- 'use client';
2
-
3
- import { InputPassword, Select } from '@lobehub/ui';
4
- import { useTranslation } from 'react-i18next';
5
-
6
- import { BedrockProviderCard } from '@/config/modelProviders';
7
- import { GlobalLLMProviderKey } from '@/types/user/settings';
8
-
9
- import { KeyVaultsConfigKey } from '../../const';
10
- import { ProviderItem } from '../../type';
11
-
12
- const providerKey: GlobalLLMProviderKey = 'bedrock';
13
-
14
- export const useBedrockProvider = (): ProviderItem => {
15
- const { t } = useTranslation('modelProvider');
16
-
17
- return {
18
- ...BedrockProviderCard,
19
- apiKeyItems: [
20
- {
21
- children: (
22
- <InputPassword
23
- autoComplete={'new-password'}
24
- placeholder={t(`${providerKey}.accessKeyId.placeholder`)}
25
- />
26
- ),
27
- desc: t(`${providerKey}.accessKeyId.desc`),
28
- label: t(`${providerKey}.accessKeyId.title`),
29
- name: [KeyVaultsConfigKey, providerKey, 'accessKeyId'],
30
- },
31
- {
32
- children: (
33
- <InputPassword
34
- autoComplete={'new-password'}
35
- placeholder={t(`${providerKey}.secretAccessKey.placeholder`)}
36
- />
37
- ),
38
- desc: t(`${providerKey}.secretAccessKey.desc`),
39
- label: t(`${providerKey}.secretAccessKey.title`),
40
- name: [KeyVaultsConfigKey, providerKey, 'secretAccessKey'],
41
- },
42
- {
43
- children: (
44
- <InputPassword
45
- autoComplete={'new-password'}
46
- placeholder={t(`${providerKey}.sessionToken.placeholder`)}
47
- />
48
- ),
49
- desc: t(`${providerKey}.sessionToken.desc`),
50
- label: t(`${providerKey}.sessionToken.title`),
51
- name: [KeyVaultsConfigKey, providerKey, 'sessionToken'],
52
- },
53
- {
54
- children: (
55
- <Select
56
- allowClear
57
- options={['us-east-1', 'us-west-2', 'ap-southeast-1', 'eu-central-1'].map((i) => ({
58
- label: i,
59
- value: i,
60
- }))}
61
- placeholder={'us-east-1'}
62
- />
63
- ),
64
- desc: t(`${providerKey}.region.desc`),
65
- label: t(`${providerKey}.region.title`),
66
- name: [KeyVaultsConfigKey, providerKey, 'region'],
67
- },
68
- ],
69
- };
70
- };
@@ -1,39 +0,0 @@
1
- 'use client';
2
-
3
- import { Input, InputPassword } from '@lobehub/ui';
4
- import { useTranslation } from 'react-i18next';
5
-
6
- import { CloudflareProviderCard } from '@/config/modelProviders';
7
- import { GlobalLLMProviderKey } from '@/types/user/settings';
8
-
9
- import { KeyVaultsConfigKey } from '../../const';
10
- import { ProviderItem } from '../../type';
11
-
12
- const providerKey: GlobalLLMProviderKey = 'cloudflare';
13
-
14
- export const useCloudflareProvider = (): ProviderItem => {
15
- const { t } = useTranslation('modelProvider');
16
-
17
- return {
18
- ...CloudflareProviderCard,
19
- apiKeyItems: [
20
- {
21
- children: (
22
- <InputPassword
23
- autoComplete={'new-password'}
24
- placeholder={t(`${providerKey}.apiKey.placeholder`)}
25
- />
26
- ),
27
- desc: t(`${providerKey}.apiKey.desc`),
28
- label: t(`${providerKey}.apiKey.title`),
29
- name: [KeyVaultsConfigKey, providerKey, 'apiKey'],
30
- },
31
- {
32
- children: <Input placeholder={t(`${providerKey}.baseURLOrAccountID.placeholder`)} />,
33
- desc: t(`${providerKey}.baseURLOrAccountID.desc`),
34
- label: t(`${providerKey}.baseURLOrAccountID.title`),
35
- name: [KeyVaultsConfigKey, providerKey, 'baseURLOrAccountID'],
36
- },
37
- ],
38
- };
39
- };
@@ -1,52 +0,0 @@
1
- 'use client';
2
-
3
- import { InputPassword, Markdown } from '@lobehub/ui';
4
- import { createStyles } from 'antd-style';
5
- import { useTranslation } from 'react-i18next';
6
-
7
- import { GithubProviderCard } from '@/config/modelProviders';
8
- import { GlobalLLMProviderKey } from '@/types/user/settings';
9
-
10
- import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
11
- import { ProviderItem } from '../../type';
12
-
13
- const useStyles = createStyles(({ css, token }) => ({
14
- markdown: css`
15
- p {
16
- color: ${token.colorTextDescription} !important;
17
- }
18
- `,
19
- tip: css`
20
- font-size: 12px;
21
- color: ${token.colorTextDescription};
22
- `,
23
- }));
24
-
25
- const providerKey: GlobalLLMProviderKey = 'github';
26
-
27
- // Same as OpenAIProvider, but replace API Key with Github Personal Access Token
28
- export const useGithubProvider = (): ProviderItem => {
29
- const { t } = useTranslation('modelProvider');
30
- const { styles } = useStyles();
31
-
32
- return {
33
- ...GithubProviderCard,
34
- apiKeyItems: [
35
- {
36
- children: (
37
- <InputPassword
38
- autoComplete={'new-password'}
39
- placeholder={t(`${providerKey}.personalAccessToken.placeholder`)}
40
- />
41
- ),
42
- desc: (
43
- <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
44
- {t(`${providerKey}.personalAccessToken.desc`)}
45
- </Markdown>
46
- ),
47
- label: t(`${providerKey}.personalAccessToken.title`),
48
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
49
- },
50
- ],
51
- };
52
- };
@@ -1,52 +0,0 @@
1
- 'use client';
2
-
3
- import { GlobalLLMProviderKey } from '@lobechat/types';
4
- import { InputPassword, Markdown } from '@lobehub/ui';
5
- import { createStyles } from 'antd-style';
6
- import { useTranslation } from 'react-i18next';
7
-
8
- import { HuggingFaceProviderCard } from '@/config/modelProviders';
9
-
10
- import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
11
- import { ProviderItem } from '../../type';
12
-
13
- const useStyles = createStyles(({ css, token }) => ({
14
- markdown: css`
15
- p {
16
- color: ${token.colorTextDescription} !important;
17
- }
18
- `,
19
- tip: css`
20
- font-size: 12px;
21
- color: ${token.colorTextDescription};
22
- `,
23
- }));
24
-
25
- const providerKey: GlobalLLMProviderKey = 'huggingface';
26
-
27
- // Same as OpenAIProvider, but replace API Key with HuggingFace Access Token
28
- export const useHuggingFaceProvider = (): ProviderItem => {
29
- const { t } = useTranslation('modelProvider');
30
- const { styles } = useStyles();
31
-
32
- return {
33
- ...HuggingFaceProviderCard,
34
- apiKeyItems: [
35
- {
36
- children: (
37
- <InputPassword
38
- autoComplete={'new-password'}
39
- placeholder={t(`${providerKey}.accessToken.placeholder`)}
40
- />
41
- ),
42
- desc: (
43
- <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
44
- {t(`${providerKey}.accessToken.desc`)}
45
- </Markdown>
46
- ),
47
- label: t(`${providerKey}.accessToken.title`),
48
- name: [KeyVaultsConfigKey, providerKey, LLMProviderApiTokenKey],
49
- },
50
- ],
51
- };
52
- };