@lobehub/chat 0.159.10 → 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 CHANGED
@@ -2,6 +2,56 @@
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
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
30
+ ### [Version 0.159.11](https://github.com/lobehub/lobe-chat/compare/v0.159.10...v0.159.11)
31
+
32
+ <sup>Released on **2024-05-15**</sup>
33
+
34
+ #### 💄 Styles
35
+
36
+ - **misc**: Add Gemini 1.5 Flash model.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Add Gemini 1.5 Flash model, closes [#2507](https://github.com/lobehub/lobe-chat/issues/2507) ([5568472](https://github.com/lobehub/lobe-chat/commit/5568472))
46
+
47
+ </details>
48
+
49
+ <div align="right">
50
+
51
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
52
+
53
+ </div>
54
+
5
55
  ### [Version 0.159.10](https://github.com/lobehub/lobe-chat/compare/v0.159.9...v0.159.10)
6
56
 
7
57
  <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 | Description |
266
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
267
- | [SF Symbols Finder](https://chat-preview.lobehub.com/market?agent=sf-symbols-finder)<br/><sup>By **[inquiry-paring0a](https://github.com/inquiry-paring0a)** on **2024-05-08**</sup> | Master Apple SF Symbols, select symbols that match the description<br/>`sf-symbols` `expert` `icon` `symbol` `plugin` |
268
- | [GhostWriter Pro](https://chat-preview.lobehub.com/market?agent=ghostwriter-pro-ai)<br/><sup>By **[EarlofSandwhich](https://github.com/EarlofSandwhich)** on **2024-05-07**</sup> | A sophisticated AI-powered ghostwriting agent designed to craft high-quality content across a diverse range of genres and formats. Equipped with advanced language models, GhostWriter Pro excels in creating personalized, engaging, and research-backed writing that meets professional standards.<br/>`author` `writing` |
269
- | [Video to Blog Post Assistant](https://chat-preview.lobehub.com/market?agent=video-2-blog-assistant)<br/><sup>By **[yayoinoyume](https://github.com/yayoinoyume)** on **2024-05-06**</sup> | Helps you quickly organize messy subtitles into beautiful blog posts<br/>`subtitle-organization` `blog-post-formatting` `video-to-blog` |
270
- | [Art Evaluation Tutor](https://chat-preview.lobehub.com/market?agent=wanwusheng-art)<br/><sup>By **[dingyufei615](https://github.com/dingyufei615)** on **2024-05-06**</sup> | Specializes in teaching children's art, meticulously evaluates works, pays attention to details, and adapts to students of different age groups.<br/>`art-education` `evaluation` `creativity` `teaching` `painting` |
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
271
 
272
- > 📊 Total agents: [<kbd>**249**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
272
+ > 📊 Total agents: [<kbd>**258**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
273
273
 
274
274
  <!-- AGENT LIST -->
275
275
 
@@ -714,7 +714,7 @@ This project is [MIT](./LICENSE) licensed.
714
714
  [image-feat-theme]: https://gw.alipayobjects.com/zos/kitchen/pvus1lo%26Z7/darkmode.webp
715
715
  [image-feat-tts]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072124-c9853d8d-f1b5-44a8-a305-45ebc0f6d19a.png
716
716
  [image-feat-vision]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072129-382bdf30-e3d6-4411-b5a0-249710b8ba08.png
717
- [image-overview]: https://github.com/lobehub/lobe-chat/assets/28616219/8b04c3c9-3d71-4fb4-bd9b-a4f415c5876d
717
+ [image-overview]: https://github.com/lobehub/lobe-chat/assets/17870709/56b95d48-f573-41cd-8b38-387bf88bc4bf
718
718
  [image-star]: https://github.com/lobehub/lobe-chat/assets/17870709/cb06b748-513f-47c2-8740-d876858d7855
719
719
  [issues-link]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
720
720
  [lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
package/README.zh-CN.md CHANGED
@@ -250,14 +250,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
250
250
 
251
251
  <!-- AGENT LIST -->
252
252
 
253
- | 最近新增 | 助手说明 |
254
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
255
- | [SF Symbols 查找器](https://chat-preview.lobehub.com/market?agent=sf-symbols-finder)<br/><sup>By **[inquiry-paring0a](https://github.com/inquiry-paring0a)** on **2024-05-08**</sup> | 精通苹果 SF Symbols,可根据描述选择符合的 Symbols<br/>`sf-symbols` `专家` `图标` `符号` `插件` |
256
- | [GhostWriter Pro](https://chat-preview.lobehub.com/market?agent=ghostwriter-pro-ai)<br/><sup>By **[EarlofSandwhich](https://github.com/EarlofSandwhich)** on **2024-05-07**</sup> | 一款复杂的 AI 驱动的写手代理,旨在跨多种流派和格式创作高质量内容。GhostWriter Pro 配备先进的语言模型,擅长创作个性化、引人入胜且有研究支持的写作,符合专业标准。<br/>`作者` `写作` |
257
- | [视频转博客文章助手](https://chat-preview.lobehub.com/market?agent=video-2-blog-assistant)<br/><sup>By **[yayoinoyume](https://github.com/yayoinoyume)** on **2024-05-06**</sup> | 帮你快速整理缭乱的字幕,变成精美的博客文章<br/>`字幕整理` `博文格式` `视频变博客` |
258
- | [美术评价导师](https://chat-preview.lobehub.com/market?agent=wanwusheng-art)<br/><sup>By **[dingyufei615](https://github.com/dingyufei615)** on **2024-05-06**</sup> | 擅长少儿美术教学,细致评价作品,关注细节,适应不同年龄段学生。<br/>`美术教育` `评价` `创意` `教学` `绘画` |
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
259
 
260
- > 📊 Total agents: [<kbd>**249**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
260
+ > 📊 Total agents: [<kbd>**258**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
261
261
 
262
262
  <!-- AGENT LIST -->
263
263
 
@@ -735,7 +735,7 @@ This project is [MIT](./LICENSE) licensed.
735
735
  [image-feat-theme]: https://gw.alipayobjects.com/zos/kitchen/pvus1lo%26Z7/darkmode.webp
736
736
  [image-feat-tts]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072124-c9853d8d-f1b5-44a8-a305-45ebc0f6d19a.png
737
737
  [image-feat-vision]: https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/284072129-382bdf30-e3d6-4411-b5a0-249710b8ba08.png
738
- [image-overview]: https://github.com/lobehub/lobe-chat/assets/28616219/8b04c3c9-3d71-4fb4-bd9b-a4f415c5876d
738
+ [image-overview]: https://github.com/lobehub/lobe-chat/assets/17870709/56b95d48-f573-41cd-8b38-387bf88bc4bf
739
739
  [image-star]: https://github.com/lobehub/lobe-chat/assets/17870709/cb06b748-513f-47c2-8740-d876858d7855
740
740
  [issues-link]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
741
741
  [lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
@@ -23,7 +23,7 @@ tags:
23
23
  borderless
24
24
  height={426}
25
25
  margin={12}
26
- src={'https://github.com/lobehub/lobe-chat/assets/28616219/8b04c3c9-3d71-4fb4-bd9b-a4f415c5876d'}
26
+ src={'https://github.com/lobehub/lobe-chat/assets/17870709/56b95d48-f573-41cd-8b38-387bf88bc4bf'}
27
27
  width={832}
28
28
  />
29
29
 
@@ -19,7 +19,7 @@ tags:
19
19
  borderless
20
20
  height={426}
21
21
  margin={12}
22
- src={'https://github.com/lobehub/lobe-chat/assets/28616219/8b04c3c9-3d71-4fb4-bd9b-a4f415c5876d'}
22
+ src={'https://github.com/lobehub/lobe-chat/assets/17870709/56b95d48-f573-41cd-8b38-387bf88bc4bf'}
23
23
  width={832}
24
24
  />
25
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.159.10",
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(
@@ -8,6 +8,7 @@ const Google: ModelProviderCard = {
8
8
  description: 'A legacy text-only model optimized for chat conversations',
9
9
  displayName: 'PaLM 2 Chat (Legacy)',
10
10
  id: 'chat-bison-001',
11
+ legacy: true,
11
12
  maxOutput: 1024,
12
13
  // tokens: 4096 + 1024, // none tokens test
13
14
  },
@@ -15,13 +16,13 @@ const Google: ModelProviderCard = {
15
16
  description: 'A legacy model that understands text and generates text as an output',
16
17
  displayName: 'PaLM 2 (Legacy)',
17
18
  id: 'text-bison-001',
19
+ legacy: true,
18
20
  maxOutput: 1024,
19
21
  tokens: 8196 + 1024,
20
22
  },
21
23
  {
22
24
  description: 'The best model for scaling across a wide range of tasks',
23
25
  displayName: 'Gemini 1.0 Pro',
24
- enabled: true,
25
26
  functionCall: true,
26
27
  id: 'gemini-pro',
27
28
  maxOutput: 2048,
@@ -38,7 +39,6 @@ const Google: ModelProviderCard = {
38
39
  {
39
40
  description: 'The best image understanding model to handle a broad range of applications',
40
41
  displayName: 'Gemini 1.0 Pro Vision',
41
- enabled: true,
42
42
  id: 'gemini-pro-vision',
43
43
  maxOutput: 4096,
44
44
  tokens: 12_288 + 4096,
@@ -69,6 +69,16 @@ const Google: ModelProviderCard = {
69
69
  maxOutput: 2048,
70
70
  tokens: 30_720 + 2048,
71
71
  },
72
+ {
73
+ description: 'Fast and versatile multimodal model for scaling across diverse tasks',
74
+ displayName: 'Gemini 1.5 Flash',
75
+ enabled: true,
76
+ functionCall: true,
77
+ id: 'gemini-1.5-flash-latest',
78
+ maxOutput: 8192,
79
+ tokens: 1_048_576 + 8192,
80
+ vision: true,
81
+ },
72
82
  {
73
83
  description: 'Mid-size multimodal model that supports up to 1 million tokens',
74
84
  displayName: 'Gemini 1.5 Pro',
@@ -1,6 +1,8 @@
1
1
  import { IPluginErrorType, PluginErrorType } from '@lobehub/chat-plugin-sdk';
2
2
  import type { AlertProps } from '@lobehub/ui';
3
- import { memo } from 'react';
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
- import PluginSettings from './PluginSettings';
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 ErrorMessageExtra;
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((s) => [
33
- s.activeTopicId,
34
- s.useFetchMessages,
35
- chatSelectors.currentChatLoadingState(s),
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
- const { isLoading } = useFetchMessages(sessionId, activeTopicId);
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
- // in server mode and switch page
84
- if (isServerMode && isLoading) return <SkeletonList mobile={mobile} />;
85
-
86
- // in client mode using the center loading for more
87
- return isLoading ? (
88
- <Center height={'100%'} width={'100%'}>
89
- <Icon
90
- icon={Loader2Icon}
91
- size={{ fontSize: 32 }}
92
- spin
93
- style={{ color: theme.colorTextTertiary }}
94
- />
95
- </Center>
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
- messages: [
77
- {
78
- id: messageId,
79
- content: messageContent,
80
- createdAt: Date.now(),
81
- updatedAt: Date.now(),
82
- role: 'user',
83
- sessionId: 'test',
84
- topicId: 'test',
85
- meta: {},
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