@lobehub/chat 0.89.9 → 0.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.90.0](https://github.com/lobehub/lobe-chat/compare/v0.89.10...v0.90.0)
6
+
7
+ <sup>Released on **2023-10-17**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Add Lazyload.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's improved
19
+
20
+ - **misc**: Add Lazyload ([27d6cb7](https://github.com/lobehub/lobe-chat/commit/27d6cb7))
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.89.10](https://github.com/lobehub/lobe-chat/compare/v0.89.9...v0.89.10)
31
+
32
+ <sup>Released on **2023-10-17**</sup>
33
+
34
+ #### ♻ Code Refactoring
35
+
36
+ - **misc**: Refactor ChatList onActionsClick.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Code refactoring
44
+
45
+ - **misc**: Refactor ChatList onActionsClick ([d06d87e](https://github.com/lobehub/lobe-chat/commit/d06d87e))
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.89.9](https://github.com/lobehub/lobe-chat/compare/v0.89.8...v0.89.9)
6
56
 
7
57
  <sup>Released on **2023-10-17**</sup>
package/README.md CHANGED
@@ -90,8 +90,8 @@ Please be aware that LobeChat is currently under active development, and feedbac
90
90
  - [x] 💎 **Exquisite UI Design**: With a carefully designed interface, it offers an elegant appearance and smooth interaction. It supports light and dark themes and is mobile-friendly. PWA support provides a more native-like experience.
91
91
  - [x] 🗣️ **Smooth Conversation Experience**: Fluid responses ensure a smooth conversation experience. It fully supports Markdown rendering, including code highlighting, LaTex formulas, Mermaid flowcharts, and more.
92
92
  - [x] 🧩 **Plugin Support & Custom Plugin Development**: Conversations are extendable with plugins. Users can install and use various plugins, such as search engines, web extraction, etc. It also supports the development of custom plugins to meet custom needs.
93
- - [x] 🔒 **Privacy Protection**: All data is stored locally in the user's browser, ensuring user privacy;
94
- - [x] 🤖 **Customizable Agent Roles**: Users can create, share, and debug personalized dialogue agent roles according to their needs, providing more flexible and customized dialogue functions;
93
+ - [x] 🔒 **Privacy Protection**: All data is stored locally in the user's browser, ensuring user privacy.
94
+ - [x] 🤖 **Customizable Agent Roles**: Users can create, share, and debug personalized dialogue agent roles according to their needs, providing more flexible and customized dialogue functions.
95
95
  - [x] 🌐 **Custom Domain**: If users have their own domain, they can bind it to the platform for quick access to the dialogue agent from anywhere.
96
96
  - [x] 🏬 **Role Market**: A Role Market is provided where users can select their preferred dialogue agent roles, enriching the content and style of the dialogue.
97
97
 
@@ -335,7 +335,7 @@ Contributions of all types are more than welcome; if you are interested in contr
335
335
 
336
336
  ## 🔗 More Products
337
337
 
338
- - **[🤯 Lobe Theme][lobe-theme]:** The modern theme for stable diffusion WebUI, exquisite interface design, highly customizable UI, and efficiency-boosting features.
338
+ - **[🤯 Lobe Theme][lobe-theme]:** The modern theme for Stable Diffusion WebUI, exquisite interface design, highly customizable UI, and efficiency-boosting features.
339
339
  - **[🌏 Lobe i18n][lobe-i18n] :** Lobe i18n is an automation tool for the i18n (internationalization) translation process, powered by ChatGPT. It supports features such as automatic splitting of large files, incremental updates, and customization options for the OpenAI model, API proxy, and temperature.
340
340
  - **[💌 Lobe Commit][lobe-commit]:** Lobe Commit is a CLI tool that leverages Langchain/ChatGPT to generate Gitmoji-based commit messages.
341
341
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.89.9",
3
+ "version": "0.90.0",
4
4
  "description": "An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application",
5
5
  "keywords": [
6
6
  "chatbot",
@@ -103,6 +103,7 @@
103
103
  "react-i18next": "^13",
104
104
  "react-intersection-observer": "^9",
105
105
  "react-layout-kit": "^1",
106
+ "react-lazy-load": "^4",
106
107
  "remark": "^14",
107
108
  "remark-gfm": "^3",
108
109
  "remark-html": "^15",
@@ -34,8 +34,7 @@ export const useStyles = createStyles(({ css, token, stylish, cx }, withBackgrou
34
34
  preview: cx(
35
35
  stylish.noScrollbar,
36
36
  css`
37
- overflow-x: hidden;
38
- overflow-y: scroll;
37
+ overflow: hidden scroll;
39
38
 
40
39
  width: 100%;
41
40
  max-height: 40vh;
@@ -44,18 +44,9 @@ const List = memo(() => {
44
44
  enableHistoryCount={enableHistoryCount}
45
45
  historyCount={historyCount}
46
46
  loadingId={chatLoadingId}
47
- onActionClick={(key, id) => {
48
- switch (key) {
49
- case 'delete': {
50
- deleteMessage(id);
51
- break;
52
- }
53
-
54
- case 'regenerate': {
55
- resendMessage(id);
56
- break;
57
- }
58
- }
47
+ onActionsClick={{
48
+ del: ({ id }) => deleteMessage(id),
49
+ regenerate: ({ id }) => resendMessage(id),
59
50
  }}
60
51
  onMessageChange={(id, content) =>
61
52
  dispatchMessage({ id, key: 'content', type: 'updateMessage', value: content })
@@ -12,8 +12,7 @@ import ChatScrollAnchor from './ScrollAnchor';
12
12
 
13
13
  const useStyles = createStyles(
14
14
  ({ css, responsive, stylish }) => css`
15
- overflow-x: hidden;
16
- overflow-y: scroll;
15
+ overflow: hidden scroll;
17
16
  height: 100%;
18
17
  ${responsive.mobile} {
19
18
  ${stylish.noScrollbar}
@@ -2,6 +2,7 @@ import { useResponsive } from 'antd-style';
2
2
  import isEqual from 'fast-deep-equal';
3
3
  import Link from 'next/link';
4
4
  import { memo } from 'react';
5
+ import LazyLoad from 'react-lazy-load';
5
6
 
6
7
  import { SESSION_CHAT_URL } from '@/const/url';
7
8
  import { useSessionHydrated, useSessionStore } from '@/store/session';
@@ -23,18 +24,19 @@ const SessionList = memo(() => {
23
24
  <SkeletonList />
24
25
  ) : list.length > 0 ? (
25
26
  list.map(({ id }) => (
26
- <Link
27
- aria-label={id}
28
- href={SESSION_CHAT_URL(id, mobile)}
29
- key={id}
30
- onClick={(e) => {
31
- e.preventDefault();
32
- if (mobile) switchSession(id);
33
- else activeSession(id);
34
- }}
35
- >
36
- <SessionItem id={id} />
37
- </Link>
27
+ <LazyLoad height={70} key={id}>
28
+ <Link
29
+ aria-label={id}
30
+ href={SESSION_CHAT_URL(id, mobile)}
31
+ onClick={(e) => {
32
+ e.preventDefault();
33
+ if (mobile) switchSession(id);
34
+ else activeSession(id);
35
+ }}
36
+ >
37
+ <SessionItem id={id} />
38
+ </Link>
39
+ </LazyLoad>
38
40
  ))
39
41
  ) : (
40
42
  <AddButton />
@@ -2,8 +2,7 @@ import { createStyles } from 'antd-style';
2
2
 
3
3
  export const useStyles = createStyles(({ css, token }) => ({
4
4
  prompt: css`
5
- overflow-x: hidden;
6
- overflow-y: auto;
5
+ overflow: hidden auto;
7
6
 
8
7
  padding: 0 16px 16px;
9
8
 
@@ -12,7 +12,7 @@ const useStyles = createStyles(({ css, token, isDarkMode }) => ({
12
12
  `,
13
13
  }));
14
14
 
15
- const AgentCard = memo<SpotlightCardProps>(({ items, renderItem, gap = 8, ...props }) => {
15
+ const AgentCard = memo<SpotlightCardProps>(({ items, renderItem, gap = 16, ...props }) => {
16
16
  const { styles } = useStyles();
17
17
  return (
18
18
  <Flexbox gap={gap} {...props}>
@@ -12,6 +12,6 @@ import Layout from './layout.mobile';
12
12
  export default memo<{ defaultAgents?: AgentsMarketIndexItem[] }>(({ defaultAgents }) => (
13
13
  <Layout>
14
14
  <Index />
15
- <AgentCard CardRender={CardRender} defaultAgents={defaultAgents} />
15
+ <AgentCard CardRender={CardRender} defaultAgents={defaultAgents} mobile />
16
16
  </Layout>
17
17
  ));
@@ -28,7 +28,6 @@ const AgentCardItem = memo<AgentsMarketIndexItem>(({ meta, identifier }) => {
28
28
  animation={isHovering}
29
29
  avatar={avatar}
30
30
  background={backgroundColor || theme.colorFillTertiary}
31
- className={styles.avatar}
32
31
  size={56}
33
32
  />
34
33
  <Paragraph className={styles.title} ellipsis={{ rows: 1, tooltip: title }}>
@@ -38,7 +37,7 @@ const AgentCardItem = memo<AgentsMarketIndexItem>(({ meta, identifier }) => {
38
37
  {description}
39
38
  </Paragraph>
40
39
  <Flexbox gap={6} horizontal style={{ flexWrap: 'wrap' }}>
41
- {(tags as string[]).map((tag: string, index) => (
40
+ {(tags as string[]).filter(Boolean).map((tag: string, index) => (
42
41
  <Tag key={index} style={{ margin: 0 }}>
43
42
  {startCase(tag).trim()}
44
43
  </Tag>
@@ -1,8 +1,8 @@
1
1
  import { SpotlightCardProps } from '@lobehub/ui';
2
- import { useResponsive } from 'antd-style';
3
2
  import { FC, memo, useMemo } from 'react';
4
3
  import { useTranslation } from 'react-i18next';
5
4
  import { Flexbox } from 'react-layout-kit';
5
+ import LazyLoad from 'react-lazy-load';
6
6
 
7
7
  import { agentMarketSelectors, useMarketStore } from '@/store/market';
8
8
  import { AgentsMarketIndexItem } from '@/types/market';
@@ -12,16 +12,25 @@ import AgentCardItem from './AgentCardItem';
12
12
  import Loading from './Loading';
13
13
  import { useStyles } from './style';
14
14
 
15
- const gridRender = (item: any) => <AgentCardItem {...item} />;
15
+ const gridRender: SpotlightCardProps['renderItem'] = (item) => {
16
+ // eslint-disable-next-line react-hooks/rules-of-hooks
17
+ const { styles } = useStyles();
18
+ return (
19
+ <LazyLoad className={styles.lazy}>
20
+ <AgentCardItem {...item} />
21
+ </LazyLoad>
22
+ );
23
+ };
16
24
 
17
25
  export interface AgentCardProps {
18
26
  CardRender: FC<SpotlightCardProps>;
19
27
  defaultAgents?: AgentsMarketIndexItem[];
28
+ mobile?: boolean;
20
29
  }
21
30
 
22
- const AgentCard = memo<AgentCardProps>(({ defaultAgents, CardRender }) => {
31
+ const AgentCard = memo<AgentCardProps>(({ defaultAgents, CardRender, mobile }) => {
23
32
  const { t } = useTranslation('market');
24
- const { mobile } = useResponsive();
33
+
25
34
  const { styles } = useStyles();
26
35
 
27
36
  const [useFetchAgentList, keywords] = useMarketStore((s) => [
@@ -44,13 +53,21 @@ const AgentCard = memo<AgentCardProps>(({ defaultAgents, CardRender }) => {
44
53
  <Flexbox gap={mobile ? 16 : 24}>
45
54
  <TagList />
46
55
  {keywords ? (
47
- <CardRender items={agentListData} renderItem={gridRender} spotlight={false} />
56
+ <CardRender
57
+ items={agentListData}
58
+ renderItem={gridRender}
59
+ spotlight={mobile ? undefined : false}
60
+ />
48
61
  ) : (
49
62
  <>
50
63
  <div className={styles.subTitle}>{t('title.recentSubmits')}</div>
51
64
  <CardRender items={agentListData.slice(0, 3)} renderItem={gridRender} />
52
65
  <div className={styles.subTitle}>{t('title.allAgents')}</div>
53
- <CardRender items={agentListData.slice(3)} renderItem={gridRender} spotlight={false} />
66
+ <CardRender
67
+ items={agentListData.slice(3)}
68
+ renderItem={gridRender}
69
+ spotlight={mobile ? undefined : false}
70
+ />
54
71
  </>
55
72
  )}
56
73
  </Flexbox>
@@ -1,8 +1,6 @@
1
1
  import { createStyles } from 'antd-style';
2
2
 
3
3
  export const useStyles = createStyles(({ css, token, responsive }) => ({
4
- avatar: css``,
5
-
6
4
  container: css`
7
5
  position: relative;
8
6
  overflow: hidden;
@@ -17,6 +15,9 @@ export const useStyles = createStyles(({ css, token, responsive }) => ({
17
15
  inner: css`
18
16
  padding: 16px;
19
17
  `,
18
+ lazy: css`
19
+ min-height: 232px;
20
+ `,
20
21
  subTitle: css`
21
22
  font-size: 24px;
22
23
  font-weight: 600;
@@ -56,8 +56,7 @@ export const useStyles = createStyles(({ css, token, stylish, cx, prefixCls }) =
56
56
  css`
57
57
  position: relative;
58
58
 
59
- overflow-x: hidden;
60
- overflow-y: auto;
59
+ overflow: hidden auto;
61
60
 
62
61
  max-width: 1024px;
63
62
  height: 100%;
@@ -14,8 +14,7 @@ const useStyles = createStyles(({ css, cx, stylish }) => ({
14
14
  css`
15
15
  position: relative;
16
16
 
17
- overflow-x: hidden;
18
- overflow-y: auto;
17
+ overflow: hidden auto;
19
18
 
20
19
  width: 100vw;
21
20
  height: 100%;