@lobehub/chat 0.1.6

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 (149) 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 +20 -0
  29. package/README.md +147 -0
  30. package/locales/en_US/common.json +41 -0
  31. package/locales/en_US/setting.json +117 -0
  32. package/locales/zh_CN/common.json +41 -0
  33. package/locales/zh_CN/setting.json +117 -0
  34. package/next.config.mjs +32 -0
  35. package/package.json +140 -0
  36. package/public/next.svg +1 -0
  37. package/public/vercel.svg +1 -0
  38. package/scripts/genDefaultLocale.ts +18 -0
  39. package/scripts/genResources.ts +51 -0
  40. package/scripts/toc.ts +7 -0
  41. package/src/const/fetch.ts +1 -0
  42. package/src/const/modelTokens.ts +8 -0
  43. package/src/features/AvatarWithUpload/index.tsx +27 -0
  44. package/src/features/FolderPanel/index.tsx +55 -0
  45. package/src/features/SideBar/index.tsx +35 -0
  46. package/src/helpers/prompt.test.ts +36 -0
  47. package/src/helpers/prompt.ts +36 -0
  48. package/src/helpers/url.ts +17 -0
  49. package/src/layout/index.tsx +57 -0
  50. package/src/layout/style.ts +18 -0
  51. package/src/locales/create.ts +49 -0
  52. package/src/locales/default/common.ts +41 -0
  53. package/src/locales/default/setting.ts +117 -0
  54. package/src/locales/index.ts +5 -0
  55. package/src/locales/options.ts +19 -0
  56. package/src/locales/resources/en_US.ts +9 -0
  57. package/src/locales/resources/index.ts +13 -0
  58. package/src/locales/resources/zh_CN.ts +9 -0
  59. package/src/migrations/FromV0ToV1.ts +12 -0
  60. package/src/migrations/index.ts +13 -0
  61. package/src/pages/_app.page.tsx +13 -0
  62. package/src/pages/_document.page.tsx +70 -0
  63. package/src/pages/api/LangChainStream.ts +95 -0
  64. package/src/pages/api/chain.api.ts +17 -0
  65. package/src/pages/api/openai.api.ts +31 -0
  66. package/src/pages/chat/SessionList/Header.tsx +56 -0
  67. package/src/pages/chat/SessionList/List/SessionItem.tsx +90 -0
  68. package/src/pages/chat/SessionList/List/index.tsx +31 -0
  69. package/src/pages/chat/SessionList/List/style.ts +77 -0
  70. package/src/pages/chat/SessionList/index.tsx +18 -0
  71. package/src/pages/chat/[id]/Config/ConfigCell.tsx +68 -0
  72. package/src/pages/chat/[id]/Config/ReadMode.tsx +63 -0
  73. package/src/pages/chat/[id]/Config/index.tsx +79 -0
  74. package/src/pages/chat/[id]/Conversation/ChatList.tsx +36 -0
  75. package/src/pages/chat/[id]/Conversation/Input.tsx +61 -0
  76. package/src/pages/chat/[id]/Conversation/index.tsx +32 -0
  77. package/src/pages/chat/[id]/Header.tsx +86 -0
  78. package/src/pages/chat/[id]/edit/AgentConfig.tsx +95 -0
  79. package/src/pages/chat/[id]/edit/AgentMeta.tsx +117 -0
  80. package/src/pages/chat/[id]/edit/FormItem.tsx +26 -0
  81. package/src/pages/chat/[id]/edit/Prompt.tsx +68 -0
  82. package/src/pages/chat/[id]/edit/index.page.tsx +62 -0
  83. package/src/pages/chat/[id]/edit/style.ts +42 -0
  84. package/src/pages/chat/[id]/index.page.tsx +40 -0
  85. package/src/pages/chat/index.page.tsx +1 -0
  86. package/src/pages/chat/layout.tsx +51 -0
  87. package/src/pages/index.page.tsx +1 -0
  88. package/src/pages/setting/Header.tsx +27 -0
  89. package/src/pages/setting/SettingForm.tsx +299 -0
  90. package/src/pages/setting/SliderWithInput/index.tsx +40 -0
  91. package/src/pages/setting/ThemeSwatches/ThemeSwatchesNeutral.tsx +33 -0
  92. package/src/pages/setting/ThemeSwatches/ThemeSwatchesPrimary.tsx +33 -0
  93. package/src/pages/setting/ThemeSwatches/index.ts +2 -0
  94. package/src/pages/setting/index.page.tsx +41 -0
  95. package/src/prompts/agent.ts +65 -0
  96. package/src/services/chatModel.ts +34 -0
  97. package/src/services/langChain.ts +18 -0
  98. package/src/services/url.ts +8 -0
  99. package/src/store/middleware/createHashStorage.ts +49 -0
  100. package/src/store/session/index.ts +33 -0
  101. package/src/store/session/initialState.ts +11 -0
  102. package/src/store/session/selectors.ts +3 -0
  103. package/src/store/session/slices/agentConfig/action.ts +226 -0
  104. package/src/store/session/slices/agentConfig/index.ts +3 -0
  105. package/src/store/session/slices/agentConfig/initialState.ts +34 -0
  106. package/src/store/session/slices/agentConfig/selectors.ts +54 -0
  107. package/src/store/session/slices/chat/action.ts +210 -0
  108. package/src/store/session/slices/chat/index.ts +3 -0
  109. package/src/store/session/slices/chat/initialState.ts +12 -0
  110. package/src/store/session/slices/chat/messageReducer.test.ts +70 -0
  111. package/src/store/session/slices/chat/messageReducer.ts +84 -0
  112. package/src/store/session/slices/chat/selectors.ts +83 -0
  113. package/src/store/session/slices/session/action.ts +118 -0
  114. package/src/store/session/slices/session/index.ts +3 -0
  115. package/src/store/session/slices/session/initialState.ts +31 -0
  116. package/src/store/session/slices/session/reducers/session.test.ts +456 -0
  117. package/src/store/session/slices/session/reducers/session.ts +113 -0
  118. package/src/store/session/slices/session/selectors/chat.ts +4 -0
  119. package/src/store/session/slices/session/selectors/index.ts +20 -0
  120. package/src/store/session/slices/session/selectors/list.ts +65 -0
  121. package/src/store/session/store.ts +17 -0
  122. package/src/store/settings/action.ts +40 -0
  123. package/src/store/settings/index.ts +23 -0
  124. package/src/store/settings/initialState.ts +41 -0
  125. package/src/store/settings/selectors.ts +17 -0
  126. package/src/store/settings/store.ts +13 -0
  127. package/src/styles/antdOverride.ts +33 -0
  128. package/src/styles/global.ts +23 -0
  129. package/src/styles/index.ts +6 -0
  130. package/src/types/chatMessage.ts +46 -0
  131. package/src/types/exportConfig.ts +44 -0
  132. package/src/types/global.d.ts +14 -0
  133. package/src/types/i18next.d.ts +8 -0
  134. package/src/types/langchain.ts +34 -0
  135. package/src/types/llm.ts +49 -0
  136. package/src/types/locale.ts +1 -0
  137. package/src/types/meta.ts +26 -0
  138. package/src/types/openai.ts +62 -0
  139. package/src/types/session.ts +59 -0
  140. package/src/utils/VersionController.test.ts +90 -0
  141. package/src/utils/VersionController.ts +64 -0
  142. package/src/utils/compass.ts +94 -0
  143. package/src/utils/fetch.ts +132 -0
  144. package/src/utils/filter.test.ts +120 -0
  145. package/src/utils/filter.ts +29 -0
  146. package/src/utils/uploadFIle.ts +8 -0
  147. package/src/utils/uuid.ts +9 -0
  148. package/tsconfig.json +31 -0
  149. 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,41 @@
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
+ "autoGenerateTooltip": "Description of the autocomplete assistant based on prompts",
17
+ "cancel": "Cancel",
18
+ "close": "Close",
19
+ "confirmRemoveSessionItemAlert": "You are about to remove this agent. Once removed, it cannot be recovered. Please confirm your action.",
20
+ "defaultAgent": "Default Agent",
21
+ "edit": "Edit",
22
+ "editAgentProfile": "Edit Agent Profile",
23
+ "export": "Export",
24
+ "gpt-3.5-turbo": "GPT 3.5 Turbo",
25
+ "gpt-3.5-turbo-16k": "GPT 3.5 Turbo (16K)",
26
+ "gpt-4": "GPT 4",
27
+ "gpt-4-32k": "GPT 4 (32K)",
28
+ "modelConfig": "Model Configuration",
29
+ "modelTemperature": "Temperature",
30
+ "newAgent": "New Agent",
31
+ "noDescription": "No description",
32
+ "ok": "OK",
33
+ "profile": "Profile",
34
+ "reset": "Reset",
35
+ "searchAgentPlaceholder": "Search agents and conversations...",
36
+ "sessionSetting": "Session Setting",
37
+ "setting": "Setting",
38
+ "share": "Share",
39
+ "updateAgent": "Update Agent",
40
+ "updatePrompt": "Update Prompt"
41
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "danger": {
3
+ "clear": {
4
+ "action": "Clear Now",
5
+ "confirm": "Are you sure you want to clear all chat and settings data?",
6
+ "desc": "Clear all chat and settings data",
7
+ "title": "Clear All Data"
8
+ },
9
+ "reset": {
10
+ "action": "Reset Now",
11
+ "confirm": "Are you sure you want to reset all settings?",
12
+ "currentVersion": "Current Version",
13
+ "desc": "Reset all settings to default values",
14
+ "title": "Reset All Settings"
15
+ }
16
+ },
17
+ "header": "Settings",
18
+ "settingChat": {
19
+ "compressThreshold": {
20
+ "desc": "When the uncompressed chat history exceeds this value, it will be compressed",
21
+ "title": "Chat History Compression Threshold"
22
+ },
23
+ "enableCompressThreshold": {
24
+ "title": "Enable Chat History Compression Threshold"
25
+ },
26
+ "enableHistoryCount": {
27
+ "title": "Enable History Message Count Limit"
28
+ },
29
+ "historyCount": {
30
+ "desc": "Number of history messages to include in each request",
31
+ "title": "History Message Count"
32
+ },
33
+ "inputTemplate": {
34
+ "desc": "The latest user message will be filled into this template",
35
+ "title": "User Input Preprocessing"
36
+ },
37
+ "title": "Chat Settings"
38
+ },
39
+ "settingModel": {
40
+ "enableMaxTokens": {
41
+ "title": "Enable Single Reply Limit"
42
+ },
43
+ "frequencyPenalty": {
44
+ "desc": "The higher the value, the more likely it is to reduce repeated words",
45
+ "title": "Frequency Penalty"
46
+ },
47
+ "maxTokens": {
48
+ "desc": "Maximum number of tokens used in a single interaction",
49
+ "title": "Single Reply Limit"
50
+ },
51
+ "model": {
52
+ "desc": "ChatGPT Model",
53
+ "title": "Model"
54
+ },
55
+ "presencePenalty": {
56
+ "desc": "The higher the value, the more likely it is to expand to new topics",
57
+ "title": "Topic Freshness"
58
+ },
59
+ "temperature": {
60
+ "desc": "The higher the value, the more random the reply",
61
+ "title": "Randomness"
62
+ },
63
+ "title": "Model Settings",
64
+ "topP": {
65
+ "desc": "Similar to randomness, but do not change together with randomness",
66
+ "title": "Top-p Sampling"
67
+ }
68
+ },
69
+ "settingOpenAI": {
70
+ "endpoint": {
71
+ "desc": "Must include http(s)://, in addition to the default address",
72
+ "placeholder": "https://api.openai.com/v1",
73
+ "title": "API Proxy Endpoint"
74
+ },
75
+ "title": "OpenAI Settings",
76
+ "token": {
77
+ "desc": "Use your own OpenAI Key",
78
+ "placeholder": "OpenAI API Key",
79
+ "title": "API Key"
80
+ }
81
+ },
82
+ "settingSystem": {
83
+ "accessCode": {
84
+ "desc": "Encryption access is enabled by the administrator",
85
+ "placeholder": "Please enter the access password",
86
+ "title": "Access Password"
87
+ },
88
+ "title": "System Settings"
89
+ },
90
+ "settingTheme": {
91
+ "avatar": {
92
+ "title": "Avatar"
93
+ },
94
+ "fontSize": {
95
+ "desc": "Font size of chat content",
96
+ "title": "Font Size"
97
+ },
98
+ "lang": {
99
+ "title": "Language Settings"
100
+ },
101
+ "neutralColor": {
102
+ "desc": "Custom grayscale for different color biases",
103
+ "title": "Neutral Color"
104
+ },
105
+ "primaryColor": {
106
+ "desc": "Custom theme color",
107
+ "title": "Theme Color"
108
+ },
109
+ "themeMode": {
110
+ "auto": "Auto",
111
+ "dark": "Dark",
112
+ "light": "Light",
113
+ "title": "Theme"
114
+ },
115
+ "title": "Theme Settings"
116
+ }
117
+ }
@@ -0,0 +1,41 @@
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
+ "autoGenerateTooltip": "基于提示词自动补全助手描述",
17
+ "cancel": "取消",
18
+ "close": "关闭",
19
+ "confirmRemoveSessionItemAlert": "即将删除该助手,删除后该将无法找回,请确认你的操作",
20
+ "defaultAgent": "默认助手",
21
+ "edit": "编辑",
22
+ "editAgentProfile": "编辑助手信息",
23
+ "export": "导出",
24
+ "gpt-3.5-turbo": "GPT 3.5",
25
+ "gpt-3.5-turbo-16k": "GPT 3.5 (16K)",
26
+ "gpt-4": "GPT 4",
27
+ "gpt-4-32k": "GPT 4 (32K)",
28
+ "modelConfig": "模型配置",
29
+ "modelTemperature": "发散度",
30
+ "newAgent": "新建助手",
31
+ "noDescription": "暂无描述",
32
+ "ok": "确定",
33
+ "profile": "助手身份",
34
+ "reset": "重置",
35
+ "searchAgentPlaceholder": "搜索助手和对话...",
36
+ "sessionSetting": "会话设置",
37
+ "setting": "设置",
38
+ "share": "分享",
39
+ "updateAgent": "更新助理信息",
40
+ "updatePrompt": "更新提示词"
41
+ }
@@ -0,0 +1,117 @@
1
+ {
2
+ "danger": {
3
+ "clear": {
4
+ "action": "立即清除",
5
+ "confirm": "确认清除所有聊天、设置数据?",
6
+ "desc": "清除所有聊天、设置数据",
7
+ "title": "清除所有数据"
8
+ },
9
+ "reset": {
10
+ "action": "立即重置",
11
+ "confirm": "确认重置所有设置?",
12
+ "currentVersion": "当前版本",
13
+ "desc": "重置所有设置项回默认值",
14
+ "title": "重置所有设置"
15
+ }
16
+ },
17
+ "header": "设置",
18
+ "settingChat": {
19
+ "compressThreshold": {
20
+ "desc": "当未压缩的历史消息超过该值时,将进行压缩",
21
+ "title": "历史消息长度压缩阈值"
22
+ },
23
+ "enableCompressThreshold": {
24
+ "title": "是否开启历史消息长度压缩阈值"
25
+ },
26
+ "enableHistoryCount": {
27
+ "title": "是否开启携带的历史消息数限制"
28
+ },
29
+ "historyCount": {
30
+ "desc": "每次请求携带的历史消息数",
31
+ "title": "附带历史消息数"
32
+ },
33
+ "inputTemplate": {
34
+ "desc": "用户最新的一条消息会填充到此模板",
35
+ "title": "用户输入预处理"
36
+ },
37
+ "title": "聊天设置"
38
+ },
39
+ "settingModel": {
40
+ "enableMaxTokens": {
41
+ "title": "开启单次回复限制"
42
+ },
43
+ "frequencyPenalty": {
44
+ "desc": "值越大,越有可能降低重复字词",
45
+ "title": "频率惩罚度"
46
+ },
47
+ "maxTokens": {
48
+ "desc": "单次交互所用的最大 Token 数",
49
+ "title": "单次回复限制"
50
+ },
51
+ "model": {
52
+ "desc": "ChatGPT 模型",
53
+ "title": "模型"
54
+ },
55
+ "presencePenalty": {
56
+ "desc": "值越大,越有可能扩展到新话题",
57
+ "title": "话题新鲜度"
58
+ },
59
+ "temperature": {
60
+ "desc": "值越大,回复越随机",
61
+ "title": "随机性"
62
+ },
63
+ "title": "模型设置",
64
+ "topP": {
65
+ "desc": "与随机性类似,但不要和随机性一起更改",
66
+ "title": "核采样"
67
+ }
68
+ },
69
+ "settingOpenAI": {
70
+ "endpoint": {
71
+ "desc": "除默认地址外,必须包含 http(s)://",
72
+ "placeholder": "https://api.openai.com/v1",
73
+ "title": "接口代理地址"
74
+ },
75
+ "title": "OpenAI 设置",
76
+ "token": {
77
+ "desc": "使用自己的 OpenAI Key",
78
+ "placeholder": "OpenAI API Key",
79
+ "title": "API Key"
80
+ }
81
+ },
82
+ "settingSystem": {
83
+ "accessCode": {
84
+ "desc": "管理员已开启加密访问",
85
+ "placeholder": "请输入访问密码",
86
+ "title": "访问密码"
87
+ },
88
+ "title": "系统设置"
89
+ },
90
+ "settingTheme": {
91
+ "avatar": {
92
+ "title": "头像"
93
+ },
94
+ "fontSize": {
95
+ "desc": "聊天内容的字体大小",
96
+ "title": "字体大小"
97
+ },
98
+ "lang": {
99
+ "title": "语言设置"
100
+ },
101
+ "neutralColor": {
102
+ "desc": "不同色彩倾向的灰阶自定义",
103
+ "title": "中性色"
104
+ },
105
+ "primaryColor": {
106
+ "desc": "自定义主题色",
107
+ "title": "主题色"
108
+ },
109
+ "themeMode": {
110
+ "auto": "自动",
111
+ "dark": "深色",
112
+ "light": "浅色",
113
+ "title": "主题"
114
+ },
115
+ "title": "主题设置"
116
+ }
117
+ }
@@ -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,140 @@
1
+ {
2
+ "name": "@lobehub/chat",
3
+ "version": "0.1.6",
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": "npm run i18n:toc && lobe-i18n",
27
+ "i18n:toc": "ts-node --project ./tsconfig.json scripts/toc.ts",
28
+ "lint": "eslint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
29
+ "lint:md": "remark . --quiet --frail --output",
30
+ "lint:style": "stylelint \"{src,tests}/**/*.{js,jsx,ts,tsx}\" --fix",
31
+ "prepare": "husky install",
32
+ "prettier": "prettier -c --write \"**/**\"",
33
+ "release": "semantic-release",
34
+ "start": "next start",
35
+ "stylelint": "stylelint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
36
+ "test": "vitest --passWithNoTests",
37
+ "test:coverage": "vitest run --coverage --passWithNoTests",
38
+ "test:update": "vitest -u",
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
+ "consola": "^3",
111
+ "eslint": "^8",
112
+ "husky": "^8",
113
+ "i18next-browser-languagedetector": "^7",
114
+ "i18next-resources-for-ts": "^1",
115
+ "jsdom": "^22",
116
+ "lint-staged": "^13",
117
+ "next-pwa": "^5",
118
+ "node-fetch": "^3",
119
+ "postcss-styled-syntax": "^0.4",
120
+ "prettier": "^2",
121
+ "remark": "^14",
122
+ "remark-cli": "^11",
123
+ "semantic-release": "^21",
124
+ "semantic-release-config-gitmoji": "^1",
125
+ "stylelint": "^15",
126
+ "ts-node": "^10",
127
+ "typescript": "^5",
128
+ "vitest": "latest"
129
+ },
130
+ "peerDependencies": {
131
+ "antd": ">=5",
132
+ "antd-style": ">=3",
133
+ "react": ">=18",
134
+ "react-dom": ">=18"
135
+ },
136
+ "publishConfig": {
137
+ "access": "public",
138
+ "registry": "https://registry.npmjs.org"
139
+ }
140
+ }
@@ -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,18 @@
1
+ import { consola } from 'consola';
2
+ import { colors } from 'consola/utils';
3
+ import fs from 'node:fs';
4
+ import { resolve } from 'node:path';
5
+
6
+ import i18nConfig from '../.i18nrc';
7
+
8
+ export const genDefaultLocale = (input: string) => {
9
+ consola.info(`Default locale is ${i18nConfig.entryLocale}...`);
10
+ const resources = require(`../${input}/${i18nConfig.entryLocale}`);
11
+ const data = Object.entries(resources.default);
12
+ consola.start(`Generate default locale json, found ${data.length} namespaces...`);
13
+ for (const [ns, value] of data) {
14
+ const filepath = resolve(i18nConfig.output, i18nConfig.entryLocale, `${ns}.json`);
15
+ fs.writeFileSync(filepath, JSON.stringify(value, null, 2));
16
+ consola.success(colors.bgWhiteBright(colors.black(` ${ns} `)), colors.gray(filepath));
17
+ }
18
+ };