@lobehub/chat 1.142.0 → 1.142.2
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/Dockerfile +3 -3
- package/Dockerfile.database +3 -3
- package/Dockerfile.pglite +3 -3
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/advanced/model-list.mdx +11 -0
- package/docs/self-hosting/advanced/model-list.zh-CN.mdx +11 -0
- package/docs/self-hosting/environment-variables/model-provider.mdx +23 -14
- package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +23 -14
- package/docs/usage/providers/aihubmix.zh-CN.mdx +1 -4
- package/locales/ar/models.json +17 -8
- package/locales/bg-BG/models.json +17 -8
- package/locales/de-DE/models.json +17 -8
- package/locales/en-US/models.json +17 -8
- package/locales/es-ES/models.json +17 -8
- package/locales/fa-IR/models.json +17 -8
- package/locales/fr-FR/models.json +17 -8
- package/locales/it-IT/models.json +17 -8
- package/locales/ja-JP/models.json +17 -8
- package/locales/ko-KR/models.json +17 -8
- package/locales/nl-NL/models.json +17 -8
- package/locales/pl-PL/models.json +17 -8
- package/locales/pt-BR/models.json +17 -8
- package/locales/ru-RU/models.json +17 -8
- package/locales/tr-TR/models.json +17 -8
- package/locales/vi-VN/models.json +17 -8
- package/locales/zh-CN/models.json +17 -8
- package/locales/zh-TW/models.json +17 -8
- package/package.json +2 -2
- package/packages/context-engine/src/processors/__tests__/MessageContent.test.ts +17 -17
- package/packages/context-engine/src/types.ts +4 -4
- package/packages/database/src/models/__tests__/generation.test.ts +2 -2
- package/packages/database/src/models/__tests__/generationBatch.test.ts +1 -1
- package/packages/database/src/models/__tests__/generationTopic.test.ts +2 -4
- package/packages/database/src/models/__tests__/message.test.ts +2 -2
- package/packages/database/src/models/asyncTask.ts +3 -4
- package/packages/database/src/models/chatGroup.ts +2 -2
- package/packages/database/src/models/chunk.ts +2 -3
- package/packages/database/src/models/drizzleMigration.ts +1 -1
- package/packages/database/src/models/file.ts +1 -2
- package/packages/database/src/models/generation.ts +8 -4
- package/packages/database/src/models/generationBatch.ts +1 -1
- package/packages/database/src/models/generationTopic.ts +2 -2
- package/packages/database/src/models/knowledgeBase.ts +2 -3
- package/packages/database/src/models/message.ts +9 -9
- package/packages/database/src/models/session.ts +8 -10
- package/packages/database/src/models/thread.ts +2 -3
- package/packages/database/src/models/topic.ts +2 -4
- package/packages/database/src/models/user.ts +1 -2
- package/packages/database/src/schemas/generation.ts +1 -2
- package/packages/database/src/schemas/message.ts +1 -3
- package/packages/model-runtime/src/core/streams/anthropic.ts +1 -2
- package/packages/model-runtime/src/core/streams/protocol.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/anthropic.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/google-ai.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.test.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/utils/computeChatCost.ts +1 -2
- package/packages/model-runtime/src/core/usageConverters/utils/withUsageCost.ts +1 -2
- package/packages/model-runtime/src/types/image.ts +1 -2
- package/packages/prompts/src/chains/__tests__/summaryHistory.test.ts +2 -2
- package/packages/prompts/src/chains/summaryHistory.ts +2 -2
- package/packages/prompts/src/chains/summaryTitle.ts +2 -3
- package/packages/prompts/src/contexts/supervisor/makeDecision.ts +2 -2
- package/packages/prompts/src/prompts/chatMessages/index.test.ts +11 -11
- package/packages/prompts/src/prompts/chatMessages/index.ts +13 -10
- package/packages/prompts/src/prompts/groupChat/index.test.ts +3 -4
- package/packages/prompts/src/prompts/groupChat/index.ts +3 -3
- package/packages/types/src/aiChat.ts +2 -2
- package/packages/types/src/exportConfig.ts +6 -6
- package/packages/types/src/importer.ts +2 -2
- package/packages/types/src/index.ts +2 -0
- package/packages/types/src/message/common/base.ts +27 -0
- package/packages/types/src/message/common/index.ts +5 -0
- package/packages/types/src/message/common/metadata.ts +67 -0
- package/packages/types/src/message/{tools.ts → common/tools.ts} +1 -1
- package/packages/types/src/message/common/translate.ts +8 -0
- package/packages/types/src/message/db/index.ts +2 -0
- package/packages/types/src/message/db/item.ts +29 -0
- package/packages/types/src/message/db/params.ts +57 -0
- package/packages/types/src/message/index.ts +3 -6
- package/packages/types/src/message/{chat.ts → ui/chat.ts} +13 -40
- package/packages/types/src/message/ui/extra.ts +16 -0
- package/packages/types/src/message/ui/index.ts +4 -0
- package/packages/types/src/message/{rag.ts → ui/rag.ts} +11 -1
- package/src/app/[variants]/(main)/chat/(workspace)/@conversation/features/ChatInput/V1Mobile/useSend.ts +1 -1
- package/src/app/[variants]/(main)/chat/(workspace)/features/ShareButton/index.tsx +0 -3
- package/src/app/[variants]/(main)/profile/stats/features/ModelsRank.tsx +1 -1
- package/src/app/[variants]/(main)/settings/llm/components/Checker.tsx +1 -2
- package/src/app/[variants]/(main)/settings/provider/detail/ollama/CheckError.tsx +1 -2
- package/src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx +1 -2
- package/src/app/[variants]/(main)/settings/provider/features/ProviderConfig/Checker.tsx +1 -2
- package/src/database/_deprecated/models/__tests__/message.test.ts +6 -7
- package/src/database/_deprecated/models/message.ts +13 -13
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/ChatInput/ActionBar/STT/browser.tsx +1 -1
- package/src/features/ChatInput/ActionBar/STT/common.tsx +1 -2
- package/src/features/ChatInput/ActionBar/STT/openai.tsx +1 -1
- package/src/features/ChatItem/components/ErrorContent.tsx +5 -0
- package/src/features/Conversation/Error/ErrorJsonViewer.tsx +1 -2
- package/src/features/Conversation/Error/OllamaBizError/index.tsx +2 -3
- package/src/features/Conversation/Error/index.tsx +3 -4
- package/src/features/Conversation/Error/style.tsx +5 -1
- package/src/features/Conversation/Messages/Assistant/Actions/index.tsx +2 -2
- package/src/features/Conversation/Messages/Assistant/Block.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/Extra/index.test.tsx +2 -2
- package/src/features/Conversation/Messages/Assistant/Extra/index.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/FileChunks/Item/index.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/FileChunks/index.tsx +1 -2
- package/src/features/Conversation/Messages/Assistant/MessageContent.tsx +2 -2
- package/src/features/Conversation/Messages/Assistant/Tool/Render/CustomRender.tsx +2 -2
- package/src/features/Conversation/Messages/Assistant/Tool/Render/ErrorResponse.tsx +1 -2
- package/src/features/Conversation/Messages/Assistant/Tool/Render/PluginSettings.tsx +1 -1
- package/src/features/Conversation/Messages/Assistant/index.tsx +2 -2
- package/src/features/Conversation/Messages/Default.tsx +3 -3
- package/src/features/Conversation/Messages/Supervisor/index.tsx +2 -2
- package/src/features/Conversation/Messages/User/Actions.tsx +2 -2
- package/src/features/Conversation/Messages/User/FileListViewer/Item.tsx +1 -1
- package/src/features/Conversation/Messages/User/FileListViewer/index.tsx +1 -2
- package/src/features/Conversation/Messages/User/MessageContent.tsx +2 -3
- package/src/features/Conversation/Messages/User/VideoFileListViewer.tsx +1 -2
- package/src/features/Conversation/Messages/User/index.tsx +2 -2
- package/src/features/Conversation/components/ChatItem/ShareMessageModal/SharePdf/index.tsx +2 -2
- package/src/features/Conversation/components/ChatItem/ShareMessageModal/SharePdf/template.ts +2 -2
- package/src/features/Conversation/components/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/Conversation/components/Extras/TTS/Player.tsx +1 -2
- package/src/features/Conversation/components/Extras/Translate.tsx +1 -1
- package/src/features/Conversation/components/Extras/Usage/UsageDetail/index.tsx +1 -1
- package/src/features/Conversation/components/Extras/Usage/UsageDetail/tokens.ts +1 -1
- package/src/features/Conversation/components/Extras/Usage/index.tsx +1 -2
- package/src/features/Conversation/components/ShareMessageModal/ShareImage/Preview.tsx +2 -2
- package/src/features/Conversation/components/ShareMessageModal/ShareImage/index.tsx +2 -2
- package/src/features/Conversation/components/ShareMessageModal/ShareText/index.tsx +2 -2
- package/src/features/Conversation/components/ShareMessageModal/ShareText/template.test.ts +3 -3
- package/src/features/Conversation/components/ShareMessageModal/ShareText/template.ts +2 -2
- package/src/features/Conversation/components/ShareMessageModal/index.tsx +3 -3
- package/src/features/Conversation/types/index.ts +5 -5
- package/src/features/Portal/Home/Body/Files/FileList/Item.tsx +1 -1
- package/src/features/Portal/Home/Body/Plugins/ArtifactList/Item/index.tsx +1 -1
- package/src/features/Portal/Thread/Chat/ChatInput/useSend.ts +1 -1
- package/src/features/ShareModal/ShareJSON/generateMessages.test.ts +3 -3
- package/src/features/ShareModal/ShareJSON/generateMessages.ts +3 -2
- package/src/features/ShareModal/SharePdf/index.tsx +2 -2
- package/src/features/ShareModal/ShareText/template.test.ts +3 -3
- package/src/features/ShareModal/ShareText/template.ts +2 -2
- package/src/libs/langchain/loaders/code/__tests__/long.json +1 -1
- package/src/libs/langchain/loaders/code/__tests__/long.txt +1 -1
- package/src/server/routers/lambda/__tests__/message.test.ts +2 -3
- package/src/server/routers/lambda/message.ts +2 -4
- package/src/services/chat/chat.test.ts +27 -25
- package/src/services/chat/contextEngineering.test.ts +21 -21
- package/src/services/chat/contextEngineering.ts +2 -2
- package/src/services/chat/index.ts +5 -8
- package/src/services/message/_deprecated.test.ts +7 -7
- package/src/services/message/_deprecated.ts +10 -10
- package/src/services/message/client.test.ts +10 -10
- package/src/services/message/client.ts +6 -5
- package/src/services/message/server.ts +4 -3
- package/src/services/message/type.ts +10 -11
- package/src/services/thread/type.ts +2 -1
- package/src/store/chat/helpers.test.ts +5 -5
- package/src/store/chat/helpers.ts +5 -5
- package/src/store/chat/initialState.ts +0 -3
- package/src/store/chat/slices/aiChat/actions/__tests__/fixtures.ts +5 -4
- package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +4 -4
- package/src/store/chat/slices/aiChat/actions/__tests__/rag.test.ts +6 -6
- package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +17 -12
- package/src/store/chat/slices/aiChat/actions/generateAIChatV2.ts +7 -8
- package/src/store/chat/slices/aiChat/actions/generateAIGroupChat.ts +10 -6
- package/src/store/chat/slices/aiChat/actions/memory.ts +2 -3
- package/src/store/chat/slices/builtinTool/actions/__tests__/dalle.test.ts +3 -3
- package/src/store/chat/slices/builtinTool/actions/__tests__/search.test.ts +3 -3
- package/src/store/chat/slices/message/action.test.ts +13 -8
- package/src/store/chat/slices/message/action.ts +19 -18
- package/src/store/chat/slices/message/initialState.ts +3 -2
- package/src/store/chat/slices/message/reducer.test.ts +6 -6
- package/src/store/chat/slices/message/reducer.ts +11 -8
- package/src/store/chat/slices/message/selectors.test.ts +9 -9
- package/src/store/chat/slices/message/selectors.ts +10 -9
- package/src/store/chat/slices/message/supervisor.ts +2 -2
- package/src/store/chat/slices/plugin/action.test.ts +16 -13
- package/src/store/chat/slices/plugin/action.ts +11 -11
- package/src/store/chat/slices/portal/selectors.test.ts +8 -8
- package/src/store/chat/slices/thread/action.test.ts +2 -2
- package/src/store/chat/slices/thread/action.ts +9 -5
- package/src/store/chat/slices/thread/selectors/index.ts +11 -11
- package/src/store/chat/slices/thread/selectors/util.ts +2 -3
- package/src/store/chat/slices/topic/action.test.ts +6 -6
- package/src/store/chat/slices/topic/action.ts +2 -3
- package/src/store/chat/slices/translate/action.ts +2 -3
- package/src/store/chat/slices/tts/action.ts +1 -1
- package/src/store/chat/store.ts +0 -3
- package/src/store/image/slices/createImage/action.test.ts +9 -2
- package/src/store/image/slices/createImage/action.ts +6 -4
- package/src/tools/local-system/Render/ListFiles/Result.tsx +1 -1
- package/src/tools/local-system/Render/ListFiles/index.tsx +1 -1
- package/src/tools/local-system/Render/ReadLocalFile/index.tsx +1 -1
- package/src/tools/local-system/Render/RenameLocalFile/index.tsx +1 -1
- package/src/tools/local-system/Render/RunCommand/index.tsx +1 -1
- package/src/tools/local-system/Render/SearchFiles/index.tsx +1 -1
- package/src/tools/local-system/Render/WriteFile/index.tsx +1 -1
- package/src/tools/web-browsing/Render/Search/index.tsx +1 -3
- package/packages/types/src/message/base.ts +0 -173
- package/packages/types/src/message/translate.ts +0 -4
- package/src/store/chat/slices/share/action.test.ts +0 -22
- package/src/store/chat/slices/share/action.ts +0 -18
- package/src/store/chat/slices/share/initialState.ts +0 -7
- /package/packages/types/src/message/{image.ts → common/image.ts} +0 -0
- /package/packages/types/src/message/{video.ts → ui/video.ts} +0 -0
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
/* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
|
|
2
2
|
// Disable the auto sort key eslint rule to make the code more logic and readable
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ChatErrorType,
|
|
5
|
+
ChatImageItem,
|
|
6
|
+
ChatMessageError,
|
|
7
|
+
ChatMessagePluginError,
|
|
8
|
+
CreateMessageParams,
|
|
9
|
+
GroundingSearch,
|
|
10
|
+
MessageMetadata,
|
|
11
|
+
MessageToolCall,
|
|
12
|
+
ModelReasoning,
|
|
13
|
+
TraceEventPayloads,
|
|
14
|
+
TraceEventType,
|
|
15
|
+
UIChatMessage,
|
|
16
|
+
UpdateMessageRAGParams,
|
|
17
|
+
} from '@lobechat/types';
|
|
18
|
+
import { nanoid } from '@lobechat/utils';
|
|
4
19
|
import { copyToClipboard } from '@lobehub/ui';
|
|
5
20
|
import isEqual from 'fast-deep-equal';
|
|
6
21
|
import { SWRResponse, mutate } from 'swr';
|
|
@@ -14,21 +29,7 @@ import { ChatStore } from '@/store/chat/store';
|
|
|
14
29
|
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
|
|
15
30
|
import { useSessionStore } from '@/store/session';
|
|
16
31
|
import { sessionSelectors } from '@/store/session/selectors';
|
|
17
|
-
import {
|
|
18
|
-
ChatMessage,
|
|
19
|
-
ChatMessageError,
|
|
20
|
-
ChatMessagePluginError,
|
|
21
|
-
CreateMessageParams,
|
|
22
|
-
MessageMetadata,
|
|
23
|
-
MessageToolCall,
|
|
24
|
-
ModelReasoning,
|
|
25
|
-
} from '@/types/message';
|
|
26
|
-
import { ChatImageItem } from '@/types/message/image';
|
|
27
|
-
import { UpdateMessageRAGParams } from '@/types/message/rag';
|
|
28
|
-
import { GroundingSearch } from '@/types/search';
|
|
29
|
-
import { TraceEventPayloads } from '@/types/trace';
|
|
30
32
|
import { Action, setNamespace } from '@/utils/storeDebug';
|
|
31
|
-
import { nanoid } from '@/utils/uuid';
|
|
32
33
|
|
|
33
34
|
import type { ChatStoreState } from '../../initialState';
|
|
34
35
|
import { chatSelectors } from '../../selectors';
|
|
@@ -61,10 +62,10 @@ export interface ChatMessageAction {
|
|
|
61
62
|
messageContextId: string,
|
|
62
63
|
activeTopicId?: string,
|
|
63
64
|
type?: 'session' | 'group',
|
|
64
|
-
) => SWRResponse<
|
|
65
|
+
) => SWRResponse<UIChatMessage[]>;
|
|
65
66
|
copyMessage: (id: string, content: string) => Promise<void>;
|
|
66
67
|
refreshMessages: () => Promise<void>;
|
|
67
|
-
replaceMessages: (messages:
|
|
68
|
+
replaceMessages: (messages: UIChatMessage[]) => void;
|
|
68
69
|
// ========= ↓ Internal Method ↓ ========== //
|
|
69
70
|
// ========================================== //
|
|
70
71
|
// ========================================== //
|
|
@@ -305,7 +306,7 @@ export const chatMessage: StateCreator<
|
|
|
305
306
|
* @param messageContextId - Can be sessionId or groupId
|
|
306
307
|
*/
|
|
307
308
|
useFetchMessages: (enable, messageContextId, activeTopicId, type = 'session') =>
|
|
308
|
-
useClientDataSWR<
|
|
309
|
+
useClientDataSWR<UIChatMessage[]>(
|
|
309
310
|
enable ? [SWR_USE_FETCH_MESSAGES, messageContextId, activeTopicId, type] : null,
|
|
310
311
|
async ([, sessionId, topicId, type]: [string, string, string | undefined, string]) =>
|
|
311
312
|
type === 'session'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { UIChatMessage } from '@lobechat/types';
|
|
2
|
+
|
|
1
3
|
import { ChatGroupAgentItem, ChatGroupItem } from '@/database/schemas/chatGroup';
|
|
2
|
-
import { ChatMessage } from '@/types/message';
|
|
3
4
|
|
|
4
5
|
import type { SupervisorTodoItem } from './supervisor';
|
|
5
6
|
|
|
@@ -39,7 +40,7 @@ export interface ChatMessageState {
|
|
|
39
40
|
* whether messages have fetched
|
|
40
41
|
*/
|
|
41
42
|
messagesInit: boolean;
|
|
42
|
-
messagesMap: Record<string,
|
|
43
|
+
messagesMap: Record<string, UIChatMessage[]>;
|
|
43
44
|
/**
|
|
44
45
|
* Supervisor decision debounce timers by group ID
|
|
45
46
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChatToolPayload, UIChatMessage } from '@lobechat/types';
|
|
2
2
|
|
|
3
3
|
import { MessageDispatch, messagesReducer } from './reducer';
|
|
4
4
|
|
|
5
5
|
describe('messagesReducer', () => {
|
|
6
|
-
let initialState:
|
|
6
|
+
let initialState: UIChatMessage[];
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
initialState = [
|
|
@@ -115,7 +115,7 @@ describe('messagesReducer', () => {
|
|
|
115
115
|
role: 'user',
|
|
116
116
|
meta: {},
|
|
117
117
|
extra: { abc: '1' },
|
|
118
|
-
} as
|
|
118
|
+
} as UIChatMessage,
|
|
119
119
|
...initialState,
|
|
120
120
|
],
|
|
121
121
|
payload,
|
|
@@ -189,7 +189,7 @@ describe('messagesReducer', () => {
|
|
|
189
189
|
|
|
190
190
|
describe('updateMessagePlugin', () => {
|
|
191
191
|
it('should update the plugin of a tool message', () => {
|
|
192
|
-
const toolMessage:
|
|
192
|
+
const toolMessage: UIChatMessage = {
|
|
193
193
|
id: 'toolMessage',
|
|
194
194
|
role: 'tool',
|
|
195
195
|
content: 'Tool content',
|
|
@@ -302,7 +302,7 @@ describe('messagesReducer', () => {
|
|
|
302
302
|
};
|
|
303
303
|
|
|
304
304
|
const newState = messagesReducer(
|
|
305
|
-
[...initialState, { id: messageId, role: 'assistant', content: '' } as
|
|
305
|
+
[...initialState, { id: messageId, role: 'assistant', content: '' } as UIChatMessage],
|
|
306
306
|
payload,
|
|
307
307
|
);
|
|
308
308
|
const updatedMessage = newState.find((m) => m.id === messageId);
|
|
@@ -330,7 +330,7 @@ describe('messagesReducer', () => {
|
|
|
330
330
|
};
|
|
331
331
|
|
|
332
332
|
const newState = messagesReducer(
|
|
333
|
-
[...initialState, { id: messageId, role: 'assistant', content: '' } as
|
|
333
|
+
[...initialState, { id: messageId, role: 'assistant', content: '' } as UIChatMessage],
|
|
334
334
|
payload,
|
|
335
335
|
);
|
|
336
336
|
const updatedMessage = newState.find((m) => m.id === messageId);
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import isEqual from 'fast-deep-equal';
|
|
2
|
-
import { produce } from 'immer';
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
|
-
ChatMessage,
|
|
6
2
|
ChatMessageExtra,
|
|
7
3
|
ChatPluginPayload,
|
|
8
4
|
ChatToolPayload,
|
|
9
5
|
CreateMessageParams,
|
|
10
|
-
|
|
6
|
+
UIChatMessage,
|
|
7
|
+
} from '@lobechat/types';
|
|
8
|
+
import isEqual from 'fast-deep-equal';
|
|
9
|
+
import { produce } from 'immer';
|
|
10
|
+
|
|
11
11
|
import { merge } from '@/utils/merge';
|
|
12
12
|
|
|
13
13
|
interface UpdateMessages {
|
|
14
14
|
type: 'updateMessages';
|
|
15
|
-
value:
|
|
15
|
+
value: UIChatMessage[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
interface UpdateMessage {
|
|
19
19
|
id: string;
|
|
20
20
|
type: 'updateMessage';
|
|
21
|
-
value: Partial<
|
|
21
|
+
value: Partial<UIChatMessage>;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
interface CreateMessage {
|
|
@@ -88,7 +88,10 @@ export type MessageDispatch =
|
|
|
88
88
|
| DeleteMessageTool
|
|
89
89
|
| DeleteMessages;
|
|
90
90
|
|
|
91
|
-
export const messagesReducer = (
|
|
91
|
+
export const messagesReducer = (
|
|
92
|
+
state: UIChatMessage[],
|
|
93
|
+
payload: MessageDispatch,
|
|
94
|
+
): UIChatMessage[] => {
|
|
92
95
|
switch (payload.type) {
|
|
93
96
|
case 'updateMessage': {
|
|
94
97
|
return produce(state, (draftState) => {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UIChatMessage } from '@lobechat/types';
|
|
2
|
+
import { LobeAgentConfig } from '@lobechat/types';
|
|
1
3
|
import { act } from '@testing-library/react';
|
|
2
4
|
import { describe, expect, it } from 'vitest';
|
|
3
5
|
|
|
@@ -8,8 +10,6 @@ import { ChatStore } from '@/store/chat';
|
|
|
8
10
|
import { initialState } from '@/store/chat/initialState';
|
|
9
11
|
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
|
|
10
12
|
import { createServerConfigStore } from '@/store/serverConfig/store';
|
|
11
|
-
import { LobeAgentConfig } from '@/types/agent';
|
|
12
|
-
import { ChatMessage } from '@/types/message';
|
|
13
13
|
import { merge } from '@/utils/merge';
|
|
14
14
|
|
|
15
15
|
import { chatSelectors } from './selectors';
|
|
@@ -45,7 +45,7 @@ const mockMessages = [
|
|
|
45
45
|
},
|
|
46
46
|
],
|
|
47
47
|
},
|
|
48
|
-
] as
|
|
48
|
+
] as UIChatMessage[];
|
|
49
49
|
|
|
50
50
|
const mockReasoningMessages = [
|
|
51
51
|
{
|
|
@@ -66,7 +66,7 @@ const mockReasoningMessages = [
|
|
|
66
66
|
content: 'Reasoning Content',
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
|
-
] as
|
|
69
|
+
] as UIChatMessage[];
|
|
70
70
|
|
|
71
71
|
const mockedChats = [
|
|
72
72
|
{
|
|
@@ -105,7 +105,7 @@ const mockedChats = [
|
|
|
105
105
|
},
|
|
106
106
|
],
|
|
107
107
|
},
|
|
108
|
-
] as
|
|
108
|
+
] as UIChatMessage[];
|
|
109
109
|
|
|
110
110
|
const mockChatStore = {
|
|
111
111
|
messagesMap: {
|
|
@@ -172,7 +172,7 @@ describe('chatSelectors', () => {
|
|
|
172
172
|
apiName: 'ttt',
|
|
173
173
|
type: 'default',
|
|
174
174
|
},
|
|
175
|
-
} as
|
|
175
|
+
} as UIChatMessage;
|
|
176
176
|
const state = merge(initialStore, {
|
|
177
177
|
messagesMap: {
|
|
178
178
|
[messageMapKey('abc')]: [...mockMessages, toolMessage],
|
|
@@ -350,7 +350,7 @@ describe('chatSelectors', () => {
|
|
|
350
350
|
{ id: '3', role: 'tool', content: 'Tool message 1' },
|
|
351
351
|
{ id: '4', role: 'user', content: 'Query' },
|
|
352
352
|
{ id: '5', role: 'tool', tools: [] },
|
|
353
|
-
] as
|
|
353
|
+
] as UIChatMessage[];
|
|
354
354
|
const state: Partial<ChatStore> = {
|
|
355
355
|
activeId: 'test-id',
|
|
356
356
|
messagesMap: {
|
|
@@ -366,7 +366,7 @@ describe('chatSelectors', () => {
|
|
|
366
366
|
const messages = [
|
|
367
367
|
{ id: '1', role: 'user', content: 'Hello' },
|
|
368
368
|
{ id: '2', role: 'assistant', content: 'Hi' },
|
|
369
|
-
] as
|
|
369
|
+
] as UIChatMessage[];
|
|
370
370
|
const state: Partial<ChatStore> = {
|
|
371
371
|
activeId: 'test-id',
|
|
372
372
|
messagesMap: {
|
|
@@ -455,7 +455,7 @@ describe('chatSelectors', () => {
|
|
|
455
455
|
groupId: 'group-123',
|
|
456
456
|
agentId: 'agent-456',
|
|
457
457
|
},
|
|
458
|
-
] as
|
|
458
|
+
] as UIChatMessage[];
|
|
459
459
|
|
|
460
460
|
const state = merge(initialStore, {
|
|
461
461
|
messagesMap: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChatFileItem, UIChatMessage } from '@lobechat/types';
|
|
2
|
+
|
|
1
3
|
import { DEFAULT_USER_AVATAR } from '@/const/meta';
|
|
2
4
|
import { INBOX_SESSION_ID } from '@/const/session';
|
|
3
5
|
import { useAgentStore } from '@/store/agent';
|
|
@@ -7,12 +9,11 @@ import { useSessionStore } from '@/store/session';
|
|
|
7
9
|
import { sessionMetaSelectors } from '@/store/session/selectors';
|
|
8
10
|
import { useUserStore } from '@/store/user';
|
|
9
11
|
import { userProfileSelectors } from '@/store/user/selectors';
|
|
10
|
-
import { ChatFileItem, ChatMessage } from '@/types/message';
|
|
11
12
|
|
|
12
13
|
import { chatHelpers } from '../../helpers';
|
|
13
14
|
import type { ChatStoreState } from '../../initialState';
|
|
14
15
|
|
|
15
|
-
const getMeta = (message:
|
|
16
|
+
const getMeta = (message: UIChatMessage) => {
|
|
16
17
|
switch (message.role) {
|
|
17
18
|
case 'user': {
|
|
18
19
|
return {
|
|
@@ -40,7 +41,7 @@ const getMeta = (message: ChatMessage) => {
|
|
|
40
41
|
|
|
41
42
|
const getBaseChatsByKey =
|
|
42
43
|
(key: string) =>
|
|
43
|
-
(s: ChatStoreState):
|
|
44
|
+
(s: ChatStoreState): UIChatMessage[] => {
|
|
44
45
|
const messages = s.messagesMap[key] || [];
|
|
45
46
|
|
|
46
47
|
return messages.map((i) => ({ ...i, meta: getMeta(i) }));
|
|
@@ -51,7 +52,7 @@ const currentChatKey = (s: ChatStoreState) => messageMapKey(s.activeId, s.active
|
|
|
51
52
|
/**
|
|
52
53
|
* Current active raw message list, include thread messages
|
|
53
54
|
*/
|
|
54
|
-
const activeBaseChats = (s: ChatStoreState):
|
|
55
|
+
const activeBaseChats = (s: ChatStoreState): UIChatMessage[] => {
|
|
55
56
|
if (!s.activeId) return [];
|
|
56
57
|
|
|
57
58
|
return getBaseChatsByKey(currentChatKey(s))(s);
|
|
@@ -66,7 +67,7 @@ const activeBaseChatsWithoutTool = (s: ChatStoreState) => {
|
|
|
66
67
|
return messages.filter((m) => m.role !== 'tool');
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
const getChatsWithThread = (s: ChatStoreState, messages:
|
|
70
|
+
const getChatsWithThread = (s: ChatStoreState, messages: UIChatMessage[]) => {
|
|
70
71
|
// 如果没有 activeThreadId,则返回所有的主消息
|
|
71
72
|
if (!s.activeThreadId) return messages.filter((m) => !m.threadId);
|
|
72
73
|
|
|
@@ -82,7 +83,7 @@ const getChatsWithThread = (s: ChatStoreState, messages: ChatMessage[]) => {
|
|
|
82
83
|
|
|
83
84
|
// ============= Main Display Chats ========== //
|
|
84
85
|
// =========================================== //
|
|
85
|
-
const mainDisplayChats = (s: ChatStoreState):
|
|
86
|
+
const mainDisplayChats = (s: ChatStoreState): UIChatMessage[] => {
|
|
86
87
|
const displayChats = activeBaseChatsWithoutTool(s);
|
|
87
88
|
|
|
88
89
|
return getChatsWithThread(s, displayChats);
|
|
@@ -90,13 +91,13 @@ const mainDisplayChats = (s: ChatStoreState): ChatMessage[] => {
|
|
|
90
91
|
|
|
91
92
|
const mainDisplayChatIDs = (s: ChatStoreState) => mainDisplayChats(s).map((s) => s.id);
|
|
92
93
|
|
|
93
|
-
const mainAIChats = (s: ChatStoreState):
|
|
94
|
+
const mainAIChats = (s: ChatStoreState): UIChatMessage[] => {
|
|
94
95
|
const messages = activeBaseChats(s);
|
|
95
96
|
|
|
96
97
|
return getChatsWithThread(s, messages);
|
|
97
98
|
};
|
|
98
99
|
|
|
99
|
-
const mainAIChatsWithHistoryConfig = (s: ChatStoreState):
|
|
100
|
+
const mainAIChatsWithHistoryConfig = (s: ChatStoreState): UIChatMessage[] => {
|
|
100
101
|
const chats = mainAIChats(s);
|
|
101
102
|
const enableHistoryCount = agentChatConfigSelectors.enableHistoryCount(useAgentStore.getState());
|
|
102
103
|
const historyCount = agentChatConfigSelectors.historyCount(useAgentStore.getState());
|
|
@@ -237,7 +238,7 @@ const inboxActiveTopicMessages = (state: ChatStoreState) => {
|
|
|
237
238
|
*/
|
|
238
239
|
const getThreadMessages =
|
|
239
240
|
(agentId: string) =>
|
|
240
|
-
(s: ChatStoreState):
|
|
241
|
+
(s: ChatStoreState): UIChatMessage[] => {
|
|
241
242
|
if (!agentId) return [];
|
|
242
243
|
|
|
243
244
|
const allMessages = activeBaseChats(s);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { contextSupervisorMakeDecision } from '@lobechat/prompts';
|
|
2
|
-
import {
|
|
2
|
+
import { GroupMemberWithAgent, UIChatMessage } from '@lobechat/types';
|
|
3
3
|
|
|
4
4
|
import { aiChatService } from '@/services/aiChat';
|
|
5
5
|
|
|
@@ -43,7 +43,7 @@ export interface SupervisorContext {
|
|
|
43
43
|
allowDM?: boolean;
|
|
44
44
|
availableAgents: GroupMemberWithAgent[];
|
|
45
45
|
groupId: string;
|
|
46
|
-
messages:
|
|
46
|
+
messages: UIChatMessage[];
|
|
47
47
|
model: string;
|
|
48
48
|
provider: string;
|
|
49
49
|
// Group scene controls which tools are exposed (e.g., todos only in 'productive')
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_INBOX_AVATAR,
|
|
3
|
+
LOADING_FLAT,
|
|
4
|
+
PLUGIN_SCHEMA_API_MD5_PREFIX,
|
|
5
|
+
PLUGIN_SCHEMA_SEPARATOR,
|
|
6
|
+
} from '@lobechat/const';
|
|
1
7
|
import { ToolNameResolver } from '@lobechat/context-engine';
|
|
8
|
+
import { ChatToolPayload, MessageToolCall, UIChatMessage } from '@lobechat/types';
|
|
2
9
|
import { act, renderHook } from '@testing-library/react';
|
|
3
10
|
import { Mock, afterEach, describe, expect, it, vi } from 'vitest';
|
|
4
11
|
|
|
5
|
-
import { LOADING_FLAT } from '@/const/message';
|
|
6
|
-
import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
|
|
7
|
-
import { PLUGIN_SCHEMA_API_MD5_PREFIX, PLUGIN_SCHEMA_SEPARATOR } from '@/const/plugin';
|
|
8
12
|
import { chatService } from '@/services/chat';
|
|
9
13
|
import { messageService } from '@/services/message';
|
|
10
14
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
11
15
|
import { useChatStore } from '@/store/chat/store';
|
|
12
16
|
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
|
|
13
17
|
import { useToolStore } from '@/store/tool';
|
|
14
|
-
import { ChatMessage, ChatToolPayload, MessageToolCall } from '@/types/message';
|
|
15
18
|
|
|
16
19
|
const invokeStandaloneTypePlugin = useChatStore.getState().invokeStandaloneTypePlugin;
|
|
17
20
|
|
|
@@ -40,7 +43,7 @@ describe('ChatPluginAction', () => {
|
|
|
40
43
|
id: messageId,
|
|
41
44
|
role: 'tool',
|
|
42
45
|
content: 'Tool content to summarize',
|
|
43
|
-
} as
|
|
46
|
+
} as UIChatMessage;
|
|
44
47
|
|
|
45
48
|
const internal_coreProcessMessageMock = vi.fn();
|
|
46
49
|
|
|
@@ -88,7 +91,7 @@ describe('ChatPluginAction', () => {
|
|
|
88
91
|
id: messageId,
|
|
89
92
|
role: 'user',
|
|
90
93
|
content: 'User message',
|
|
91
|
-
} as
|
|
94
|
+
} as UIChatMessage;
|
|
92
95
|
|
|
93
96
|
const internal_coreProcessMessageMock = vi.fn();
|
|
94
97
|
|
|
@@ -326,7 +329,7 @@ describe('ChatPluginAction', () => {
|
|
|
326
329
|
arguments: '{}',
|
|
327
330
|
},
|
|
328
331
|
],
|
|
329
|
-
} as
|
|
332
|
+
} as UIChatMessage;
|
|
330
333
|
|
|
331
334
|
const invokeStandaloneTypePluginMock = vi.fn();
|
|
332
335
|
const invokeMarkdownTypePluginMock = vi.fn();
|
|
@@ -420,7 +423,7 @@ describe('ChatPluginAction', () => {
|
|
|
420
423
|
arguments: '{}',
|
|
421
424
|
},
|
|
422
425
|
],
|
|
423
|
-
} as
|
|
426
|
+
} as UIChatMessage;
|
|
424
427
|
|
|
425
428
|
const invokeStandaloneTypePluginMock = vi.fn();
|
|
426
429
|
const invokeMarkdownTypePluginMock = vi.fn();
|
|
@@ -818,7 +821,7 @@ describe('ChatPluginAction', () => {
|
|
|
818
821
|
arguments: '{}',
|
|
819
822
|
},
|
|
820
823
|
tool_call_id: 'tool-id',
|
|
821
|
-
} as
|
|
824
|
+
} as UIChatMessage;
|
|
822
825
|
|
|
823
826
|
const internal_invokeDifferentTypePluginMock = vi.fn();
|
|
824
827
|
act(() => {
|
|
@@ -856,7 +859,7 @@ describe('ChatPluginAction', () => {
|
|
|
856
859
|
},
|
|
857
860
|
tool_call_id: 'tool-id',
|
|
858
861
|
pluginError: { message: 'Previous error', type: 'ProviderBizError' },
|
|
859
|
-
} as
|
|
862
|
+
} as UIChatMessage;
|
|
860
863
|
|
|
861
864
|
const internal_updateMessageErrorMock = vi.fn();
|
|
862
865
|
|
|
@@ -894,14 +897,14 @@ describe('ChatPluginAction', () => {
|
|
|
894
897
|
plugin: { identifier: identifier, arguments: '{"oldKey":"oldValue"}' },
|
|
895
898
|
tool_call_id: toolCallId,
|
|
896
899
|
parentId,
|
|
897
|
-
} as
|
|
900
|
+
} as UIChatMessage;
|
|
898
901
|
|
|
899
902
|
const assistantMessage = {
|
|
900
903
|
id: parentId,
|
|
901
904
|
role: 'assistant',
|
|
902
905
|
content: 'Assistant content',
|
|
903
906
|
tools: [{ identifier: identifier, arguments: '{"oldKey":"oldValue"}', id: toolCallId }],
|
|
904
|
-
} as
|
|
907
|
+
} as UIChatMessage;
|
|
905
908
|
|
|
906
909
|
act(() => {
|
|
907
910
|
useChatStore.setState({
|
|
@@ -1138,7 +1141,7 @@ describe('ChatPluginAction', () => {
|
|
|
1138
1141
|
role: 'assistant',
|
|
1139
1142
|
content: 'Assistant content',
|
|
1140
1143
|
tools: [{ identifier: identifier, arguments: '{"oldKey":"oldValue"}', id: toolCallId }],
|
|
1141
|
-
} as
|
|
1144
|
+
} as UIChatMessage;
|
|
1142
1145
|
|
|
1143
1146
|
act(() => {
|
|
1144
1147
|
useChatStore.setState({
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
|
|
2
|
+
import { LOADING_FLAT } from '@lobechat/const';
|
|
2
3
|
import { ToolNameResolver } from '@lobechat/context-engine';
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
ChatErrorType,
|
|
6
|
+
ChatMessageError,
|
|
7
|
+
ChatToolPayload,
|
|
8
|
+
CreateMessageParams,
|
|
9
|
+
MessageToolCall,
|
|
10
|
+
ToolsCallingContext,
|
|
11
|
+
UIChatMessage,
|
|
12
|
+
} from '@lobechat/types';
|
|
4
13
|
import { LobeChatPluginManifest, PluginErrorType } from '@lobehub/chat-plugin-sdk';
|
|
5
14
|
import isEqual from 'fast-deep-equal';
|
|
6
15
|
import { t } from 'i18next';
|
|
7
16
|
import { StateCreator } from 'zustand/vanilla';
|
|
8
17
|
|
|
9
|
-
import { LOADING_FLAT } from '@/const/message';
|
|
10
18
|
import { chatService } from '@/services/chat';
|
|
11
19
|
import { mcpService } from '@/services/mcp';
|
|
12
20
|
import { messageService } from '@/services/message';
|
|
@@ -14,14 +22,6 @@ import { ChatStore } from '@/store/chat/store';
|
|
|
14
22
|
import { useToolStore } from '@/store/tool';
|
|
15
23
|
import { pluginSelectors } from '@/store/tool/selectors';
|
|
16
24
|
import { builtinTools } from '@/tools';
|
|
17
|
-
import {
|
|
18
|
-
ChatMessage,
|
|
19
|
-
ChatMessageError,
|
|
20
|
-
ChatToolPayload,
|
|
21
|
-
CreateMessageParams,
|
|
22
|
-
MessageToolCall,
|
|
23
|
-
ToolsCallingContext,
|
|
24
|
-
} from '@/types/message';
|
|
25
25
|
import { merge } from '@/utils/merge';
|
|
26
26
|
import { safeParseJSON } from '@/utils/safeParseJSON';
|
|
27
27
|
import { setNamespace } from '@/utils/storeDebug';
|
|
@@ -245,7 +245,7 @@ export const chatPlugin: StateCreator<
|
|
|
245
245
|
name: undefined,
|
|
246
246
|
tool_call_id: undefined,
|
|
247
247
|
},
|
|
248
|
-
] as
|
|
248
|
+
] as UIChatMessage[],
|
|
249
249
|
message.id,
|
|
250
250
|
);
|
|
251
251
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { UIChatMessage } from '@lobechat/types';
|
|
1
2
|
import { describe, expect, it } from 'vitest';
|
|
2
3
|
|
|
3
4
|
import type { ChatStoreState } from '@/store/chat';
|
|
4
|
-
import { ChatMessage } from '@/types/message';
|
|
5
5
|
|
|
6
6
|
import { chatPortalSelectors } from './selectors';
|
|
7
7
|
|
|
@@ -119,7 +119,7 @@ describe('chatDockSelectors', () => {
|
|
|
119
119
|
role: 'user',
|
|
120
120
|
meta: {},
|
|
121
121
|
sessionId: 'test-id',
|
|
122
|
-
} as
|
|
122
|
+
} as UIChatMessage,
|
|
123
123
|
],
|
|
124
124
|
},
|
|
125
125
|
});
|
|
@@ -140,7 +140,7 @@ describe('chatDockSelectors', () => {
|
|
|
140
140
|
role: 'user',
|
|
141
141
|
meta: {},
|
|
142
142
|
sessionId: 'test-id',
|
|
143
|
-
} as
|
|
143
|
+
} as UIChatMessage,
|
|
144
144
|
],
|
|
145
145
|
},
|
|
146
146
|
});
|
|
@@ -160,7 +160,7 @@ describe('chatDockSelectors', () => {
|
|
|
160
160
|
role: 'user',
|
|
161
161
|
meta: {},
|
|
162
162
|
sessionId: 'test-id',
|
|
163
|
-
} as
|
|
163
|
+
} as UIChatMessage,
|
|
164
164
|
],
|
|
165
165
|
},
|
|
166
166
|
});
|
|
@@ -192,7 +192,7 @@ ${htmlContent}
|
|
|
192
192
|
role: 'user',
|
|
193
193
|
meta: {},
|
|
194
194
|
sessionId: 'test-id',
|
|
195
|
-
} as
|
|
195
|
+
} as UIChatMessage,
|
|
196
196
|
],
|
|
197
197
|
},
|
|
198
198
|
});
|
|
@@ -213,7 +213,7 @@ ${htmlContent}
|
|
|
213
213
|
role: 'user',
|
|
214
214
|
meta: {},
|
|
215
215
|
sessionId: 'test-id',
|
|
216
|
-
} as
|
|
216
|
+
} as UIChatMessage,
|
|
217
217
|
],
|
|
218
218
|
},
|
|
219
219
|
});
|
|
@@ -232,7 +232,7 @@ ${htmlContent}
|
|
|
232
232
|
role: 'user',
|
|
233
233
|
meta: {},
|
|
234
234
|
sessionId: 'test-id',
|
|
235
|
-
} as
|
|
235
|
+
} as UIChatMessage,
|
|
236
236
|
],
|
|
237
237
|
},
|
|
238
238
|
});
|
|
@@ -251,7 +251,7 @@ ${htmlContent}
|
|
|
251
251
|
role: 'user',
|
|
252
252
|
meta: {},
|
|
253
253
|
sessionId: 'test-id',
|
|
254
|
-
} as
|
|
254
|
+
} as UIChatMessage,
|
|
255
255
|
],
|
|
256
256
|
},
|
|
257
257
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UIChatMessage } from '@lobechat/types';
|
|
1
2
|
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
2
3
|
import { mutate } from 'swr';
|
|
3
4
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
@@ -7,7 +8,6 @@ import { chatService } from '@/services/chat';
|
|
|
7
8
|
import { threadService } from '@/services/thread';
|
|
8
9
|
import { messageMapKey } from '@/store/chat/utils/messageMapKey';
|
|
9
10
|
import { useSessionStore } from '@/store/session';
|
|
10
|
-
import { ChatMessage } from '@/types/message';
|
|
11
11
|
import { ThreadItem, ThreadStatus, ThreadType } from '@/types/topic';
|
|
12
12
|
|
|
13
13
|
import { useChatStore } from '../../store';
|
|
@@ -426,7 +426,7 @@ describe('thread action', () => {
|
|
|
426
426
|
});
|
|
427
427
|
});
|
|
428
428
|
|
|
429
|
-
const messages:
|
|
429
|
+
const messages: UIChatMessage[] = [
|
|
430
430
|
{
|
|
431
431
|
content: 'Hello',
|
|
432
432
|
createdAt: Date.now(),
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/* eslint-disable sort-keys-fix/sort-keys-fix, typescript-sort-keys/interface */
|
|
2
2
|
// Disable the auto sort key eslint rule to make the code more logic and readable
|
|
3
|
+
import { LOADING_FLAT, THREAD_DRAFT_ID, isDeprecatedEdition } from '@lobechat/const';
|
|
3
4
|
import { chainSummaryTitle } from '@lobechat/prompts';
|
|
5
|
+
import {
|
|
6
|
+
CreateMessageParams,
|
|
7
|
+
SendThreadMessageParams,
|
|
8
|
+
ThreadItem,
|
|
9
|
+
ThreadType,
|
|
10
|
+
UIChatMessage,
|
|
11
|
+
} from '@lobechat/types';
|
|
4
12
|
import isEqual from 'fast-deep-equal';
|
|
5
13
|
import { SWRResponse, mutate } from 'swr';
|
|
6
14
|
import { StateCreator } from 'zustand/vanilla';
|
|
7
15
|
|
|
8
|
-
import { LOADING_FLAT, THREAD_DRAFT_ID } from '@/const/message';
|
|
9
|
-
import { isDeprecatedEdition } from '@/const/version';
|
|
10
16
|
import { useClientDataSWR } from '@/libs/swr';
|
|
11
17
|
import { chatService } from '@/services/chat';
|
|
12
18
|
import { threadService } from '@/services/thread';
|
|
@@ -16,8 +22,6 @@ import { globalHelpers } from '@/store/global/helpers';
|
|
|
16
22
|
import { useSessionStore } from '@/store/session';
|
|
17
23
|
import { useUserStore } from '@/store/user';
|
|
18
24
|
import { systemAgentSelectors } from '@/store/user/selectors';
|
|
19
|
-
import { ChatMessage, CreateMessageParams, SendThreadMessageParams } from '@/types/message';
|
|
20
|
-
import { ThreadItem, ThreadType } from '@/types/topic';
|
|
21
25
|
import { merge } from '@/utils/merge';
|
|
22
26
|
import { setNamespace } from '@/utils/storeDebug';
|
|
23
27
|
|
|
@@ -46,7 +50,7 @@ export interface ChatThreadAction {
|
|
|
46
50
|
openThreadInPortal: (threadId: string, sourceMessageId: string) => void;
|
|
47
51
|
closeThreadPortal: () => void;
|
|
48
52
|
useFetchThreads: (enable: boolean, topicId?: string) => SWRResponse<ThreadItem[]>;
|
|
49
|
-
summaryThreadTitle: (threadId: string, messages:
|
|
53
|
+
summaryThreadTitle: (threadId: string, messages: UIChatMessage[]) => Promise<void>;
|
|
50
54
|
updateThreadTitle: (id: string, title: string) => Promise<void>;
|
|
51
55
|
removeThread: (id: string) => Promise<void>;
|
|
52
56
|
switchThread: (id: string) => void;
|