@lobehub/chat 0.115.2 → 0.115.4
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/package.json +1 -1
- package/src/app/chat/features/SessionListContent/DefaultMode.tsx +2 -1
- package/src/app/chat/features/SessionListContent/List/Item/index.tsx +2 -1
- package/src/app/settings/agent/Agent.tsx +2 -1
- package/src/app/settings/common/Common.tsx +2 -1
- package/src/app/settings/llm/LLM/Checker.tsx +1 -1
- package/src/app/settings/llm/LLM/index.tsx +2 -1
- package/src/app/settings/tts/TTS/index.tsx +2 -1
- package/src/database/models/__tests__/message.test.ts +1 -1
- package/src/database/models/message.ts +1 -1
- package/src/features/AgentSetting/AgentConfig/index.tsx +2 -1
- package/src/features/AgentSetting/AgentMeta/index.tsx +2 -1
- package/src/features/AgentSetting/AgentTTS/SelectWithTTSPreview.tsx +1 -1
- package/src/features/AgentSetting/AgentTTS/index.tsx +3 -2
- package/src/features/ChatInput/ActionBar/ModelSwitch.tsx +2 -1
- package/src/features/ChatInput/STT/index.tsx +1 -1
- package/src/features/Conversation/ChatList/Error/ApiKeyForm.tsx +2 -1
- package/src/features/Conversation/ChatList/Extras/Assistant.test.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/Assistant.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/TTS/InitPlayer.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/TTS/Player.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/TTS/index.tsx +3 -2
- package/src/features/Conversation/ChatList/Extras/Translate.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/User.tsx +1 -1
- package/src/features/Conversation/ChatList/Extras/type.ts +1 -1
- package/src/features/Conversation/ChatList/Messages/Assistant.tsx +1 -1
- package/src/features/Conversation/ChatList/Messages/Default.tsx +1 -1
- package/src/features/Conversation/ChatList/Messages/Function.tsx +1 -1
- package/src/features/Conversation/ChatList/Messages/User.tsx +1 -1
- package/src/features/Conversation/index.tsx +2 -1
- package/src/features/PluginDevModal/LocalForm.tsx +3 -2
- package/src/hooks/useSTT.ts +2 -1
- package/src/hooks/useTTS.ts +2 -1
- package/src/services/__tests__/chat.test.ts +1 -1
- package/src/services/__tests__/message.test.ts +1 -1
- package/src/services/_header.ts +2 -2
- package/src/services/chat.ts +1 -1
- package/src/services/config.ts +3 -2
- package/src/services/message.ts +2 -2
- package/src/store/chat/helpers.test.ts +1 -1
- package/src/store/chat/helpers.ts +1 -1
- package/src/store/chat/initialState.ts +9 -47
- package/src/store/chat/selectors.ts +3 -0
- package/src/store/chat/{actions/enhance.test.ts → slices/enchance/action.test.ts} +2 -2
- package/src/store/chat/{actions/message.test.ts → slices/message/action.test.ts} +2 -2
- package/src/store/chat/{actions/message.ts → slices/message/action.ts} +3 -3
- package/src/store/chat/slices/message/initialState.ts +29 -0
- package/src/store/chat/{reducers/message.test.ts → slices/message/reducer.test.ts} +2 -2
- package/src/store/chat/{reducers/message.ts → slices/message/reducer.ts} +1 -1
- package/src/store/chat/{selectors/__tests__/chat.test.ts → slices/message/selectors.test.ts} +2 -2
- package/src/store/chat/{selectors/chat.ts → slices/message/selectors.ts} +3 -3
- package/src/store/chat/{actions/share.ts → slices/share/action.ts} +2 -2
- package/src/store/chat/slices/share/initialState.ts +7 -0
- package/src/store/chat/{actions/plugin.ts → slices/tool/action.ts} +2 -4
- package/src/store/chat/slices/tool/initialState.ts +7 -0
- package/src/store/chat/{actions/topic.test.ts → slices/topic/action.test.ts} +2 -2
- package/src/store/chat/{actions/topic.ts → slices/topic/action.ts} +3 -2
- package/src/store/chat/slices/topic/initialState.ts +23 -0
- package/src/store/chat/{selectors/__tests__/topic.test.ts → slices/topic/selectors.test.ts} +1 -1
- package/src/store/chat/{selectors/topic.ts → slices/topic/selectors.ts} +1 -1
- package/src/store/chat/store.ts +5 -5
- package/src/store/global/helpers.ts +1 -1
- package/src/store/global/index.ts +0 -1
- package/src/store/global/initialState.ts +6 -61
- package/src/store/global/selectors.ts +2 -2
- package/src/store/global/slices/{common.ts → common/action.ts} +3 -3
- package/src/store/global/slices/common/initialState.ts +55 -0
- package/src/store/global/{selectors/preference.ts → slices/common/selectors.ts} +1 -1
- package/src/store/global/slices/{settings.ts → settings/action.ts} +12 -4
- package/src/store/global/slices/settings/initialState.ts +15 -0
- package/src/store/global/{selectors/settings.test.ts → slices/settings/selectors.test.ts} +2 -2
- package/src/store/global/{selectors/settings.ts → slices/settings/selectors.ts} +3 -4
- package/src/store/global/store.ts +4 -18
- package/src/store/session/slices/agent/selectors.ts +2 -1
- package/src/store/session/slices/session/action.ts +2 -1
- package/src/tools/dalle/Render/ToolBar.tsx +2 -1
- package/src/types/exportConfig.ts +1 -1
- package/src/types/{chatMessage.ts → message/index.ts} +2 -2
- package/src/types/settings.ts +0 -29
- package/src/utils/fetch.ts +1 -1
- package/src/store/chat/selectors/index.ts +0 -3
- package/src/store/global/slices/agent.ts +0 -34
- /package/src/store/chat/{actions/enhance.ts → slices/enchance/action.ts} +0 -0
- /package/src/store/chat/{selectors/enchance.ts → slices/enchance/selectors.ts} +0 -0
- /package/src/store/chat/{actions/plugin.test.ts → slices/tool/action.test.ts} +0 -0
- /package/src/store/global/{selectors/__snapshots__/settings.test.ts.snap → slices/settings/__snapshots__/selectors.test.ts.snap} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.115.4](https://github.com/lobehub/lobe-chat/compare/v0.115.3...v0.115.4)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2023-12-23**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor the ChatMessage type.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor the ChatMessage type ([40375bd](https://github.com/lobehub/lobe-chat/commit/40375bd))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.115.3](https://github.com/lobehub/lobe-chat/compare/v0.115.2...v0.115.3)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2023-12-23**</sup>
|
|
33
|
+
|
|
34
|
+
#### ♻ Code Refactoring
|
|
35
|
+
|
|
36
|
+
- **misc**: Refactor and clean global store and chat store.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### Code refactoring
|
|
44
|
+
|
|
45
|
+
- **misc**: Refactor and clean global store and chat store, closes [#774](https://github.com/lobehub/lobe-chat/issues/774) ([6120042](https://github.com/lobehub/lobe-chat/commit/6120042))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.115.2](https://github.com/lobehub/lobe-chat/compare/v0.115.1...v0.115.2)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2023-12-23**</sup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.115.
|
|
3
|
+
"version": "0.115.4",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -3,7 +3,8 @@ import isEqual from 'fast-deep-equal';
|
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useGlobalStore } from '@/store/global';
|
|
7
|
+
import { preferenceSelectors } from '@/store/global/selectors';
|
|
7
8
|
import { useSessionStore } from '@/store/session';
|
|
8
9
|
import { sessionSelectors } from '@/store/session/selectors';
|
|
9
10
|
|
|
@@ -5,7 +5,8 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
5
5
|
import { shallow } from 'zustand/shallow';
|
|
6
6
|
|
|
7
7
|
import { useChatStore } from '@/store/chat';
|
|
8
|
-
import {
|
|
8
|
+
import { useGlobalStore } from '@/store/global';
|
|
9
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
9
10
|
import { useSessionStore } from '@/store/session';
|
|
10
11
|
import { sessionHelpers } from '@/store/session/helpers';
|
|
11
12
|
import { agentSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
@@ -2,9 +2,10 @@ import isEqual from 'fast-deep-equal';
|
|
|
2
2
|
import { memo } from 'react';
|
|
3
3
|
|
|
4
4
|
import AgentSetting from '@/features/AgentSetting';
|
|
5
|
-
import {
|
|
5
|
+
import { useGlobalStore } from '@/store/global';
|
|
6
6
|
import { useSwitchSideBarOnInit } from '@/store/global/hooks/useSwitchSettingsOnInit';
|
|
7
7
|
import { SettingsTabs } from '@/store/global/initialState';
|
|
8
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
8
9
|
|
|
9
10
|
const Agent = memo(() => {
|
|
10
11
|
useSwitchSideBarOnInit(SettingsTabs.Agent);
|
|
@@ -12,7 +12,8 @@ import AvatarWithUpload from '@/features/AvatarWithUpload';
|
|
|
12
12
|
import { localeOptions } from '@/locales/options';
|
|
13
13
|
import { useChatStore } from '@/store/chat';
|
|
14
14
|
import { useFileStore } from '@/store/file';
|
|
15
|
-
import {
|
|
15
|
+
import { useGlobalStore } from '@/store/global';
|
|
16
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
16
17
|
import { useSessionStore } from '@/store/session';
|
|
17
18
|
import { useToolStore } from '@/store/tool';
|
|
18
19
|
import { switchLang } from '@/utils/switchLang';
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
9
|
import { chatService } from '@/services/chat';
|
|
10
|
-
import { ChatMessageError } from '@/types/
|
|
10
|
+
import { ChatMessageError } from '@/types/message';
|
|
11
11
|
|
|
12
12
|
import { getModelList } from './getModelList';
|
|
13
13
|
|
|
@@ -7,7 +7,8 @@ import { memo } from 'react';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
|
|
9
9
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
10
|
-
import {
|
|
10
|
+
import { useEffectAfterGlobalHydrated, useGlobalStore } from '@/store/global';
|
|
11
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
11
12
|
|
|
12
13
|
import Checker from './Checker';
|
|
13
14
|
|
|
@@ -7,7 +7,8 @@ import { memo } from 'react';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
|
|
9
9
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
10
|
-
import {
|
|
10
|
+
import { useGlobalStore } from '@/store/global';
|
|
11
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
11
12
|
|
|
12
13
|
import { opeanaiSTTOptions, opeanaiTTSOptions, sttOptions } from './options';
|
|
13
14
|
|
|
@@ -3,7 +3,7 @@ import { DeepPartial } from 'utility-types';
|
|
|
3
3
|
import { BaseModel } from '@/database/core';
|
|
4
4
|
import { DBModel } from '@/database/core/types/db';
|
|
5
5
|
import { DB_Message, DB_MessageSchema } from '@/database/schemas/message';
|
|
6
|
-
import { ChatMessage } from '@/types/
|
|
6
|
+
import { ChatMessage } from '@/types/message';
|
|
7
7
|
import { nanoid } from '@/utils/uuid';
|
|
8
8
|
|
|
9
9
|
export interface CreateMessageParams
|
|
@@ -8,7 +8,8 @@ import { memo, useEffect } from 'react';
|
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
|
-
import {
|
|
11
|
+
import { useGlobalStore } from '@/store/global';
|
|
12
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
12
13
|
|
|
13
14
|
import { useStore } from '../store';
|
|
14
15
|
|
|
@@ -8,7 +8,8 @@ import { memo, useMemo } from 'react';
|
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
|
-
import {
|
|
11
|
+
import { useGlobalStore } from '@/store/global';
|
|
12
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
12
13
|
|
|
13
14
|
import { useStore } from '../store';
|
|
14
15
|
import { SessionLoadingState } from '../store/initialState';
|
|
@@ -8,7 +8,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
8
8
|
|
|
9
9
|
import { useTTS } from '@/hooks/useTTS';
|
|
10
10
|
import { TTSServer } from '@/types/agent';
|
|
11
|
-
import { ChatMessageError } from '@/types/
|
|
11
|
+
import { ChatMessageError } from '@/types/message';
|
|
12
12
|
import { getMessageError } from '@/utils/fetch';
|
|
13
13
|
|
|
14
14
|
interface SelectWithTTSPreviewProps extends SelectProps {
|
|
@@ -8,10 +8,11 @@ import { memo, useEffect } from 'react';
|
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
9
9
|
|
|
10
10
|
import { FORM_STYLE } from '@/const/layoutTokens';
|
|
11
|
-
import
|
|
12
|
-
import { settingsSelectors
|
|
11
|
+
import { useGlobalStore } from '@/store/global';
|
|
12
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
13
13
|
|
|
14
14
|
import { useStore } from '../store';
|
|
15
|
+
import SelectWithTTSPreview from './SelectWithTTSPreview';
|
|
15
16
|
import { ttsOptions } from './options';
|
|
16
17
|
|
|
17
18
|
const TTS_SETTING_KEY = 'tts';
|
|
@@ -5,7 +5,8 @@ import { BrainCog } from 'lucide-react';
|
|
|
5
5
|
import { memo } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useGlobalStore } from '@/store/global';
|
|
9
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
9
10
|
import { useSessionStore } from '@/store/session';
|
|
10
11
|
import { agentSelectors } from '@/store/session/selectors';
|
|
11
12
|
import { LanguageModel } from '@/types/llm';
|
|
@@ -8,7 +8,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
8
8
|
|
|
9
9
|
import { useSTT } from '@/hooks/useSTT';
|
|
10
10
|
import { useChatStore } from '@/store/chat';
|
|
11
|
-
import { ChatMessageError } from '@/types/
|
|
11
|
+
import { ChatMessageError } from '@/types/message';
|
|
12
12
|
import { getMessageError } from '@/utils/fetch';
|
|
13
13
|
|
|
14
14
|
const useStyles = createStyles(({ css, token }) => ({
|
|
@@ -6,7 +6,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
6
6
|
import { Center, Flexbox } from 'react-layout-kit';
|
|
7
7
|
|
|
8
8
|
import { useChatStore } from '@/store/chat';
|
|
9
|
-
import {
|
|
9
|
+
import { useGlobalStore } from '@/store/global';
|
|
10
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
10
11
|
|
|
11
12
|
import { FormAction } from './style';
|
|
12
13
|
|
|
@@ -3,7 +3,7 @@ import { Mock, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
|
|
4
4
|
import { useSessionStore } from '@/store/session';
|
|
5
5
|
import { agentSelectors } from '@/store/session/selectors';
|
|
6
|
-
import { ChatMessage } from '@/types/
|
|
6
|
+
import { ChatMessage } from '@/types/message';
|
|
7
7
|
|
|
8
8
|
import { AssistantMessageExtra } from './Assistant';
|
|
9
9
|
|
|
@@ -6,7 +6,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
6
6
|
import { useChatStore } from '@/store/chat';
|
|
7
7
|
import { useSessionStore } from '@/store/session';
|
|
8
8
|
import { agentSelectors } from '@/store/session/selectors';
|
|
9
|
-
import { ChatMessage } from '@/types/
|
|
9
|
+
import { ChatMessage } from '@/types/message';
|
|
10
10
|
|
|
11
11
|
import ExtraContainer from './ExtraContainer';
|
|
12
12
|
import TTS from './TTS';
|
|
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { useTTS } from '@/hooks/useTTS';
|
|
5
5
|
import { useChatStore } from '@/store/chat';
|
|
6
6
|
import { useFileStore } from '@/store/file';
|
|
7
|
-
import { ChatMessageError, ChatTTS } from '@/types/
|
|
7
|
+
import { ChatMessageError, ChatTTS } from '@/types/message';
|
|
8
8
|
import { getMessageError } from '@/utils/fetch';
|
|
9
9
|
|
|
10
10
|
import Player from './Player';
|
|
@@ -6,7 +6,7 @@ import { memo } from 'react';
|
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { Flexbox } from 'react-layout-kit';
|
|
8
8
|
|
|
9
|
-
import { ChatMessageError } from '@/types/
|
|
9
|
+
import { ChatMessageError } from '@/types/message';
|
|
10
10
|
|
|
11
11
|
interface PlayerProps extends AudioPlayerProps {
|
|
12
12
|
error?: ChatMessageError;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { memo, useMemo } from 'react';
|
|
2
2
|
import { Md5 } from 'ts-md5';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useGlobalStore } from '@/store/global';
|
|
5
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
5
6
|
import { useSessionStore } from '@/store/session';
|
|
6
|
-
import { agentSelectors } from '@/store/session/
|
|
7
|
+
import { agentSelectors } from '@/store/session/selectors';
|
|
7
8
|
|
|
8
9
|
import FilePlayer from './FilePlayer';
|
|
9
10
|
import InitPlayer, { TTSProps } from './InitPlayer';
|
|
@@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
8
8
|
import { Flexbox } from 'react-layout-kit';
|
|
9
9
|
|
|
10
10
|
import { useChatStore } from '@/store/chat';
|
|
11
|
-
import { ChatTranslate } from '@/types/
|
|
11
|
+
import { ChatTranslate } from '@/types/message';
|
|
12
12
|
|
|
13
13
|
import BubblesLoading from '../Loading';
|
|
14
14
|
|
|
@@ -2,7 +2,7 @@ import { ReactNode, memo } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { useChatStore } from '@/store/chat';
|
|
4
4
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
5
|
-
import { ChatMessage } from '@/types/
|
|
5
|
+
import { ChatMessage } from '@/types/message';
|
|
6
6
|
import { isFunctionMessageAtStart } from '@/utils/message';
|
|
7
7
|
|
|
8
8
|
import Inspector from '../Plugins/Inspector';
|
|
@@ -4,7 +4,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
4
4
|
|
|
5
5
|
import { useChatStore } from '@/store/chat';
|
|
6
6
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
7
|
-
import { ChatMessage } from '@/types/
|
|
7
|
+
import { ChatMessage } from '@/types/message';
|
|
8
8
|
|
|
9
9
|
import Inspector from '../Plugins/Inspector';
|
|
10
10
|
import PluginRender from '../Plugins/Render';
|
|
@@ -3,7 +3,7 @@ import { Flexbox } from 'react-layout-kit';
|
|
|
3
3
|
|
|
4
4
|
import FileList from '@/components/FileList';
|
|
5
5
|
import { LOADING_FLAT } from '@/const/message';
|
|
6
|
-
import { ChatMessage } from '@/types/
|
|
6
|
+
import { ChatMessage } from '@/types/message';
|
|
7
7
|
|
|
8
8
|
import BubblesLoading from '../Loading';
|
|
9
9
|
|
|
@@ -5,7 +5,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { Flexbox } from 'react-layout-kit';
|
|
6
6
|
|
|
7
7
|
import SafeSpacing from '@/components/SafeSpacing';
|
|
8
|
-
import {
|
|
8
|
+
import { useGlobalStore } from '@/store/global';
|
|
9
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
9
10
|
|
|
10
11
|
import ChatList from './ChatList';
|
|
11
12
|
import ChatScrollAnchor from './ScrollAnchor';
|
|
@@ -4,9 +4,10 @@ import dynamic from 'next/dynamic';
|
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useGlobalStore } from '@/store/global';
|
|
8
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
8
9
|
import { useToolStore } from '@/store/tool';
|
|
9
|
-
import { pluginSelectors } from '@/store/tool/
|
|
10
|
+
import { pluginSelectors } from '@/store/tool/selectors';
|
|
10
11
|
|
|
11
12
|
const EmojiPicker = dynamic(() => import('@lobehub/ui/es/EmojiPicker'), { ssr: false });
|
|
12
13
|
|
package/src/hooks/useSTT.ts
CHANGED
|
@@ -10,7 +10,8 @@ import { SWRConfiguration } from 'swr';
|
|
|
10
10
|
|
|
11
11
|
import { createHeaderWithOpenAI } from '@/services/_header';
|
|
12
12
|
import { OPENAI_URLS } from '@/services/_url';
|
|
13
|
-
import {
|
|
13
|
+
import { useGlobalStore } from '@/store/global';
|
|
14
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
14
15
|
import { useSessionStore } from '@/store/session';
|
|
15
16
|
import { agentSelectors } from '@/store/session/selectors';
|
|
16
17
|
|
package/src/hooks/useTTS.ts
CHANGED
|
@@ -11,7 +11,8 @@ import isEqual from 'fast-deep-equal';
|
|
|
11
11
|
|
|
12
12
|
import { createHeaderWithOpenAI } from '@/services/_header';
|
|
13
13
|
import { OPENAI_URLS, TTS_URL } from '@/services/_url';
|
|
14
|
-
import {
|
|
14
|
+
import { useGlobalStore } from '@/store/global';
|
|
15
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
15
16
|
import { useSessionStore } from '@/store/session';
|
|
16
17
|
import { agentSelectors } from '@/store/session/selectors';
|
|
17
18
|
import { TTSServer } from '@/types/agent';
|
|
@@ -6,7 +6,7 @@ import { VISION_MODEL_WHITE_LIST } from '@/const/llm';
|
|
|
6
6
|
import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
|
7
7
|
import { useFileStore } from '@/store/file';
|
|
8
8
|
import { useToolStore } from '@/store/tool';
|
|
9
|
-
import { ChatMessage } from '@/types/
|
|
9
|
+
import { ChatMessage } from '@/types/message';
|
|
10
10
|
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
11
11
|
import { LobeTool } from '@/types/tool';
|
|
12
12
|
|
package/src/services/_header.ts
CHANGED
|
@@ -11,8 +11,8 @@ import { useGlobalStore } from '@/store/global';
|
|
|
11
11
|
export const createHeaderWithOpenAI = (header?: HeadersInit): HeadersInit => {
|
|
12
12
|
const openai = useGlobalStore.getState().settings.languageModel.openAI;
|
|
13
13
|
|
|
14
|
-
const apiKey = openai.OPENAI_API_KEY ||
|
|
15
|
-
const endpoint = openai.endpoint ||
|
|
14
|
+
const apiKey = openai.OPENAI_API_KEY || '';
|
|
15
|
+
const endpoint = openai.endpoint || '';
|
|
16
16
|
|
|
17
17
|
// eslint-disable-next-line no-undef
|
|
18
18
|
const result: HeadersInit = {
|
package/src/services/chat.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { DEFAULT_AGENT_CONFIG } from '@/const/settings';
|
|
|
7
7
|
import { filesSelectors, useFileStore } from '@/store/file';
|
|
8
8
|
import { useToolStore } from '@/store/tool';
|
|
9
9
|
import { pluginSelectors, toolSelectors } from '@/store/tool/selectors';
|
|
10
|
-
import { ChatMessage } from '@/types/
|
|
10
|
+
import { ChatMessage } from '@/types/message';
|
|
11
11
|
import type { OpenAIChatMessage, OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
12
12
|
import { UserMessageContentPart } from '@/types/openai/chat';
|
|
13
13
|
import { fetchAIFactory, getMessageError } from '@/utils/fetch';
|
package/src/services/config.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { messageService } from '@/services/message';
|
|
2
2
|
import { sessionService } from '@/services/session';
|
|
3
3
|
import { topicService } from '@/services/topic';
|
|
4
|
-
import {
|
|
4
|
+
import { useGlobalStore } from '@/store/global';
|
|
5
|
+
import { settingsSelectors } from '@/store/global/selectors';
|
|
5
6
|
import { useSessionStore } from '@/store/session';
|
|
6
7
|
import { sessionExportSelectors, sessionSelectors } from '@/store/session/selectors';
|
|
7
|
-
import { ChatMessage } from '@/types/chatMessage';
|
|
8
8
|
import { ConfigFile } from '@/types/exportConfig';
|
|
9
|
+
import { ChatMessage } from '@/types/message';
|
|
9
10
|
import { LobeSessions } from '@/types/session';
|
|
10
11
|
import { GlobalSettings } from '@/types/settings';
|
|
11
12
|
import { ChatTopic } from '@/types/topic';
|
package/src/services/message.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { CreateMessageParams, MessageModel } from '@/database/models/message';
|
|
2
2
|
import { DB_Message } from '@/database/schemas/message';
|
|
3
|
+
import { LLMRoleType } from '@/types/llm';
|
|
3
4
|
import {
|
|
4
5
|
ChatMessage,
|
|
5
6
|
ChatMessageError,
|
|
6
7
|
ChatPluginPayload,
|
|
7
8
|
ChatTTS,
|
|
8
9
|
ChatTranslate,
|
|
9
|
-
} from '@/types/
|
|
10
|
-
import { LLMRoleType } from '@/types/llm';
|
|
10
|
+
} from '@/types/message';
|
|
11
11
|
|
|
12
12
|
export class MessageService {
|
|
13
13
|
async create(data: CreateMessageParams) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
3
|
import { LobeAgentConfig } from '@/types/agent';
|
|
4
|
-
import { ChatMessage } from '@/types/
|
|
4
|
+
import { ChatMessage } from '@/types/message';
|
|
5
5
|
import { OpenAIChatMessage } from '@/types/openai/chat';
|
|
6
6
|
import { encodeAsync } from '@/utils/tokenizer';
|
|
7
7
|
import * as tokenizerObj from '@/utils/tokenizer';
|
|
@@ -1,51 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChatMessageState, initialMessageState } from './slices/message/initialState';
|
|
2
|
+
import { ChatShareState, initialShareState } from './slices/share/initialState';
|
|
3
|
+
import { ChatToolState, initialToolState } from './slices/tool/initialState';
|
|
4
|
+
import { ChatTopicState, initialTopicState } from './slices/topic/initialState';
|
|
3
5
|
|
|
4
|
-
export
|
|
5
|
-
abortController?: AbortController;
|
|
6
|
-
/**
|
|
7
|
-
* @title 当前活动的会话
|
|
8
|
-
* @description 当前正在编辑或查看的会话
|
|
9
|
-
*/
|
|
10
|
-
activeId: string;
|
|
11
|
-
activeTopicId?: string;
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated
|
|
14
|
-
*/
|
|
15
|
-
chatLoadingId?: string;
|
|
16
|
-
dalleImageLoading: Record<string, boolean>;
|
|
17
|
-
|
|
18
|
-
inputMessage: string;
|
|
19
|
-
isSearchingTopic: boolean;
|
|
20
|
-
messageLoadingIds: [];
|
|
21
|
-
messages: ChatMessage[];
|
|
22
|
-
/**
|
|
23
|
-
* whether messages have fetched
|
|
24
|
-
*/
|
|
25
|
-
messagesInit: boolean;
|
|
26
|
-
|
|
27
|
-
searchTopics: ChatTopic[];
|
|
28
|
-
shareLoading?: boolean;
|
|
29
|
-
topicLoadingId?: string;
|
|
30
|
-
topicRenamingId?: string;
|
|
31
|
-
topicSearchKeywords: string;
|
|
32
|
-
topics: ChatTopic[];
|
|
33
|
-
/**
|
|
34
|
-
* whether topics have fetched
|
|
35
|
-
*/
|
|
36
|
-
topicsInit: boolean;
|
|
37
|
-
}
|
|
6
|
+
export type ChatStoreState = ChatTopicState & ChatMessageState & ChatToolState & ChatShareState;
|
|
38
7
|
|
|
39
8
|
export const initialState: ChatStoreState = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
messageLoadingIds: [],
|
|
45
|
-
messages: [],
|
|
46
|
-
messagesInit: false,
|
|
47
|
-
searchTopics: [],
|
|
48
|
-
topicSearchKeywords: '',
|
|
49
|
-
topics: [],
|
|
50
|
-
topicsInit: false,
|
|
9
|
+
...initialMessageState,
|
|
10
|
+
...initialTopicState,
|
|
11
|
+
...initialToolState,
|
|
12
|
+
...initialShareState,
|
|
51
13
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { act, renderHook
|
|
1
|
+
import { act, renderHook } from '@testing-library/react';
|
|
2
2
|
import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { chainLangDetect } from '@/chains/langDetect';
|
|
@@ -6,7 +6,7 @@ import { chainTranslate } from '@/chains/translate';
|
|
|
6
6
|
import { chatService } from '@/services/chat';
|
|
7
7
|
import { messageService } from '@/services/message';
|
|
8
8
|
|
|
9
|
-
import { useChatStore } from '
|
|
9
|
+
import { useChatStore } from '../../store';
|
|
10
10
|
|
|
11
11
|
// Mock messageService 和 chatService
|
|
12
12
|
vi.mock('@/services/message', () => ({
|
|
@@ -7,9 +7,9 @@ import { chatService } from '@/services/chat';
|
|
|
7
7
|
import { messageService } from '@/services/message';
|
|
8
8
|
import { topicService } from '@/services/topic';
|
|
9
9
|
import { chatSelectors } from '@/store/chat/selectors';
|
|
10
|
-
import { ChatMessage } from '@/types/
|
|
10
|
+
import { ChatMessage } from '@/types/message';
|
|
11
11
|
|
|
12
|
-
import { useChatStore } from '
|
|
12
|
+
import { useChatStore } from '../../store';
|
|
13
13
|
|
|
14
14
|
// Mock service
|
|
15
15
|
vi.mock('@/services/message', () => ({
|
|
@@ -17,13 +17,13 @@ import { chatHelpers } from '@/store/chat/helpers';
|
|
|
17
17
|
import { ChatStore } from '@/store/chat/store';
|
|
18
18
|
import { useSessionStore } from '@/store/session';
|
|
19
19
|
import { agentSelectors } from '@/store/session/selectors';
|
|
20
|
-
import { ChatMessage } from '@/types/
|
|
20
|
+
import { ChatMessage } from '@/types/message';
|
|
21
21
|
import { fetchSSE } from '@/utils/fetch';
|
|
22
22
|
import { isFunctionMessageAtStart, testFunctionMessageAtEnd } from '@/utils/message';
|
|
23
23
|
import { setNamespace } from '@/utils/storeDebug';
|
|
24
24
|
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import { chatSelectors } from '../../selectors';
|
|
26
|
+
import { MessageDispatch, messagesReducer } from './reducer';
|
|
27
27
|
|
|
28
28
|
const n = setNamespace('message');
|
|
29
29
|
|