@lobehub/chat 0.159.11 → 0.159.12
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 +25 -0
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/package.json +1 -1
- package/src/app/(main)/chat/@session/features/SessionHydration.tsx +2 -0
- package/src/features/Conversation/Error/index.tsx +13 -4
- package/src/features/Conversation/components/VirtualizedList/index.tsx +27 -21
- package/src/services/message/type.ts +6 -3
- package/src/store/chat/slices/enchance/action.test.ts +16 -12
- package/src/store/chat/slices/message/action.test.ts +495 -24
- package/src/store/chat/slices/message/action.ts +143 -32
- package/src/store/chat/slices/message/initialState.ts +2 -2
- package/src/store/chat/slices/message/selectors.test.ts +39 -9
- package/src/store/chat/slices/message/selectors.ts +13 -3
- package/src/store/chat/slices/message/utils.ts +7 -0
- package/src/store/chat/slices/plugin/action.test.ts +7 -2
- package/src/store/chat/slices/share/action.test.ts +19 -3
- package/src/store/chat/slices/topic/action.test.ts +13 -2
- package/src/store/chat/slices/topic/action.ts +27 -6
- package/src/store/chat/slices/topic/initialState.ts +2 -0
- package/src/utils/fetch.test.ts +17 -11
- package/src/utils/fetch.ts +20 -22
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.159.12](https://github.com/lobehub/lobe-chat/compare/v0.159.11...v0.159.12)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-05-15**</sup>
|
|
8
|
+
|
|
9
|
+
#### ♻ Code Refactoring
|
|
10
|
+
|
|
11
|
+
- **misc**: Refactor the create message flow to fix some bugs.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### Code refactoring
|
|
19
|
+
|
|
20
|
+
- **misc**: Refactor the create message flow to fix some bugs, closes [#2521](https://github.com/lobehub/lobe-chat/issues/2521) ([7263a33](https://github.com/lobehub/lobe-chat/commit/7263a33))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.159.11](https://github.com/lobehub/lobe-chat/compare/v0.159.10...v0.159.11)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-05-15**</sup>
|
package/README.md
CHANGED
|
@@ -262,14 +262,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
|
|
|
262
262
|
|
|
263
263
|
<!-- AGENT LIST -->
|
|
264
264
|
|
|
265
|
-
| Recent Submits
|
|
266
|
-
|
|
|
267
|
-
| [
|
|
268
|
-
| [
|
|
269
|
-
| [
|
|
270
|
-
| [
|
|
271
|
-
|
|
272
|
-
> 📊 Total agents: [<kbd>**
|
|
265
|
+
| Recent Submits | Description |
|
|
266
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
267
|
+
| [AWS Guru](https://chat-preview.lobehub.com/market?agent=aws-guru)<br/><sup>By **[wilbeibi](https://github.com/wilbeibi)** on **2024-05-15**</sup> | Agent to answer AWS questions<br/>`programming` |
|
|
268
|
+
| [Linux Buddy](https://chat-preview.lobehub.com/market?agent=linux-buddy)<br/><sup>By **[Firpo7](https://github.com/Firpo7)** on **2024-05-15**</sup> | Your Linux expert friend<br/>`linux` `technical-support` `buddy` |
|
|
269
|
+
| [Photography Critic](https://chat-preview.lobehub.com/market?agent=photography-critic)<br/><sup>By **[Justin3go](https://github.com/Justin3go)** on **2024-05-15**</sup> | Specializes in detailed analysis of photographic works, including themes, composition, technical quality, use of light, creativity, and originality.<br/>`photography` `evaluation` `analysis` `composition` `technical-quality` |
|
|
270
|
+
| [Python Buddy](https://chat-preview.lobehub.com/market?agent=python-buddy)<br/><sup>By **[Firpo7](https://github.com/Firpo7)** on **2024-05-15**</sup> | Your Python expert friend<br/>`python` `software-development` `coding` `code` `buddy` |
|
|
271
|
+
|
|
272
|
+
> 📊 Total agents: [<kbd>**258**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
273
273
|
|
|
274
274
|
<!-- AGENT LIST -->
|
|
275
275
|
|
package/README.zh-CN.md
CHANGED
|
@@ -250,14 +250,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
250
250
|
|
|
251
251
|
<!-- AGENT LIST -->
|
|
252
252
|
|
|
253
|
-
| 最近新增
|
|
254
|
-
|
|
|
255
|
-
| [
|
|
256
|
-
| [
|
|
257
|
-
| [
|
|
258
|
-
| [
|
|
259
|
-
|
|
260
|
-
> 📊 Total agents: [<kbd>**
|
|
253
|
+
| 最近新增 | 助手说明 |
|
|
254
|
+
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
255
|
+
| [AWS Guru](https://chat-preview.lobehub.com/market?agent=aws-guru)<br/><sup>By **[wilbeibi](https://github.com/wilbeibi)** on **2024-05-15**</sup> | Agent to answer AWS questions<br/>`programming` |
|
|
256
|
+
| [Linux Buddy](https://chat-preview.lobehub.com/market?agent=linux-buddy)<br/><sup>By **[Firpo7](https://github.com/Firpo7)** on **2024-05-15**</sup> | 您的 Linux 专家朋友<br/>`linux` `technical-support` `buddy` |
|
|
257
|
+
| [摄影评论家](https://chat-preview.lobehub.com/market?agent=photography-critic)<br/><sup>By **[Justin3go](https://github.com/Justin3go)** on **2024-05-15**</sup> | 擅长摄影作品细致分析,包括主题、构图、技术质量、光线使用、创意与原创性等。<br/>`摄影` `评价` `分析` `构图` `技术质量` |
|
|
258
|
+
| [Python Buddy](https://chat-preview.lobehub.com/market?agent=python-buddy)<br/><sup>By **[Firpo7](https://github.com/Firpo7)** on **2024-05-15**</sup> | 您的 Python 专家朋友<br/>`python` `软件开发` `编程` `代码` `伙伴` |
|
|
259
|
+
|
|
260
|
+
> 📊 Total agents: [<kbd>**258**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
261
261
|
|
|
262
262
|
<!-- AGENT LIST -->
|
|
263
263
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.159.
|
|
3
|
+
"version": "0.159.12",
|
|
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",
|
|
@@ -13,6 +13,7 @@ import { useSessionStore } from '@/store/session';
|
|
|
13
13
|
const SessionHydration = memo(() => {
|
|
14
14
|
const useStoreUpdater = createStoreUpdater(useSessionStore);
|
|
15
15
|
const useAgentStoreUpdater = createStoreUpdater(useAgentStore);
|
|
16
|
+
const useChatStoreUpdater = createStoreUpdater(useChatStore);
|
|
16
17
|
const [switchTopic] = useChatStore((s) => [s.switchTopic]);
|
|
17
18
|
|
|
18
19
|
// two-way bindings the url and session store
|
|
@@ -22,6 +23,7 @@ const SessionHydration = memo(() => {
|
|
|
22
23
|
);
|
|
23
24
|
useStoreUpdater('activeId', session);
|
|
24
25
|
useAgentStoreUpdater('activeId', session);
|
|
26
|
+
useChatStoreUpdater('activeId', session);
|
|
25
27
|
|
|
26
28
|
useEffect(() => {
|
|
27
29
|
const unsubscribe = useSessionStore.subscribe(
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { IPluginErrorType, PluginErrorType } from '@lobehub/chat-plugin-sdk';
|
|
2
2
|
import type { AlertProps } from '@lobehub/ui';
|
|
3
|
-
import {
|
|
3
|
+
import { Skeleton } from 'antd';
|
|
4
|
+
import dynamic from 'next/dynamic';
|
|
5
|
+
import { Suspense, memo } from 'react';
|
|
4
6
|
|
|
5
7
|
import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '@/libs/agent-runtime';
|
|
6
8
|
import { ChatErrorType, ErrorType } from '@/types/fetch';
|
|
@@ -10,9 +12,12 @@ import ClerkLogin from './ClerkLogin';
|
|
|
10
12
|
import ErrorJsonViewer from './ErrorJsonViewer';
|
|
11
13
|
import InvalidAPIKey from './InvalidAPIKey';
|
|
12
14
|
import InvalidAccessCode from './InvalidAccessCode';
|
|
13
|
-
import OllamaBizError from './OllamaBizError';
|
|
14
15
|
import OpenAiBizError from './OpenAiBizError';
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
const loading = () => <Skeleton active />;
|
|
18
|
+
|
|
19
|
+
const OllamaBizError = dynamic(() => import('./OllamaBizError'), { loading, ssr: false });
|
|
20
|
+
const PluginSettings = dynamic(() => import('./PluginSettings'), { loading, ssr: false });
|
|
16
21
|
|
|
17
22
|
// Config for the errorMessage display
|
|
18
23
|
export const getErrorAlertConfig = (
|
|
@@ -95,4 +100,8 @@ const ErrorMessageExtra = memo<{ data: ChatMessage }>(({ data }) => {
|
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
102
|
|
|
98
|
-
export default
|
|
103
|
+
export default memo<{ data: ChatMessage }>(({ data }) => (
|
|
104
|
+
<Suspense fallback={<Skeleton active style={{ width: '100%' }} />}>
|
|
105
|
+
<ErrorMessageExtra data={data} />
|
|
106
|
+
</Suspense>
|
|
107
|
+
));
|
|
@@ -29,14 +29,17 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
|
|
|
29
29
|
|
|
30
30
|
const [id] = useChatStore((s) => [chatSelectors.currentChatKey(s)]);
|
|
31
31
|
|
|
32
|
-
const [activeTopicId, useFetchMessages, isFirstLoading] = useChatStore(
|
|
33
|
-
s
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
const [activeTopicId, useFetchMessages, isFirstLoading, isCurrentChatLoaded] = useChatStore(
|
|
33
|
+
(s) => [
|
|
34
|
+
s.activeTopicId,
|
|
35
|
+
s.useFetchMessages,
|
|
36
|
+
chatSelectors.currentChatLoadingState(s),
|
|
37
|
+
chatSelectors.isCurrentChatLoaded(s),
|
|
38
|
+
],
|
|
39
|
+
);
|
|
37
40
|
|
|
38
41
|
const [sessionId] = useSessionStore((s) => [s.activeId]);
|
|
39
|
-
|
|
42
|
+
useFetchMessages(sessionId, activeTopicId);
|
|
40
43
|
|
|
41
44
|
const data = useChatStore((s) => {
|
|
42
45
|
const showInboxWelcome = chatSelectors.showInboxWelcome(s);
|
|
@@ -77,23 +80,26 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
|
|
|
77
80
|
[mobile],
|
|
78
81
|
);
|
|
79
82
|
|
|
80
|
-
// first time loading
|
|
83
|
+
// first time loading or not loaded
|
|
81
84
|
if (isFirstLoading) return <SkeletonList mobile={mobile} />;
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
if (!isCurrentChatLoaded)
|
|
87
|
+
// use skeleton list when not loaded in server mode due to the loading duration is much longer than client mode
|
|
88
|
+
return isServerMode ? (
|
|
89
|
+
<SkeletonList mobile={mobile} />
|
|
90
|
+
) : (
|
|
91
|
+
// in client mode and switch page, using the center loading for smooth transition
|
|
92
|
+
<Center height={'100%'} width={'100%'}>
|
|
93
|
+
<Icon
|
|
94
|
+
icon={Loader2Icon}
|
|
95
|
+
size={{ fontSize: 32 }}
|
|
96
|
+
spin
|
|
97
|
+
style={{ color: theme.colorTextTertiary }}
|
|
98
|
+
/>
|
|
99
|
+
</Center>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return (
|
|
97
103
|
<Flexbox height={'100%'}>
|
|
98
104
|
<Virtuoso
|
|
99
105
|
atBottomStateChange={setAtBottom}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { DB_Message } from '@/database/client/schemas/message';
|
|
2
|
-
import { ChatMessage, ChatMessageError, ChatPluginPayload } from '@/types/message';
|
|
2
|
+
import { ChatMessage, ChatMessageError, ChatPluginPayload, MessageRoleType } from '@/types/message';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable typescript-sort-keys/interface */
|
|
5
5
|
|
|
6
6
|
export interface CreateMessageParams
|
|
7
|
-
extends Partial<Omit<ChatMessage, 'content' | 'role'
|
|
8
|
-
Pick<ChatMessage, 'content' | 'role'> {
|
|
7
|
+
extends Partial<Omit<ChatMessage, 'content' | 'role' | 'topicId'>> {
|
|
9
8
|
fromModel?: string;
|
|
10
9
|
fromProvider?: string;
|
|
11
10
|
sessionId: string;
|
|
12
11
|
traceId?: string;
|
|
12
|
+
topicId?: string;
|
|
13
|
+
content: string;
|
|
14
|
+
error?: ChatMessageError;
|
|
15
|
+
role: MessageRoleType;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export interface IMessageService {
|
|
@@ -5,6 +5,7 @@ import { chainLangDetect } from '@/chains/langDetect';
|
|
|
5
5
|
import { chainTranslate } from '@/chains/translate';
|
|
6
6
|
import { chatService } from '@/services/chat';
|
|
7
7
|
import { messageService } from '@/services/message';
|
|
8
|
+
import { messageMapKey } from '@/store/chat/slices/message/utils';
|
|
8
9
|
|
|
9
10
|
import { useChatStore } from '../../store';
|
|
10
11
|
|
|
@@ -73,18 +74,21 @@ describe('ChatEnhanceAction', () => {
|
|
|
73
74
|
|
|
74
75
|
act(() => {
|
|
75
76
|
useChatStore.setState({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
activeId: 'session',
|
|
78
|
+
messagesMap: {
|
|
79
|
+
[messageMapKey('session')]: [
|
|
80
|
+
{
|
|
81
|
+
id: messageId,
|
|
82
|
+
content: messageContent,
|
|
83
|
+
createdAt: Date.now(),
|
|
84
|
+
updatedAt: Date.now(),
|
|
85
|
+
role: 'user',
|
|
86
|
+
sessionId: 'test',
|
|
87
|
+
topicId: 'test',
|
|
88
|
+
meta: {},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
88
92
|
});
|
|
89
93
|
});
|
|
90
94
|
|