@lobehub/chat 1.0.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 (142) hide show
  1. package/.changelogrc.js +1 -0
  2. package/.commitlintrc.js +1 -0
  3. package/.editorconfig +16 -0
  4. package/.eslintignore +32 -0
  5. package/.eslintrc.js +6 -0
  6. package/.github/ISSUE_TEMPLATE/1_bug_report.yml +45 -0
  7. package/.github/ISSUE_TEMPLATE/2_feature_request.yml +21 -0
  8. package/.github/ISSUE_TEMPLATE/3_question.yml +15 -0
  9. package/.github/ISSUE_TEMPLATE/4_other.md +7 -0
  10. package/.github/PULL_REQUEST_TEMPLATE.md +17 -0
  11. package/.github/dependabot.yml +17 -0
  12. package/.github/workflows/auto-merge.yml +32 -0
  13. package/.github/workflows/contributor-help.yml +29 -0
  14. package/.github/workflows/issue-check-inactive.yml +22 -0
  15. package/.github/workflows/issue-close-require.yml +46 -0
  16. package/.github/workflows/issue-remove-inactive.yml +25 -0
  17. package/.github/workflows/release.yml +34 -0
  18. package/.github/workflows/test.yml +30 -0
  19. package/.gitpod.yml +3 -0
  20. package/.husky/commit-msg +4 -0
  21. package/.husky/pre-commit +5 -0
  22. package/.i18nrc.js +13 -0
  23. package/.prettierignore +63 -0
  24. package/.prettierrc.js +1 -0
  25. package/.releaserc.js +1 -0
  26. package/.remarkrc.js +1 -0
  27. package/.stylelintrc.js +8 -0
  28. package/CHANGELOG.md +80 -0
  29. package/README.md +147 -0
  30. package/locales/en_US/common.json +40 -0
  31. package/locales/en_US/setting.json +97 -0
  32. package/locales/zh_CN/common.json +40 -0
  33. package/locales/zh_CN/setting.json +98 -0
  34. package/next.config.mjs +32 -0
  35. package/package.json +138 -0
  36. package/public/next.svg +1 -0
  37. package/public/vercel.svg +1 -0
  38. package/scripts/genDefaultLocale.mjs +12 -0
  39. package/scripts/toc.mjs +40 -0
  40. package/src/const/fetch.ts +1 -0
  41. package/src/const/modelTokens.ts +8 -0
  42. package/src/features/FolderPanel/index.tsx +55 -0
  43. package/src/helpers/prompt.test.ts +36 -0
  44. package/src/helpers/prompt.ts +36 -0
  45. package/src/helpers/url.ts +17 -0
  46. package/src/layout/index.tsx +42 -0
  47. package/src/layout/style.ts +18 -0
  48. package/src/locales/create.ts +48 -0
  49. package/src/locales/default/common.ts +41 -0
  50. package/src/locales/default/setting.ts +97 -0
  51. package/src/locales/index.ts +5 -0
  52. package/src/locales/resources/en_US.ts +9 -0
  53. package/src/locales/resources/index.ts +7 -0
  54. package/src/locales/resources/zh_CN.ts +9 -0
  55. package/src/migrations/FromV0ToV1.ts +12 -0
  56. package/src/migrations/index.ts +13 -0
  57. package/src/pages/Sidebar.tsx +36 -0
  58. package/src/pages/_app.page.tsx +13 -0
  59. package/src/pages/_document.page.tsx +70 -0
  60. package/src/pages/api/LangChainStream.ts +95 -0
  61. package/src/pages/api/chain.api.ts +17 -0
  62. package/src/pages/api/openai.api.ts +31 -0
  63. package/src/pages/chat/SessionList/Header.tsx +56 -0
  64. package/src/pages/chat/SessionList/List/SessionItem.tsx +90 -0
  65. package/src/pages/chat/SessionList/List/index.tsx +31 -0
  66. package/src/pages/chat/SessionList/List/style.ts +77 -0
  67. package/src/pages/chat/SessionList/index.tsx +18 -0
  68. package/src/pages/chat/[id]/Config/ConfigCell.tsx +68 -0
  69. package/src/pages/chat/[id]/Config/ReadMode.tsx +63 -0
  70. package/src/pages/chat/[id]/Config/index.tsx +79 -0
  71. package/src/pages/chat/[id]/Conversation/ChatList.tsx +36 -0
  72. package/src/pages/chat/[id]/Conversation/Input.tsx +61 -0
  73. package/src/pages/chat/[id]/Conversation/index.tsx +32 -0
  74. package/src/pages/chat/[id]/Header.tsx +86 -0
  75. package/src/pages/chat/[id]/edit/AgentConfig.tsx +95 -0
  76. package/src/pages/chat/[id]/edit/AgentMeta.tsx +117 -0
  77. package/src/pages/chat/[id]/edit/FormItem.tsx +26 -0
  78. package/src/pages/chat/[id]/edit/Prompt.tsx +68 -0
  79. package/src/pages/chat/[id]/edit/index.page.tsx +62 -0
  80. package/src/pages/chat/[id]/edit/style.ts +42 -0
  81. package/src/pages/chat/[id]/index.page.tsx +40 -0
  82. package/src/pages/chat/index.page.tsx +1 -0
  83. package/src/pages/chat/layout.tsx +51 -0
  84. package/src/pages/index.page.tsx +1 -0
  85. package/src/pages/setting/Header.tsx +27 -0
  86. package/src/pages/setting/SettingForm.tsx +42 -0
  87. package/src/pages/setting/index.page.tsx +41 -0
  88. package/src/prompts/agent.ts +65 -0
  89. package/src/services/chatModel.ts +34 -0
  90. package/src/services/langChain.ts +18 -0
  91. package/src/services/url.ts +8 -0
  92. package/src/store/middleware/createHashStorage.ts +49 -0
  93. package/src/store/session/index.ts +33 -0
  94. package/src/store/session/initialState.ts +11 -0
  95. package/src/store/session/selectors.ts +3 -0
  96. package/src/store/session/slices/agentConfig/action.ts +226 -0
  97. package/src/store/session/slices/agentConfig/index.ts +3 -0
  98. package/src/store/session/slices/agentConfig/initialState.ts +34 -0
  99. package/src/store/session/slices/agentConfig/selectors.ts +54 -0
  100. package/src/store/session/slices/chat/action.ts +210 -0
  101. package/src/store/session/slices/chat/index.ts +3 -0
  102. package/src/store/session/slices/chat/initialState.ts +12 -0
  103. package/src/store/session/slices/chat/messageReducer.test.ts +70 -0
  104. package/src/store/session/slices/chat/messageReducer.ts +84 -0
  105. package/src/store/session/slices/chat/selectors.ts +83 -0
  106. package/src/store/session/slices/session/action.ts +118 -0
  107. package/src/store/session/slices/session/index.ts +3 -0
  108. package/src/store/session/slices/session/initialState.ts +31 -0
  109. package/src/store/session/slices/session/reducers/session.test.ts +456 -0
  110. package/src/store/session/slices/session/reducers/session.ts +113 -0
  111. package/src/store/session/slices/session/selectors/chat.ts +4 -0
  112. package/src/store/session/slices/session/selectors/index.ts +20 -0
  113. package/src/store/session/slices/session/selectors/list.ts +65 -0
  114. package/src/store/session/store.ts +17 -0
  115. package/src/store/settings/action.ts +31 -0
  116. package/src/store/settings/index.ts +23 -0
  117. package/src/store/settings/initialState.ts +25 -0
  118. package/src/store/settings/selectors.ts +9 -0
  119. package/src/store/settings/store.ts +13 -0
  120. package/src/styles/antdOverride.ts +29 -0
  121. package/src/styles/global.ts +23 -0
  122. package/src/styles/index.ts +6 -0
  123. package/src/types/chatMessage.ts +46 -0
  124. package/src/types/exportConfig.ts +23 -0
  125. package/src/types/global.d.ts +14 -0
  126. package/src/types/i18next.d.ts +8 -0
  127. package/src/types/langchain.ts +34 -0
  128. package/src/types/llm.ts +49 -0
  129. package/src/types/locale.ts +7 -0
  130. package/src/types/meta.ts +26 -0
  131. package/src/types/openai.ts +62 -0
  132. package/src/types/session.ts +59 -0
  133. package/src/utils/VersionController.test.ts +90 -0
  134. package/src/utils/VersionController.ts +64 -0
  135. package/src/utils/compass.ts +94 -0
  136. package/src/utils/fetch.ts +132 -0
  137. package/src/utils/filter.test.ts +120 -0
  138. package/src/utils/filter.ts +29 -0
  139. package/src/utils/uploadFIle.ts +8 -0
  140. package/src/utils/uuid.ts +9 -0
  141. package/tsconfig.json +26 -0
  142. package/vitest.config.ts +11 -0
