@lobehub/chat 0.105.2 → 0.107.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.
- package/CHANGELOG.md +50 -0
- package/README.md +18 -0
- package/README.zh-CN.md +18 -0
- package/docs/Environment-Variable.md +4 -2
- package/docs/Environment-Variable.zh-CN.md +4 -2
- package/locales/en_US/common.json +19 -0
- package/locales/en_US/migration.json +45 -0
- package/locales/en_US/setting.json +7 -7
- package/locales/ja_JP/common.json +19 -0
- package/locales/ja_JP/migration.json +45 -0
- package/locales/ja_JP/setting.json +2 -2
- package/locales/ko_KR/common.json +19 -0
- package/locales/ko_KR/migration.json +45 -0
- package/locales/ko_KR/setting.json +2 -2
- package/locales/ru_RU/common.json +19 -0
- package/locales/ru_RU/migration.json +45 -0
- package/locales/ru_RU/setting.json +2 -2
- package/locales/zh_CN/common.json +19 -0
- package/locales/zh_CN/migration.json +45 -0
- package/locales/zh_CN/setting.json +1 -1
- package/locales/zh_TW/common.json +19 -0
- package/locales/zh_TW/migration.json +45 -0
- package/locales/zh_TW/setting.json +2 -2
- package/package.json +2 -1
- package/src/app/api/openai/chat/createChatCompletion.test.ts +4 -4
- package/src/app/api/openai/chat/createChatCompletion.ts +4 -10
- package/src/app/api/openai/createBizOpenAI/index.ts +1 -1
- package/src/app/api/openai/errorResponse.test.ts +1 -1
- package/src/app/chat/(desktop)/features/ChatInput/Footer/index.tsx +2 -1
- package/src/app/chat/(mobile)/features/ChatInput/SendButton.tsx +2 -2
- package/src/app/chat/features/ChatHeader/ShareButton/Inner.tsx +2 -5
- package/src/app/chat/features/ChatHeader/ShareButton/index.tsx +2 -2
- package/src/app/chat/features/ChatInput/ActionBar/Clear.tsx +2 -2
- package/src/app/chat/features/ChatInput/ActionBar/ModelSwitch.tsx +1 -1
- package/src/app/chat/features/ChatInput/ActionBar/Token/TokenTag.tsx +8 -2
- package/src/app/chat/features/ChatInput/InputAreaInner/index.tsx +2 -2
- package/src/app/chat/features/ChatInput/STT/index.tsx +2 -2
- package/src/app/chat/features/ChatInput/Topic/index.tsx +2 -2
- package/src/app/chat/features/ChatInput/useSend.ts +3 -3
- package/src/app/chat/features/Conversation/ChatList/Actions/index.ts +2 -2
- package/src/app/chat/features/Conversation/ChatList/Error/ApiKeyForm.tsx +2 -2
- package/src/app/chat/features/Conversation/ChatList/Error/InvalidAccess.tsx +2 -2
- package/src/app/chat/features/Conversation/ChatList/Error/Plugin/PluginSettings.tsx +2 -2
- package/src/app/chat/features/Conversation/ChatList/Extras/Assistant.test.tsx +4 -4
- package/src/app/chat/features/Conversation/ChatList/Extras/Assistant.tsx +30 -31
- package/src/app/chat/features/Conversation/ChatList/Extras/TTS.tsx +2 -2
- package/src/app/chat/features/Conversation/ChatList/Extras/Translate.tsx +2 -2
- package/src/app/chat/features/Conversation/ChatList/Extras/User.tsx +8 -5
- package/src/app/chat/features/Conversation/ChatList/Extras/index.ts +3 -3
- package/src/app/chat/features/Conversation/ChatList/Extras/type.ts +5 -0
- package/src/app/chat/features/Conversation/ChatList/Messages/Assistant.tsx +10 -6
- package/src/app/chat/features/Conversation/ChatList/Messages/Default.tsx +7 -3
- package/src/app/chat/features/Conversation/ChatList/Messages/Function.tsx +7 -6
- package/src/app/chat/features/Conversation/ChatList/Messages/index.ts +7 -7
- package/src/app/chat/features/Conversation/ChatList/Plugins/Render/StandaloneType/Iframe.tsx +6 -6
- package/src/app/chat/features/Conversation/ChatList/index.tsx +16 -24
- package/src/app/chat/features/Conversation/ScrollAnchor/index.tsx +2 -2
- package/src/app/chat/features/Conversation/index.tsx +3 -3
- package/src/app/chat/features/Conversation/useInitConversation.ts +43 -0
- package/src/app/chat/features/Migration/ExportConfigButton.tsx +33 -0
- package/src/app/chat/features/Migration/Failed.tsx +115 -0
- package/src/app/chat/features/Migration/Modal.tsx +80 -0
- package/src/app/chat/features/Migration/Start.tsx +106 -0
- package/src/app/chat/features/Migration/UpgradeButton.tsx +74 -0
- package/src/app/chat/features/Migration/const.ts +15 -0
- package/src/app/chat/features/Migration/index.tsx +44 -0
- package/src/app/chat/features/SessionListContent/DefaultMode.tsx +54 -0
- package/src/app/chat/features/SessionListContent/List/Item/Actions.tsx +5 -4
- package/src/app/chat/features/SessionListContent/List/Item/index.tsx +22 -28
- package/src/app/chat/features/SessionListContent/SearchMode.tsx +15 -0
- package/src/app/chat/features/SessionListContent/index.tsx +4 -44
- package/src/app/chat/features/SessionSearchBar/index.tsx +11 -3
- package/src/app/chat/features/TopicListContent/Header.tsx +4 -4
- package/src/app/chat/features/TopicListContent/Topic/TopicContent.tsx +11 -9
- package/src/app/chat/features/TopicListContent/Topic/TopicItem.tsx +15 -13
- package/src/app/chat/features/TopicListContent/Topic/index.tsx +9 -16
- package/src/app/chat/features/TopicListContent/TopicSearchBar/index.tsx +13 -4
- package/src/app/chat/features/TopicListContent/index.tsx +1 -2
- package/src/app/chat/page.tsx +6 -1
- package/src/app/chat/settings/features/HeaderContent.tsx +3 -3
- package/src/app/home/Redirect.tsx +13 -7
- package/src/app/settings/(mobile)/features/ExtraList.tsx +12 -4
- package/src/app/settings/common/Common.tsx +16 -4
- package/src/app/welcome/features/Banner/index.tsx +9 -10
- package/src/chains/summaryTitle.ts +5 -2
- package/src/components/DataStyleModal/index.tsx +64 -0
- package/src/config/client.ts +5 -0
- package/src/const/session.ts +21 -0
- package/src/const/settings.ts +1 -1
- package/src/database/core/__tests__/db.test.ts +8 -5
- package/src/database/core/__tests__/model.test.ts +3 -3
- package/src/database/core/db.ts +38 -10
- package/src/database/core/index.ts +1 -0
- package/src/database/core/model.ts +121 -10
- package/src/database/core/schemas.ts +22 -0
- package/src/database/core/types/db.ts +13 -0
- package/src/database/models/__DEBUG.ts +119 -0
- package/src/database/models/{file.test.ts → __tests__/file.test.ts} +19 -6
- package/src/database/models/__tests__/message.test.ts +314 -0
- package/src/database/models/__tests__/session.test.ts +117 -0
- package/src/database/models/__tests__/topic.test.ts +250 -0
- package/src/database/models/file.ts +9 -5
- package/src/database/models/message.ts +186 -0
- package/src/database/models/session.ts +160 -0
- package/src/database/models/topic.ts +196 -0
- package/src/{types/database → database/schemas}/files.ts +2 -2
- package/src/database/schemas/message.ts +37 -0
- package/src/database/schemas/session.ts +56 -0
- package/src/database/schemas/topic.ts +12 -0
- package/src/features/AgentSetting/AgentConfig/index.tsx +8 -1
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/AgentSetting/store/action.ts +1 -1
- package/src/features/AgentSetting/store/initialState.ts +1 -1
- package/src/features/AgentSetting/store/reducers/config.ts +1 -1
- package/src/features/DataImporter/index.tsx +240 -0
- package/src/features/DebugUI/index.tsx +34 -0
- package/src/features/SideBar/BottomActions.tsx +8 -14
- package/src/hooks/useImportConfig.ts +13 -30
- package/src/hooks/useTTS.ts +1 -1
- package/src/layout/GlobalLayout/index.tsx +16 -1
- package/src/locales/default/common.ts +19 -0
- package/src/locales/default/migration.ts +47 -0
- package/src/locales/default/setting.ts +1 -1
- package/src/locales/resources/en_US.ts +2 -0
- package/src/locales/resources/ja_JP.ts +2 -0
- package/src/locales/resources/ko_KR.ts +2 -0
- package/src/locales/resources/ru_RU.ts +2 -0
- package/src/locales/resources/zh_CN.ts +2 -0
- package/src/locales/resources/zh_TW.ts +2 -0
- package/src/migrations/FromV0ToV1.ts +2 -4
- package/src/migrations/FromV1ToV2/fixtures/input-v1-session.json +191 -0
- package/src/migrations/FromV1ToV2/fixtures/output-v2.json +202 -0
- package/src/migrations/FromV1ToV2/index.ts +82 -0
- package/src/migrations/FromV1ToV2/migrations.test.ts +224 -0
- package/src/migrations/FromV1ToV2/types/v1.ts +78 -0
- package/src/migrations/FromV1ToV2/types/v2.ts +52 -0
- package/src/{utils → migrations}/VersionController.test.ts +1 -3
- package/src/{utils → migrations}/VersionController.ts +5 -2
- package/src/migrations/index.ts +17 -3
- package/src/services/__tests__/file.test.ts +3 -3
- package/src/services/chat.ts +66 -5
- package/src/services/config.ts +184 -0
- package/src/services/debug.ts +13 -0
- package/src/services/file.ts +6 -2
- package/src/services/github.ts +25 -0
- package/src/services/message.ts +79 -0
- package/src/services/session.ts +63 -0
- package/src/services/topic.ts +56 -0
- package/src/store/chat/actions/enhance.ts +95 -0
- package/src/store/{session/slices/chat → chat}/actions/message.ts +225 -247
- package/src/store/{session/slices/chat → chat}/actions/plugin.ts +29 -34
- package/src/store/{session/slices/chat → chat}/actions/share.ts +9 -13
- package/src/store/chat/actions/topic.ts +197 -0
- package/src/store/chat/helpers.ts +23 -0
- package/src/store/chat/index.ts +3 -0
- package/src/store/chat/initialState.ts +48 -0
- package/src/store/chat/reducers/message.test.ts +83 -0
- package/src/store/chat/reducers/message.ts +83 -0
- package/src/store/chat/selectors/__tests__/topic.test.ts +43 -0
- package/src/store/chat/selectors/chat.ts +119 -0
- package/src/store/chat/selectors/index.ts +2 -0
- package/src/store/chat/selectors/topic.ts +28 -0
- package/src/store/chat/store.ts +63 -0
- package/src/store/files/slices/images/action.ts +6 -4
- package/src/store/global/selectors/__snapshots__/settings.test.ts.snap +99 -0
- package/src/store/global/selectors/settings.test.ts +51 -0
- package/src/store/global/selectors/settings.ts +36 -5
- package/src/store/global/store.ts +1 -1
- package/src/store/middleware/createHyperStorage/index.ts +40 -24
- package/src/store/middleware/createHyperStorage/keyMapper.ts +8 -2
- package/src/store/middleware/createHyperStorage/type.ts +10 -8
- package/src/store/plugin/slices/plugin/action.ts +1 -1
- package/src/store/plugin/store.ts +2 -4
- package/src/store/session/helpers.ts +1 -1
- package/src/store/session/hooks/useSessionHydrated.ts +6 -10
- package/src/store/session/initialState.ts +26 -7
- package/src/store/session/selectors.ts +1 -2
- package/src/store/session/slices/agent/action.ts +26 -35
- package/src/store/session/slices/agent/selectors.ts +32 -37
- package/src/store/session/slices/session/action.ts +81 -88
- package/src/store/session/slices/session/helpers.ts +19 -0
- package/src/store/session/slices/session/initialState.ts +7 -10
- package/src/store/session/slices/session/selectors/export.ts +12 -9
- package/src/store/session/slices/session/selectors/index.ts +2 -35
- package/src/store/session/slices/session/selectors/list.test.ts +25 -203
- package/src/store/session/slices/session/selectors/list.ts +40 -78
- package/src/store/session/store.ts +11 -17
- package/src/types/agent/index.ts +61 -0
- package/src/types/chatMessage.ts +11 -20
- package/src/types/exportConfig.ts +7 -2
- package/src/types/files.ts +2 -2
- package/src/types/llm.ts +1 -1
- package/src/types/meta.ts +24 -12
- package/src/types/openai/chat.ts +9 -1
- package/src/types/openai/functionCall.ts +4 -0
- package/src/types/session.ts +10 -94
- package/src/types/settings.ts +2 -0
- package/src/types/translate.ts +2 -1
- package/src/utils/config.ts +5 -11
- package/src/utils/fetch.ts +8 -2
- package/src/app/chat/features/Conversation/usePluginsInit.ts +0 -14
- package/src/database/core/schema.ts +0 -9
- package/src/helpers/export.ts +0 -69
- package/src/hooks/useExportConfig.ts +0 -6
- package/src/store/session/slices/chat/actions/index.ts +0 -32
- package/src/store/session/slices/chat/actions/topic.ts +0 -171
- package/src/store/session/slices/chat/actions/translate.ts +0 -113
- package/src/store/session/slices/chat/helpers.ts +0 -9
- package/src/store/session/slices/chat/initialState.ts +0 -13
- package/src/store/session/slices/chat/reducers/message.test.ts +0 -319
- package/src/store/session/slices/chat/reducers/message.ts +0 -156
- package/src/store/session/slices/chat/reducers/topic.test.ts +0 -179
- package/src/store/session/slices/chat/reducers/topic.ts +0 -81
- package/src/store/session/slices/chat/selectors/chat.ts +0 -111
- package/src/store/session/slices/chat/selectors/index.ts +0 -26
- package/src/store/session/slices/chat/selectors/topic.ts +0 -30
- package/src/store/session/slices/chat/selectors/utils.test.ts +0 -385
- package/src/store/session/slices/chat/selectors/utils.ts +0 -91
- package/src/store/session/slices/chat/utils.ts +0 -13
- package/src/store/session/slices/session/reducers/session.test.ts +0 -577
- package/src/store/session/slices/session/reducers/session.ts +0 -182
- package/src/types/database/db.ts +0 -4
- /package/src/store/{session/slices/chat → chat}/reducers/files.test.ts +0 -0
- /package/src/store/{session/slices/chat → chat}/reducers/files.ts +0 -0
|
@@ -30,6 +30,25 @@
|
|
|
30
30
|
"feedback": "回饋與建議",
|
|
31
31
|
"historyRange": "歷史範圍",
|
|
32
32
|
"import": "匯入設定",
|
|
33
|
+
"importModal": {
|
|
34
|
+
"finish": {
|
|
35
|
+
"onlySettings": "系統設置匯入成功",
|
|
36
|
+
"start": "開始使用",
|
|
37
|
+
"subTitle": "數據匯入成功,耗時 {{duration}} 秒。匯入明細如下:",
|
|
38
|
+
"title": "數據匯入完成"
|
|
39
|
+
},
|
|
40
|
+
"loading": "數據匯入中,請耐心等待...",
|
|
41
|
+
"result": {
|
|
42
|
+
"added": "匯入成功",
|
|
43
|
+
"errors": "匯入出錯",
|
|
44
|
+
"messages": "消息",
|
|
45
|
+
"sessions": "助手",
|
|
46
|
+
"skips": "重複跳過",
|
|
47
|
+
"topics": "話題",
|
|
48
|
+
"type": "數據類型"
|
|
49
|
+
},
|
|
50
|
+
"title": "匯入數據"
|
|
51
|
+
},
|
|
33
52
|
"lang": {
|
|
34
53
|
"en": "英語",
|
|
35
54
|
"en-US": "英語",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dbV1": {
|
|
3
|
+
"action": {
|
|
4
|
+
"clearDB": "清空本地資料",
|
|
5
|
+
"downloadBackup": "下載資料備份",
|
|
6
|
+
"reUpgrade": "重新升級",
|
|
7
|
+
"start": "開始使用",
|
|
8
|
+
"upgrade": "一鍵升級"
|
|
9
|
+
},
|
|
10
|
+
"clear": {
|
|
11
|
+
"confirm": "即將清空本地資料(全域設定不受影響),請確認你已經下載了資料備份。"
|
|
12
|
+
},
|
|
13
|
+
"description": "在新版本中,LobeChat 的資料存儲有了巨大的飛躍。因此我們要對舊版資料進行升級,進而為你帶來更好的使用體驗。",
|
|
14
|
+
"features": {
|
|
15
|
+
"capability": {
|
|
16
|
+
"desc": "基於 IndexedDB 技術,足以裝下你一生的對話消息",
|
|
17
|
+
"title": "大容量"
|
|
18
|
+
},
|
|
19
|
+
"performance": {
|
|
20
|
+
"title": "高性能",
|
|
21
|
+
"desc": "百萬條消息自動索引,檢索查詢毫秒級響應"
|
|
22
|
+
},
|
|
23
|
+
"use": {
|
|
24
|
+
"desc": "支持標題、描述、標籤、消息內容乃至翻譯文本檢索,日常搜索效率大大提升",
|
|
25
|
+
"title": "更易用"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"title": "LobeChat 資料進化",
|
|
29
|
+
"upgrade": {
|
|
30
|
+
"error": {
|
|
31
|
+
"title": "資料庫升級失敗",
|
|
32
|
+
"subTitle": "非常抱歉,資料庫升級過程發生異常。請嘗試以下方案:A. 清空本地數據後,重新導入備份數據; B.點擊「重新升級」按鈕。<br><br> 如仍然出錯,請 <1>提交問題</1> ,我們將會第一時間幫你排查"
|
|
33
|
+
},
|
|
34
|
+
"success": {
|
|
35
|
+
"subTitle": "LobeChat 的資料庫已經升級到最新版本,立即開始體驗吧",
|
|
36
|
+
"title": "資料庫升級成功"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"upgradeTip": "升級大致需要 1~2 秒,升級過程中請不要關閉 LobeChat"
|
|
40
|
+
},
|
|
41
|
+
"migrateError": {
|
|
42
|
+
"missVersion": "導入數據缺少版本號,請檢查文件後重試",
|
|
43
|
+
"noMigration": "沒有找到當前版本對應的遷移方案,請檢查版本號後重試。如仍有問題請提交問題反饋"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.107.0",
|
|
4
4
|
"description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chatbot",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"react-layout-kit": "^1",
|
|
108
108
|
"react-lazy-load": "^4",
|
|
109
109
|
"react-spring-lightbox": "^1",
|
|
110
|
+
"react-wrap-balancer": "^1.1.0",
|
|
110
111
|
"remark": "^14",
|
|
111
112
|
"remark-gfm": "^3",
|
|
112
113
|
"remark-html": "^15",
|
|
@@ -33,7 +33,7 @@ describe('createChatCompletion', () => {
|
|
|
33
33
|
const result = await createChatCompletion({
|
|
34
34
|
openai: openaiInstance,
|
|
35
35
|
payload: {
|
|
36
|
-
messages: [{ content: 'Hello',
|
|
36
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
|
37
37
|
model: 'text-davinci-003',
|
|
38
38
|
temperature: 0,
|
|
39
39
|
},
|
|
@@ -63,7 +63,7 @@ describe('createChatCompletion', () => {
|
|
|
63
63
|
const result = await createChatCompletion({
|
|
64
64
|
openai: openaiInstance,
|
|
65
65
|
payload: {
|
|
66
|
-
messages: [{ content: 'Hello',
|
|
66
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
|
67
67
|
model: 'text-davinci-003',
|
|
68
68
|
temperature: 0,
|
|
69
69
|
},
|
|
@@ -89,7 +89,7 @@ describe('createChatCompletion', () => {
|
|
|
89
89
|
const result = await createChatCompletion({
|
|
90
90
|
openai: openaiInstance,
|
|
91
91
|
payload: {
|
|
92
|
-
messages: [{ content: 'Hello',
|
|
92
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
|
93
93
|
model: 'text-davinci-003',
|
|
94
94
|
temperature: 0,
|
|
95
95
|
},
|
|
@@ -114,7 +114,7 @@ describe('createChatCompletion', () => {
|
|
|
114
114
|
const result = await createChatCompletion({
|
|
115
115
|
openai: openaiInstance,
|
|
116
116
|
payload: {
|
|
117
|
-
messages: [{ content: 'Hello',
|
|
117
|
+
messages: [{ content: 'Hello', role: 'user' }],
|
|
118
118
|
model: 'text-davinci-003',
|
|
119
119
|
temperature: 0,
|
|
120
120
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
|
2
2
|
import OpenAI from 'openai';
|
|
3
3
|
|
|
4
|
-
import { createErrorResponse } from '@/app/api/openai/errorResponse';
|
|
5
4
|
import { ChatErrorType } from '@/types/fetch';
|
|
6
5
|
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
7
6
|
|
|
7
|
+
import { createErrorResponse } from '../errorResponse';
|
|
8
|
+
|
|
8
9
|
interface CreateChatCompletionOptions {
|
|
9
10
|
openai: OpenAI;
|
|
10
11
|
payload: OpenAIChatStreamPayload;
|
|
@@ -14,22 +15,15 @@ export const createChatCompletion = async ({ payload, openai }: CreateChatComple
|
|
|
14
15
|
// ============ 1. preprocess messages ============ //
|
|
15
16
|
const { messages, ...params } = payload;
|
|
16
17
|
|
|
17
|
-
// remove unnecessary fields like `plugins` or `files` by lobe-chat
|
|
18
|
-
const formatMessages = messages.map((m) => ({
|
|
19
|
-
content: m.content,
|
|
20
|
-
name: m.name,
|
|
21
|
-
role: m.role,
|
|
22
|
-
})) as OpenAI.ChatCompletionMessageParam[];
|
|
23
|
-
|
|
24
18
|
// ============ 2. send api ============ //
|
|
25
19
|
|
|
26
20
|
try {
|
|
27
21
|
const response = await openai.chat.completions.create(
|
|
28
22
|
{
|
|
29
|
-
messages
|
|
23
|
+
messages,
|
|
30
24
|
...params,
|
|
31
25
|
stream: true,
|
|
32
|
-
},
|
|
26
|
+
} as unknown as OpenAI.ChatCompletionCreateParamsStreaming,
|
|
33
27
|
{ headers: { Accept: '*/*' } },
|
|
34
28
|
);
|
|
35
29
|
const stream = OpenAIStream(response);
|
|
@@ -8,6 +8,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
8
8
|
|
|
9
9
|
import SaveTopic from '@/app/chat/features/ChatInput/Topic';
|
|
10
10
|
import { useSendMessage } from '@/app/chat/features/ChatInput/useSend';
|
|
11
|
+
import { useChatStore } from '@/store/chat';
|
|
11
12
|
import { useSessionStore } from '@/store/session';
|
|
12
13
|
import { agentSelectors } from '@/store/session/selectors';
|
|
13
14
|
|
|
@@ -16,7 +17,7 @@ import { LocalFiles } from './LocalFiles';
|
|
|
16
17
|
const Footer = memo(() => {
|
|
17
18
|
const { t } = useTranslation('chat');
|
|
18
19
|
const theme = useTheme();
|
|
19
|
-
const [loading, onStop] =
|
|
20
|
+
const [loading, onStop] = useChatStore((s) => [!!s.chatLoadingId, s.stopGenerateMessage]);
|
|
20
21
|
|
|
21
22
|
const onSend = useSendMessage();
|
|
22
23
|
const canUpload = useSessionStore(agentSelectors.modelHasVisionAbility);
|
|
@@ -4,10 +4,10 @@ import { Loader2, SendHorizonal } from 'lucide-react';
|
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
|
|
6
6
|
import { useSendMessage } from '@/app/chat/features/ChatInput/useSend';
|
|
7
|
-
import {
|
|
7
|
+
import { useChatStore } from '@/store/chat';
|
|
8
8
|
|
|
9
9
|
const SendButton = memo(() => {
|
|
10
|
-
const [loading, onStop] =
|
|
10
|
+
const [loading, onStop] = useChatStore((s) => [!!s.chatLoadingId, s.stopGenerateMessage]);
|
|
11
11
|
|
|
12
12
|
const handleSend = useSendMessage();
|
|
13
13
|
|
|
@@ -7,8 +7,8 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
7
7
|
|
|
8
8
|
import MobilePadding from '@/components/MobilePadding';
|
|
9
9
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
10
11
|
import { useGlobalStore } from '@/store/global';
|
|
11
|
-
import { useSessionStore } from '@/store/session';
|
|
12
12
|
|
|
13
13
|
import Preview, { ImageType, imageTypeOptions } from './Preview';
|
|
14
14
|
|
|
@@ -27,10 +27,7 @@ const Inner = memo(() => {
|
|
|
27
27
|
const { t } = useTranslation('chat');
|
|
28
28
|
|
|
29
29
|
const avatar = useGlobalStore((s) => s.settings.avatar);
|
|
30
|
-
const [shareLoading, shareToShareGPT] =
|
|
31
|
-
s.shareLoading,
|
|
32
|
-
s.shareToShareGPT,
|
|
33
|
-
]);
|
|
30
|
+
const [shareLoading, shareToShareGPT] = useChatStore((s) => [s.shareLoading, s.shareToShareGPT]);
|
|
34
31
|
|
|
35
32
|
const options: SegmentedProps['options'] = useMemo(
|
|
36
33
|
() => [
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import useMergeState from 'use-merge-value';
|
|
7
7
|
|
|
8
8
|
import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens';
|
|
9
|
-
import {
|
|
9
|
+
import { useChatStore } from '@/store/chat';
|
|
10
10
|
|
|
11
11
|
const Inner = dynamic(() => import('./Inner'));
|
|
12
12
|
interface ShareButtonProps {
|
|
@@ -22,7 +22,7 @@ const ShareButton = memo<ShareButtonProps>(({ mobile, setOpen, open }) => {
|
|
|
22
22
|
value: open,
|
|
23
23
|
});
|
|
24
24
|
const { t } = useTranslation('common');
|
|
25
|
-
const [shareLoading] =
|
|
25
|
+
const [shareLoading] = useChatStore((s) => [s.shareLoading]);
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<>
|
|
@@ -7,12 +7,12 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
|
|
8
8
|
import HotKeys from '@/components/HotKeys';
|
|
9
9
|
import { CLEAN_MESSAGE_KEY, PREFIX_KEY } from '@/const/hotkeys';
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
10
11
|
import { useFileStore } from '@/store/files';
|
|
11
|
-
import { useSessionStore } from '@/store/session';
|
|
12
12
|
|
|
13
13
|
const Clear = memo(() => {
|
|
14
14
|
const { t } = useTranslation('setting');
|
|
15
|
-
const [clearMessage] =
|
|
15
|
+
const [clearMessage] = useChatStore((s) => [s.clearMessage]);
|
|
16
16
|
const [clearImageList] = useFileStore((s) => [s.clearImageList]);
|
|
17
17
|
const hotkeys = [PREFIX_KEY, CLEAN_MESSAGE_KEY].join('+');
|
|
18
18
|
|
|
@@ -22,7 +22,7 @@ const ModelSwitch = memo(() => {
|
|
|
22
22
|
<Dropdown
|
|
23
23
|
menu={{
|
|
24
24
|
activeKey: model,
|
|
25
|
-
items: modelList.map((
|
|
25
|
+
items: modelList.map(({ name, displayName }) => ({ key: name, label: displayName })),
|
|
26
26
|
onClick: (e) => {
|
|
27
27
|
updateAgentConfig({ model: e.key as LanguageModel });
|
|
28
28
|
},
|
|
@@ -4,19 +4,25 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
|
|
5
5
|
import { ModelTokens } from '@/const/modelTokens';
|
|
6
6
|
import { useTokenCount } from '@/hooks/useTokenCount';
|
|
7
|
+
import { useChatStore } from '@/store/chat';
|
|
8
|
+
import { chatSelectors } from '@/store/chat/selectors';
|
|
7
9
|
import { useSessionStore } from '@/store/session';
|
|
8
|
-
import { agentSelectors
|
|
10
|
+
import { agentSelectors } from '@/store/session/selectors';
|
|
9
11
|
import { LanguageModel } from '@/types/llm';
|
|
10
12
|
|
|
11
13
|
const Token = memo(() => {
|
|
12
14
|
const { t } = useTranslation('chat');
|
|
13
15
|
|
|
14
|
-
const [input, messageString
|
|
16
|
+
const [input, messageString] = useChatStore((s) => [
|
|
15
17
|
s.inputMessage,
|
|
16
18
|
chatSelectors.chatsMessageString(s),
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const [systemRole, model] = useSessionStore((s) => [
|
|
17
22
|
agentSelectors.currentAgentSystemRole(s),
|
|
18
23
|
agentSelectors.currentAgentModel(s) as LanguageModel,
|
|
19
24
|
]);
|
|
25
|
+
|
|
20
26
|
const inputTokenCount = useTokenCount(input);
|
|
21
27
|
|
|
22
28
|
const systemRoleToken = useTokenCount(systemRole);
|
|
@@ -2,7 +2,7 @@ import { Input, TextArea } from '@lobehub/ui';
|
|
|
2
2
|
import { memo, useRef } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useChatStore } from '@/store/chat';
|
|
6
6
|
|
|
7
7
|
import { useSendMessage } from '../useSend';
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ const InputAreaInner = memo<InputAreaInnerProps>(({ className, mobile }) => {
|
|
|
15
15
|
const { t } = useTranslation('chat');
|
|
16
16
|
const isChineseInput = useRef(false);
|
|
17
17
|
|
|
18
|
-
const [loading, message, updateInputMessage] =
|
|
18
|
+
const [loading, message, updateInputMessage] = useChatStore((s) => [
|
|
19
19
|
!!s.chatLoadingId,
|
|
20
20
|
s.inputMessage,
|
|
21
21
|
s.updateInputMessage,
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import { useSTT } from '@/hooks/useSTT';
|
|
10
|
-
import {
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
11
11
|
import { ChatMessageError } from '@/types/chatMessage';
|
|
12
12
|
import { getMessageError } from '@/utils/fetch';
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ const STT = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
|
25
25
|
const { t } = useTranslation('chat');
|
|
26
26
|
const { styles } = useStyles();
|
|
27
27
|
|
|
28
|
-
const [loading, updateInputMessage] =
|
|
28
|
+
const [loading, updateInputMessage] = useChatStore((s) => [
|
|
29
29
|
!!s.chatLoadingId,
|
|
30
30
|
s.updateInputMessage,
|
|
31
31
|
]);
|
|
@@ -7,11 +7,11 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
|
|
8
8
|
import HotKeys from '@/components/HotKeys';
|
|
9
9
|
import { PREFIX_KEY, SAVE_TOPIC_KEY } from '@/const/hotkeys';
|
|
10
|
-
import {
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
11
11
|
|
|
12
12
|
const SaveTopic = memo<{ mobile?: boolean }>(({ mobile }) => {
|
|
13
13
|
const { t } = useTranslation('chat');
|
|
14
|
-
const [hasTopic, openNewTopicOrSaveTopic] =
|
|
14
|
+
const [hasTopic, openNewTopicOrSaveTopic] = useChatStore((s) => [
|
|
15
15
|
!!s.activeTopicId,
|
|
16
16
|
s.openNewTopicOrSaveTopic,
|
|
17
17
|
]);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { filesSelectors, useFileStore } from '@/store/files';
|
|
4
|
-
import {
|
|
4
|
+
import { useChatStore } from 'src/store/chat';
|
|
5
5
|
|
|
6
6
|
export const useSendMessage = () => {
|
|
7
|
-
const [sendMessage, updateInputMessage] =
|
|
7
|
+
const [sendMessage, updateInputMessage] = useChatStore((s) => [
|
|
8
8
|
s.sendMessage,
|
|
9
9
|
s.updateInputMessage,
|
|
10
10
|
]);
|
|
11
11
|
|
|
12
12
|
return useCallback(() => {
|
|
13
|
-
const store =
|
|
13
|
+
const store = useChatStore.getState();
|
|
14
14
|
if (!!store.chatLoadingId) return;
|
|
15
15
|
const imageList = filesSelectors.imageUrlOrBase64List(useFileStore.getState());
|
|
16
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChatListProps } from '@lobehub/ui';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useChatStore } from '@/store/chat';
|
|
4
4
|
|
|
5
5
|
import { AssistantActionsBar } from './Assistant';
|
|
6
6
|
import { DefaultActionsBar } from './Fallback';
|
|
@@ -20,7 +20,7 @@ interface ActionsClick {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const useActionsClick = (): ChatListProps['onActionsClick'] => {
|
|
23
|
-
const [deleteMessage, resendMessage, translateMessage, ttsMessage] =
|
|
23
|
+
const [deleteMessage, resendMessage, translateMessage, ttsMessage] = useChatStore((s) => [
|
|
24
24
|
s.deleteMessage,
|
|
25
25
|
s.resendMessage,
|
|
26
26
|
s.translateMessage,
|
|
@@ -5,8 +5,8 @@ import { memo, useState } from 'react';
|
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
7
7
|
|
|
8
|
+
import { useChatStore } from '@/store/chat';
|
|
8
9
|
import { settingsSelectors, useGlobalStore } from '@/store/global';
|
|
9
|
-
import { useSessionStore } from '@/store/session';
|
|
10
10
|
|
|
11
11
|
import { FormAction } from './style';
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ const APIKeyForm = memo<{ id: string }>(({ id }) => {
|
|
|
20
20
|
s.setOpenAIConfig,
|
|
21
21
|
]);
|
|
22
22
|
|
|
23
|
-
const [resend, deleteMessage] =
|
|
23
|
+
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<Center gap={16} style={{ maxWidth: 300 }}>
|
|
@@ -5,8 +5,8 @@ import { memo, useState } from 'react';
|
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { Flexbox } from 'react-layout-kit';
|
|
7
7
|
|
|
8
|
+
import { useChatStore } from '@/store/chat';
|
|
8
9
|
import { useGlobalStore } from '@/store/global';
|
|
9
|
-
import { useSessionStore } from '@/store/session';
|
|
10
10
|
|
|
11
11
|
import APIKeyForm from './ApiKeyForm';
|
|
12
12
|
import { ErrorActionContainer, FormAction } from './style';
|
|
@@ -20,7 +20,7 @@ const InvalidAccess: RenderErrorMessage['Render'] = memo(({ id }) => {
|
|
|
20
20
|
const { t } = useTranslation('error');
|
|
21
21
|
const [mode, setMode] = useState<Tab>(Tab.Password);
|
|
22
22
|
const [password, setSettings] = useGlobalStore((s) => [s.settings.password, s.setSettings]);
|
|
23
|
-
const [resend, deleteMessage] =
|
|
23
|
+
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<ErrorActionContainer>
|
|
@@ -7,9 +7,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import PluginSettingsConfig from '@/features/PluginSettings';
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
10
11
|
import { pluginHelpers, usePluginStore } from '@/store/plugin';
|
|
11
12
|
import { pluginSelectors } from '@/store/plugin/selectors';
|
|
12
|
-
import { useSessionStore } from '@/store/session';
|
|
13
13
|
|
|
14
14
|
import { ErrorActionContainer, useStyles } from '../style';
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ const PluginSettings: RenderErrorMessage['Render'] = memo(({ id, plugin }) => {
|
|
|
17
17
|
const { styles } = useStyles();
|
|
18
18
|
const { t } = useTranslation('error');
|
|
19
19
|
const theme = useTheme();
|
|
20
|
-
const [resend, deleteMessage] =
|
|
20
|
+
const [resend, deleteMessage] = useChatStore((s) => [s.resendMessage, s.deleteMessage]);
|
|
21
21
|
const pluginIdentifier = plugin?.identifier as string;
|
|
22
22
|
const pluginMeta = usePluginStore(pluginSelectors.getPluginMetaById(pluginIdentifier), isEqual);
|
|
23
23
|
const manifest = usePluginStore(pluginSelectors.getPluginManifestById(pluginIdentifier), isEqual);
|
|
@@ -27,11 +27,11 @@ vi.mock('@/store/session/selectors', () => ({
|
|
|
27
27
|
|
|
28
28
|
const mockData: ChatMessage = {
|
|
29
29
|
content: 'test-content',
|
|
30
|
-
|
|
30
|
+
createdAt: 0,
|
|
31
31
|
id: 'abc',
|
|
32
32
|
meta: { avatar: '', backgroundColor: '', description: '', tags: [], title: '' },
|
|
33
33
|
role: 'assistant',
|
|
34
|
-
|
|
34
|
+
updatedAt: 0,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
describe('AssistantMessageExtra', () => {
|
|
@@ -71,7 +71,7 @@ describe('AssistantMessageExtra', () => {
|
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it('should render Translate component if extra.translate exists', async () => {
|
|
74
|
-
render(<AssistantMessageExtra {...mockData} extra={{ translate: {} }} />);
|
|
74
|
+
render(<AssistantMessageExtra {...mockData} extra={{ translate: { to: 'abc' } }} />);
|
|
75
75
|
expect(screen.getByText('Translate Component')).toBeInTheDocument();
|
|
76
76
|
});
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ describe('AssistantMessageExtra', () => {
|
|
|
79
79
|
(useSessionStore as unknown as Mock).mockImplementation(() => ({
|
|
80
80
|
chatLoadingId: 'test-id',
|
|
81
81
|
}));
|
|
82
|
-
render(<AssistantMessageExtra {...mockData} extra={{ translate: {}, tts: {} }} />);
|
|
82
|
+
render(<AssistantMessageExtra {...mockData} extra={{ translate: { to: 'abc' }, tts: {} }} />);
|
|
83
83
|
expect(screen.getByText('TTS Component')).toBeInTheDocument();
|
|
84
84
|
expect(screen.getByText('Translate Component')).toBeInTheDocument();
|
|
85
85
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SiOpenai } from '@icons-pack/react-simple-icons';
|
|
2
|
-
import {
|
|
2
|
+
import { Tag } from '@lobehub/ui';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import { Flexbox } from 'react-layout-kit';
|
|
5
5
|
|
|
6
|
+
import { useChatStore } from '@/store/chat';
|
|
6
7
|
import { useSessionStore } from '@/store/session';
|
|
7
8
|
import { agentSelectors } from '@/store/session/selectors';
|
|
8
9
|
import { ChatMessage } from '@/types/chatMessage';
|
|
@@ -11,39 +12,37 @@ import ExtraContainer from './ExtraContainer';
|
|
|
11
12
|
import TTS from './TTS';
|
|
12
13
|
import Translate from './Translate';
|
|
13
14
|
|
|
14
|
-
export const AssistantMessageExtra
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const loading = useSessionStore((s) => s.chatLoadingId === id);
|
|
15
|
+
export const AssistantMessageExtra = memo<ChatMessage>(({ extra, id, content }) => {
|
|
16
|
+
const model = useSessionStore(agentSelectors.currentAgentModel);
|
|
17
|
+
const loading = useChatStore((s) => s.chatLoadingId === id);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const showModelTag = extra?.fromModel && model !== extra?.fromModel;
|
|
20
|
+
const showTranslate = !!extra?.translate;
|
|
21
|
+
const showTTS = !!extra?.tts;
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const showExtra = showModelTag || showTranslate || showTTS;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
if (!showExtra) return;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<div>
|
|
31
|
-
<Tag icon={<SiOpenai size={'1em'} />}>{extra?.fromModel as string}</Tag>
|
|
32
|
-
</div>
|
|
33
|
-
)}
|
|
27
|
+
return (
|
|
28
|
+
<Flexbox gap={8} style={{ marginTop: 8 }}>
|
|
29
|
+
{showModelTag && (
|
|
34
30
|
<div>
|
|
35
|
-
{extra?.
|
|
36
|
-
<ExtraContainer>
|
|
37
|
-
<TTS content={content} id={id} loading={loading} {...extra?.tts} />
|
|
38
|
-
</ExtraContainer>
|
|
39
|
-
)}
|
|
40
|
-
{extra?.translate && (
|
|
41
|
-
<ExtraContainer>
|
|
42
|
-
<Translate id={id} loading={loading} {...extra?.translate} />
|
|
43
|
-
</ExtraContainer>
|
|
44
|
-
)}
|
|
31
|
+
<Tag icon={<SiOpenai size={'1em'} />}>{extra?.fromModel as string}</Tag>
|
|
45
32
|
</div>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
)}
|
|
34
|
+
<div>
|
|
35
|
+
{extra?.tts && (
|
|
36
|
+
<ExtraContainer>
|
|
37
|
+
<TTS content={content} id={id} loading={loading} {...extra?.tts} />
|
|
38
|
+
</ExtraContainer>
|
|
39
|
+
)}
|
|
40
|
+
{extra?.translate && (
|
|
41
|
+
<ExtraContainer>
|
|
42
|
+
<Translate id={id} loading={loading} {...extra?.translate} />
|
|
43
|
+
</ExtraContainer>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
</Flexbox>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import { useTTS } from '@/hooks/useTTS';
|
|
10
|
-
import {
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
11
11
|
import { ChatMessageError, ChatTTS } from '@/types/chatMessage';
|
|
12
12
|
import { getMessageError } from '@/utils/fetch';
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ const TTS = memo<TTSProps>(({ id, init, content }) => {
|
|
|
22
22
|
const [error, setError] = useState<ChatMessageError>();
|
|
23
23
|
const { t } = useTranslation('chat');
|
|
24
24
|
|
|
25
|
-
const [ttsMessage, clearTTS] =
|
|
25
|
+
const [ttsMessage, clearTTS] = useChatStore((s) => [s.ttsMessage, s.clearTTS]);
|
|
26
26
|
|
|
27
27
|
const setDefaultError = useCallback(
|
|
28
28
|
(err?: any) => {
|
|
@@ -7,7 +7,7 @@ import { memo, useState } from 'react';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { useChatStore } from '@/store/chat';
|
|
11
11
|
import { ChatTranslate } from '@/types/chatMessage';
|
|
12
12
|
|
|
13
13
|
import BubblesLoading from '../Loading';
|
|
@@ -25,7 +25,7 @@ const Translate = memo<TranslateProps>(({ content = '', from, to, id, loading })
|
|
|
25
25
|
const { theme, styles } = useStyles();
|
|
26
26
|
const { t } = useTranslation('common');
|
|
27
27
|
const [show, setShow] = useState(true);
|
|
28
|
-
const clearTranslate =
|
|
28
|
+
const clearTranslate = useChatStore((s) => s.clearTranslate);
|
|
29
29
|
|
|
30
30
|
const { message } = App.useApp();
|
|
31
31
|
return (
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { RenderMessageExtra } from '@lobehub/ui';
|
|
2
1
|
import { memo } from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { useChatStore } from '@/store/chat';
|
|
5
4
|
import { ChatMessage } from '@/types/chatMessage';
|
|
6
5
|
|
|
7
6
|
import ExtraContainer from './ExtraContainer';
|
|
8
7
|
import TTS from './TTS';
|
|
9
8
|
import Translate from './Translate';
|
|
10
9
|
|
|
11
|
-
export const UserMessageExtra
|
|
12
|
-
const loading =
|
|
10
|
+
export const UserMessageExtra = memo<ChatMessage>(({ extra, id, content }) => {
|
|
11
|
+
const loading = useChatStore((s) => s.chatLoadingId === id);
|
|
12
|
+
|
|
13
|
+
const showTranslate = !!extra?.translate;
|
|
14
|
+
const showTTS = !!extra?.tts;
|
|
15
|
+
|
|
16
|
+
const showExtra = showTranslate || showTTS;
|
|
13
17
|
|
|
14
|
-
const showExtra = extra?.translate || extra?.tts;
|
|
15
18
|
if (!showExtra) return;
|
|
16
19
|
|
|
17
20
|
return (
|