package/README.md ADDED
@@ -0,0 +1,147 @@
1
+ <a name="readme-top"></a>
2
+
3
+ <div align="center">
4
+
5
+ <img height="120" src="https://npm.elemecdn.com/@lobehub/assets-logo@1.0.0/assets/logo-3d.webp">
6
+ <img height="120" src="https://gw.alipayobjects.com/zos/kitchen/qJ3l3EPsdW/split.svg">
7
+ <img height="120" src="https://npm.elemecdn.com/fluentui-emoji/icons/modern/robot.svg">
8
+
9
+ <h1>Lobe Chat</h1>
10
+
11
+ Lobe Chat is an open-source chatbot client using LangChain
12
+
13
+ Typescript and Next.js
14
+
15
+ [Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
16
+
17
+ <!-- SHIELD GROUP -->
18
+
19
+ [![release][release-shield]][release-url]
20
+ [![releaseDate][release-date-shield]][release-date-url]
21
+ [![ciTest][ci-test-shield]][ci-test-url]
22
+ [![ciRelease][ci-release-shield]][ci-release-url] <br/>
23
+ [![contributors][contributors-shield]][contributors-url]
24
+ [![forks][forks-shield]][forks-url]
25
+ [![stargazers][stargazers-shield]][stargazers-url]
26
+ [![issues][issues-shield]][issues-url]
27
+
28
+ ![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)
29
+
30
+ </div>
31
+
32
+ <details>
33
+ <summary><kbd>Table of contents</kbd></summary>
34
+
35
+ #### TOC
36
+
37
+ - [⌨️ Local Development](#️-local-development)
38
+ - [🤝 Contributing](#-contributing)
39
+
40
+ ####
41
+
42
+ </details>
43
+
44
+ ## ⌨️ Local Development
45
+
46
+ You can use Gitpod for online development:
47
+
48
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)][gitpod-url]
49
+
50
+ Or clone it for local development:
51
+
52
+ ```bash
53
+ $ git clone https://github.com/lobehub/lobe-chat.git
54
+ $ cd lobe-chat
55
+ $ pnpm install
56
+ $ pnpm start
57
+ ```
58
+
59
+ <div align="right">
60
+
61
+ [![][back-to-top]](#readme-top)
62
+
63
+ </div>
64
+
65
+ ## 🤝 Contributing
66
+
67
+ <!-- CONTRIBUTION GROUP -->
68
+
69
+ > 📊 Total: <kbd>**4**</kbd>
70
+
71
+ <a href="https://github.com/canisminor1990" title="canisminor1990">
72
+ <img src="https://avatars.githubusercontent.com/u/17870709?v=4" width="50" />
73
+ </a>
74
+ <a href="https://github.com/arvinxx" title="arvinxx">
75
+ <img src="https://avatars.githubusercontent.com/u/28616219?v=4" width="50" />
76
+ </a>
77
+ <a href="https://github.com/apps/dependabot" title="dependabot[bot]">
78
+ <img src="https://avatars.githubusercontent.com/in/29110?v=4" width="50" />
79
+ </a>
80
+ <a href="https://github.com/actions-user" title="actions-user">
81
+ <img src="https://avatars.githubusercontent.com/u/65916846?v=4" width="50" />
82
+ </a>
83
+
84
+ <!-- CONTRIBUTION END -->
85
+
86
+ <div align="right">
87
+
88
+ [![][back-to-top]](#readme-top)
89
+
90
+ </div>
91
+
92
+ ---
93
+
94
+ #### 📝 License
95
+
96
+ Copyright © 2023 [LobeHub][profile-url]. <br />
97
+ This project is [MIT](./LICENSE) licensed.
98
+
99
+ <!-- LINK GROUP -->
100
+
101
+ [profile-url]: https://github.com/lobehub
102
+ [issues-url]: https://github.com/lobehub/lobe-chat/issues/new/choose
103
+ [gitpod-url]: https://gitpod.io/#https://github.com/lobehub/lobe-chat
104
+
105
+ <!-- SHIELD LINK GROUP -->
106
+
107
+ [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
108
+
109
+ <!-- release -->
110
+
111
+ [release-shield]: https://img.shields.io/npm/v/@lobehub/chat?label=%F0%9F%A4%AF%20NPM
112
+ [release-url]: https://www.npmjs.com/package/@lobehub/chat
113
+
114
+ <!-- releaseDate -->
115
+
116
+ [release-date-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?style=flat
117
+ [release-date-url]: https://github.com/lobehub/lobe-chat/releases
118
+
119
+ <!-- ciTest -->
120
+
121
+ [ci-test-shield]: https://github.com/lobehub/lobe-chat/workflows/Test%20CI/badge.svg
122
+ [ci-test-url]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
123
+
124
+ <!-- ciRelease -->
125
+
126
+ [ci-release-shield]: https://github.com/lobehub/lobe-chat/workflows/Release%20CI/badge.svg
127
+ [ci-release-url]: https://github.com/lobehub/lobe-chat/actions?query=workflow%3ARelease%20CI
128
+
129
+ <!-- contributors -->
130
+
131
+ [contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-chat.svg?style=flat
132
+ [contributors-url]: https://github.com/lobehub/lobe-chat/graphs/contributors
133
+
134
+ <!-- forks -->
135
+
136
+ [forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-chat.svg?style=flat
137
+ [forks-url]: https://github.com/lobehub/lobe-chat/network/members
138
+
139
+ <!-- stargazers -->
140
+
141
+ [stargazers-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat.svg?style=flat
142
+ [stargazers-url]: https://github.com/lobehub/lobe-chat/stargazers
143
+
144
+ <!-- issues -->
145
+
146
+ [issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
147
+ [issues-url]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
@@ -0,0 +1,40 @@
1
+ {
2
+ "advanceSettings": "Advanced Settings",
3
+ "agentAvatar": "Avatar",
4
+ "agentDescription": "Description",
5
+ "agentDescriptionPlaceholder": "Please enter a description",
6
+ "agentModel": "Model",
7
+ "agentName": "Name",
8
+ "agentNamePlaceholder": "Please enter a name",
9
+ "agentProfile": "Agent Profile",
10
+ "agentPrompt": "AI Prompt",
11
+ "agentPromptPlaceholder": "Please enter AI prompt",
12
+ "agentTag": "Tag",
13
+ "agentTagPlaceholder": "Please enter a tag",
14
+ "archive": "Archive",
15
+ "autoGenerate": "Auto Generate",
16
+ "cancel": "Cancel",
17
+ "close": "Close",
18
+ "confirmRemoveSessionItemAlert": "You are about to remove this agent. Once removed, it cannot be recovered. Please confirm your action.",
19
+ "defaultAgent": "Default Agent",
20
+ "edit": "Edit",
21
+ "editAgentProfile": "Edit Agent Profile",
22
+ "export": "Export",
23
+ "gpt-3.5-turbo": "GPT 3.5 Turbo",
24
+ "gpt-3.5-turbo-16k": "GPT 3.5 Turbo (16K)",
25
+ "gpt-4": "GPT 4",
26
+ "gpt-4-32k": "GPT 4 (32K)",
27
+ "modelConfig": "Model Configuration",
28
+ "modelTemperature": "Temperature",
29
+ "newAgent": "New Agent",
30
+ "noDescription": "No description",
31
+ "ok": "OK",
32
+ "profile": "Profile",
33
+ "reset": "Reset",
34
+ "searchAgentPlaceholder": "Search agents and conversations...",
35
+ "sessionSetting": "Session Setting",
36
+ "setting": "Setting",
37
+ "share": "Share",
38
+ "updateAgent": "Update Agent",
39
+ "updatePrompt": "Update Prompt"
40
+ }
@@ -0,0 +1,97 @@
1
+ {
2
+ "danger": {
3
+ "reset": {
4
+ "title": "Reset All Settings",
5
+ "desc": "Reset all settings to default values",
6
+ "action": "Reset Now",
7
+ "confirm": "Confirm reset all settings?",
8
+ "currentVersion": "Current Version"
9
+ },
10
+ "clear": {
11
+ "title": "Clear All Data",
12
+ "desc": "Clear all chat and settings data",
13
+ "action": "Clear Now",
14
+ "confirm": "Confirm clear all chat and settings data?"
15
+ }
16
+ },
17
+ "header": "Settings",
18
+ "settingChat": {
19
+ "title": "Chat Settings",
20
+ "inputTemplate": {
21
+ "title": "User Input Template",
22
+ "desc": "The latest user message will be filled into this template"
23
+ },
24
+ "compressThreshold": {
25
+ "title": "History Message Length Compression Threshold",
26
+ "desc": "When the uncompressed history message exceeds this value, it will be compressed"
27
+ },
28
+ "historyCount": {
29
+ "title": "Number of History Messages",
30
+ "desc": "Number of history messages carried in each request"
31
+ },
32
+ "maxTokens": {
33
+ "title": "Max Tokens per Response",
34
+ "desc": "The maximum number of tokens used for each interaction"
35
+ },
36
+ "sendKey": {
37
+ "title": "Send Key"
38
+ }
39
+ },
40
+ "settingModel": {
41
+ "title": "Model Settings",
42
+ "model": {
43
+ "title": "Model"
44
+ },
45
+ "temperature": {
46
+ "title": "Randomness (temperature)",
47
+ "desc": "The higher the value, the more random the response"
48
+ },
49
+ "topP": {
50
+ "title": "Nucleus Sampling (top_p)",
51
+ "desc": "Similar to randomness, but do not change it together with randomness"
52
+ },
53
+ "presencePenalty": {
54
+ "title": "Topic Freshness (presence_penalty)",
55
+ "desc": "The higher the value, the more likely it is to expand to new topics"
56
+ },
57
+ "frequencyPenalty": {
58
+ "title": "Frequency Penalty (frequency_penalty)",
59
+ "desc": "The higher the value, the more likely it is to reduce repeated words"
60
+ }
61
+ },
62
+ "settingOpenAI": {
63
+ "title": "OpenAI Settings",
64
+ "token": {
65
+ "title": "API Key",
66
+ "desc": "Use your own key to bypass password access restrictions",
67
+ "placeholder": "OpenAI API Key"
68
+ },
69
+ "endpoint": {
70
+ "title": "API Endpoint",
71
+ "desc": "In addition to the default address, it must include http(s)://"
72
+ }
73
+ },
74
+ "settingSystem": {
75
+ "title": "System Settings",
76
+ "accessCode": {
77
+ "title": "Access Code",
78
+ "desc": "Encryption access has been enabled by the administrator",
79
+ "placeholder": "Please enter the access code"
80
+ }
81
+ },
82
+ "settingTheme": {
83
+ "title": "Theme Settings",
84
+ "avatar": {
85
+ "title": "Avatar",
86
+ "desc": "Supports URL / Base64 / Emoji"
87
+ },
88
+ "fontSize": {
89
+ "title": "Font Size",
90
+ "desc": "Font size of chat content"
91
+ },
92
+ "lang": {
93
+ "name": "Language Settings",
94
+ "all": "All Languages"
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "advanceSettings": "高级设置",
3
+ "agentAvatar": "头像",
4
+ "agentDescription": "描述",
5
+ "agentDescriptionPlaceholder": "请输入描述",
6
+ "agentModel": "模型",
7
+ "agentName": "名称",
8
+ "agentNamePlaceholder": "请输入名称",
9
+ "agentProfile": "助手信息",
10
+ "agentPrompt": "提示词",
11
+ "agentPromptPlaceholder": "请输入 AI 提示词",
12
+ "agentTag": "标签",
13
+ "agentTagPlaceholder": "请输入标签",
14
+ "archive": "归档",
15
+ "autoGenerate": "自动补全",
16
+ "cancel": "取消",
17
+ "close": "关闭",
18
+ "confirmRemoveSessionItemAlert": "即将删除该助手,删除后该将无法找回,请确认你的操作",
19
+ "defaultAgent": "默认助手",
20
+ "edit": "编辑",
21
+ "editAgentProfile": "编辑助手信息",
22
+ "export": "导出",
23
+ "gpt-3.5-turbo": "GPT 3.5",
24
+ "gpt-3.5-turbo-16k": "GPT 3.5 (16K)",
25
+ "gpt-4": "GPT 4",
26
+ "gpt-4-32k": "GPT 4 (32K)",
27
+ "modelConfig": "模型配置",
28
+ "modelTemperature": "发散度",
29
+ "newAgent": "新建助手",
30
+ "noDescription": "暂无描述",
31
+ "ok": "确定",
32
+ "profile": "身份卡",
33
+ "reset": "重置",
34
+ "searchAgentPlaceholder": "搜索助手和对话...",
35
+ "sessionSetting": "会话设置",
36
+ "setting": "设置",
37
+ "share": "分享",
38
+ "updateAgent": "更新助理信息",
39
+ "updatePrompt": "更新提示词"
40
+ }
@@ -0,0 +1,98 @@
1
+ {
2
+ "danger": {
3
+ "reset": {
4
+ "title": "重置所有设置",
5
+ "desc": "重置所有设置项回默认值",
6
+ "action": "立即重置",
7
+ "confirm": "确认重置所有设置?",
8
+ "currentVersion": "当前版本"
9
+ },
10
+ "clear": {
11
+ "title": "清除所有数据",
12
+ "desc": "清除所有聊天、设置数据",
13
+ "action": "立即清除",
14
+ "confirm": "确认清除所有聊天、设置数据?"
15
+ }
16
+ },
17
+
18
+ "header": "设置",
19
+ "settingChat": {
20
+ "title": "聊天设置",
21
+ "inputTemplate": {
22
+ "title": "用户输入预处理",
23
+ "desc": "用户最新的一条消息会填充到此模板"
24
+ },
25
+ "compressThreshold": {
26
+ "title": "历史消息长度压缩阈值",
27
+ "desc": "当未压缩的历史消息超过该值时,将进行压缩"
28
+ },
29
+ "historyCount": {
30
+ "title": "附带历史消息数",
31
+ "desc": "每次请求携带的历史消息数"
32
+ },
33
+ "maxTokens": {
34
+ "title": "单次回复限制 (max_tokens)",
35
+ "desc": "单次交互所用的最大 Token 数"
36
+ },
37
+ "sendKey": {
38
+ "title": "发送键"
39
+ }
40
+ },
41
+ "settingModel": {
42
+ "title": "模型设置",
43
+ "model": {
44
+ "title": "模型"
45
+ },
46
+ "temperature": {
47
+ "title": "随机性 (temperature)",
48
+ "desc": "值越大,回复越随机"
49
+ },
50
+ "topP": {
51
+ "title": "核采样 (top_p)",
52
+ "desc": "与随机性类似,但不要和随机性一起更改"
53
+ },
54
+ "presencePenalty": {
55
+ "title": "话题新鲜度 (presence_penalty)",
56
+ "desc": "值越大,越有可能扩展到新话题"
57
+ },
58
+ "frequencyPenalty": {
59
+ "title": "频率惩罚度 (frequency_penalty)",
60
+ "desc": "值越大,越有可能降低重复字词"
61
+ }
62
+ },
63
+ "settingOpenAI": {
64
+ "title": "OpenAI 设置",
65
+ "token": {
66
+ "title": "API Key",
67
+ "desc": "使用自己的 Key 可绕过密码访问限制",
68
+ "placeholder": "OpenAI API Key"
69
+ },
70
+ "endpoint": {
71
+ "title": "接口地址",
72
+ "desc": "除默认地址外,必须包含 http(s)://"
73
+ }
74
+ },
75
+ "settingSystem": {
76
+ "title": "系统设置",
77
+ "accessCode": {
78
+ "title": "访问密码",
79
+ "desc": "管理员已开启加密访问",
80
+ "placeholder": "请输入访问密码"
81
+ }
82
+ },
83
+ "settingTheme": {
84
+ "title": "主题设置",
85
+ "avatar": {
86
+ "title": "头像",
87
+ "desc": "支持 URL / Base64 / Emoji 表情符号"
88
+ },
89
+ "fontSize": {
90
+ "title": "字体大小",
91
+ "desc": "聊天内容的字体大小"
92
+ },
93
+ "lang": {
94
+ "name": "语言设置",
95
+ "all": "所有语言"
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,32 @@
1
+ const API_END_PORT_URL = process.env.API_END_PORT_URL || '';
2
+
3
+ /** @type {import('next').NextConfig} */
4
+ const nextConfig = {
5
+ reactStrictMode: true,
6
+ pageExtensions: ['page.tsx', 'api.ts'],
7
+ transpilePackages: ['@lobehub/ui', 'antd-style'],
8
+
9
+ webpack(config) {
10
+ config.experiments = {
11
+ asyncWebAssembly: true,
12
+ layers: true,
13
+ };
14
+
15
+ return config;
16
+ },
17
+
18
+ async rewrites() {
19
+ return [
20
+ {
21
+ source: '/api/openai-dev',
22
+ destination: `${API_END_PORT_URL}/api/openai`,
23
+ },
24
+ {
25
+ source: '/api/chain-dev',
26
+ destination: `${API_END_PORT_URL}/api/chain`,
27
+ },
28
+ ];
29
+ },
30
+ };
31
+
32
+ export default nextConfig;
package/package.json ADDED
@@ -0,0 +1,138 @@
1
+ {
2
+ "name": "@lobehub/chat",
3
+ "version": "1.0.0",
4
+ "description": "Lobe Chat is an open-source chatbot client using LangChain, Typescript and Next.js",
5
+ "keywords": [
6
+ "chatbot",
7
+ "ChatGPT",
8
+ "LangChain",
9
+ "typescript",
10
+ "Next.js"
11
+ ],
12
+ "homepage": "https://github.com/lobehub/lobe-chat",
13
+ "bugs": {
14
+ "url": "https://github.com/lobehub/lobe-chat/issues/new"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/lobehub/lobe-chat.git"
19
+ },
20
+ "license": "MIT",
21
+ "author": "LobeHub <i@lobehub.com>",
22
+ "sideEffects": false,
23
+ "scripts": {
24
+ "build": "next build",
25
+ "dev": "next dev -p 3010",
26
+ "i18n": "lobe-i18n",
27
+ "lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
28
+ "lint:md": "remark . --quiet --frail --output",
29
+ "lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
30
+ "prepare": "husky install",
31
+ "prettier": "prettier -c --write \"**/**\"",
32
+ "release": "semantic-release",
33
+ "start": "next start",
34
+ "stylelint": "stylelint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
35
+ "test": "vitest --passWithNoTests",
36
+ "test:coverage": "vitest run --coverage --passWithNoTests",
37
+ "test:update": "vitest -u",
38
+ "toc": "node scripts/toc.mjs",
39
+ "type-check": "tsc --noEmit"
40
+ },
41
+ "lint-staged": {
42
+ "*.md": [
43
+ "remark --quiet --output --",
44
+ "prettier --write --no-error-on-unmatched-pattern"
45
+ ],
46
+ "*.json": [
47
+ "prettier --write --no-error-on-unmatched-pattern"
48
+ ],
49
+ "*.{js,jsx}": [
50
+ "prettier --write",
51
+ "stylelint --fix",
52
+ "eslint --fix"
53
+ ],
54
+ "*.{ts,tsx}": [
55
+ "prettier --parser=typescript --write",
56
+ "stylelint --fix",
57
+ "eslint --fix"
58
+ ]
59
+ },
60
+ "dependencies": {
61
+ "@ant-design/colors": "^7",
62
+ "@ant-design/icons": "^5",
63
+ "@commitlint/cli": "^17",
64
+ "@lobehub/ui": "^1",
65
+ "@vercel/analytics": "^1",
66
+ "ahooks": "^3",
67
+ "ai": "^2",
68
+ "antd": "^5",
69
+ "antd-style": "^3",
70
+ "brotli-wasm": "^1",
71
+ "chroma-js": "^2",
72
+ "fast-deep-equal": "^3",
73
+ "gpt-tokenizer": "^2",
74
+ "i18next": "^23",
75
+ "immer": "^10",
76
+ "langchain": "latest",
77
+ "lodash-es": "^4",
78
+ "lucide-react": "latest",
79
+ "nanoid": "^4",
80
+ "next": "13.4.7",
81
+ "openai-edge": "^1",
82
+ "polished": "^4",
83
+ "react": "^18",
84
+ "react-dom": "^18",
85
+ "react-hotkeys-hook": "^4",
86
+ "react-i18next": "^13",
87
+ "react-layout-kit": "^1",
88
+ "swr": "^2",
89
+ "ts-md5": "^1",
90
+ "zustand": "^4",
91
+ "zustand-utils": "^1"
92
+ },
93
+ "devDependencies": {
94
+ "@commitlint/cli": "^17",
95
+ "@lobehub/i18n-cli": "latest",
96
+ "@lobehub/lint": "latest",
97
+ "@next/eslint-plugin-next": "^13",
98
+ "@testing-library/jest-dom": "^5",
99
+ "@testing-library/react": "^14",
100
+ "@types/chroma-js": "^2",
101
+ "@types/lodash-es": "^4",
102
+ "@types/node": "^20",
103
+ "@types/react": "^18",
104
+ "@types/react-dom": "^18",
105
+ "@types/testing-library__jest-dom": "^5",
106
+ "@types/uuid": "^9",
107
+ "@umijs/lint": "^4",
108
+ "@vitest/coverage-v8": "latest",
109
+ "commitlint": "^17",
110
+ "eslint": "^8",
111
+ "husky": "^8",
112
+ "i18next-browser-languagedetector": "^7",
113
+ "i18next-resources-for-ts": "^1",
114
+ "jsdom": "^22",
115
+ "lint-staged": "^13",
116
+ "next-pwa": "^5",
117
+ "node-fetch": "^3",
118
+ "postcss-styled-syntax": "^0.4",
119
+ "prettier": "^2",
120
+ "remark": "^14",
121
+ "remark-cli": "^11",
122
+ "semantic-release": "^21",
123
+ "semantic-release-config-gitmoji": "^1",
124
+ "stylelint": "^15",
125
+ "typescript": "^5",
126
+ "vitest": "latest"
127
+ },
128
+ "peerDependencies": {
129
+ "antd": ">=5",
130
+ "antd-style": ">=3",
131
+ "react": ">=18",
132
+ "react-dom": ">=18"
133
+ },
134
+ "publishConfig": {
135
+ "access": "public",
136
+ "registry": "https://registry.npmjs.org"
137
+ }
138
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
@@ -0,0 +1,12 @@
1
+ import fs from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+
4
+ import i18nConfig from '../.i18nrc.js';
5
+ import resources from '../src/locales/resources/zh_CN.ts';
6
+
7
+ for (const [ns, value] of Object.entries(resources)) {
8
+ fs.writeFileSync(
9
+ resolve(i18nConfig.output, i18nConfig.entryLocale, `${ns}.json`),
10
+ JSON.stringify(value, null, 2),
11
+ );
12
+ }
@@ -0,0 +1,40 @@
1
+ import { tocForResources } from 'i18next-resources-for-ts';
2
+ import fs from 'node:fs';
3
+ import { resolve } from 'node:path';
4
+
5
+ import i18nConfig from '../.i18nrc.js';
6
+
7
+ const locales = [i18nConfig.entryLocale, ...i18nConfig.outputLocales];
8
+
9
+ const RES_OUTPUT = 'src/locales/resources';
10
+
11
+ let index = '';
12
+ let indexObj = '';
13
+ locales.forEach((locale) => {
14
+ const files = fs
15
+ .readdirSync(resolve(i18nConfig.output, locale))
16
+ .filter((name) => name.includes('.json'));
17
+ index += `import ${locale} from "./${locale}";\n`;
18
+ indexObj += ` "${locale.replace('_', '-')}": ${locale},\n`;
19
+ const ns = [];
20
+ files.forEach((file) => {
21
+ ns.push({
22
+ name: file.replace('.json', ''),
23
+ path: resolve(i18nConfig.output, locale, file),
24
+ });
25
+ });
26
+ let toc = tocForResources(ns, resolve(RES_OUTPUT)).replaceAll('\\', '/');
27
+ if (locale === i18nConfig.entryLocale) {
28
+ toc = toc.replaceAll('.json', '').replaceAll('../../../locales/zh_CN', '../default');
29
+ }
30
+ fs.writeFileSync(resolve(RES_OUTPUT, `${locale}.ts`), toc);
31
+ });
32
+
33
+ fs.writeFileSync(
34
+ resolve(RES_OUTPUT, `index.ts`),
35
+ `${index}
36
+
37
+ export default {
38
+ ${indexObj}};
39
+ `,
40
+ );
@@ -0,0 +1 @@
1
+ export const OPENAI_SERVICE_ERROR_CODE = 555;
@@ -0,0 +1,8 @@
1
+ import { LanguageModel } from '@/types/llm';
2
+
3
+ export const ModelTokens: Record<LanguageModel, number> = {
4
+ [LanguageModel.GPT3_5]: 4096,
5
+ [LanguageModel.GPT3_5_16K]: 4096 * 4,
6
+ [LanguageModel.GPT4]: 8196,
7
+ [LanguageModel.GPT4_32K]: 8196 * 4,
8
+ };