@lobehub/chat 0.96.2 โ†’ 0.96.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 CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.96.4](https://github.com/lobehub/lobe-chat/compare/v0.96.3...v0.96.4)
6
+
7
+ <sup>Released on **2023-10-29**</sup>
8
+
9
+ #### ๐Ÿ› Bug Fixes
10
+
11
+ - **misc**: Fix agents market locale fallback to english.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Fix agents market locale fallback to english, closes [#382](https://github.com/lobehub/lobe-chat/issues/382) ([3814523](https://github.com/lobehub/lobe-chat/commit/3814523))
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.96.3](https://github.com/lobehub/lobe-chat/compare/v0.96.2...v0.96.3)
31
+
32
+ <sup>Released on **2023-10-28**</sup>
33
+
34
+ #### ๐Ÿ’„ Styles
35
+
36
+ - **misc**: Fix SessionList on mobile.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### Styles
44
+
45
+ - **misc**: Fix SessionList on mobile ([e7e7b80](https://github.com/lobehub/lobe-chat/commit/e7e7b80))
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.96.2](https://github.com/lobehub/lobe-chat/compare/v0.96.1...v0.96.2)
6
56
 
7
57
  <sup>Released on **2023-10-28**</sup>
@@ -193,7 +243,7 @@
193
243
 
194
244
  #### ๐Ÿ› Bug Fixes
195
245
 
196
- - **misc**: Fix agent share formate.
246
+ - **misc**: Fix agent share format.
197
247
 
198
248
  <br/>
199
249
 
@@ -202,7 +252,7 @@
202
252
 
203
253
  #### What's fixed
204
254
 
205
- - **misc**: Fix agent share formate ([56ebc0b](https://github.com/lobehub/lobe-chat/commit/56ebc0b))
255
+ - **misc**: Fix agent share format ([56ebc0b](https://github.com/lobehub/lobe-chat/commit/56ebc0b))
206
256
 
207
257
  </details>
208
258
 
@@ -1004,7 +1054,7 @@
1004
1054
 
1005
1055
  #### ๐Ÿ› Bug Fixes
1006
1056
 
1007
- - **misc**: Fix mobile safearea (fix.
1057
+ - **misc**: Fix mobile safe area (fix.
1008
1058
 
1009
1059
  <br/>
1010
1060
 
@@ -1013,7 +1063,7 @@
1013
1063
 
1014
1064
  #### What's fixed
1015
1065
 
1016
- - **misc**: Fix mobile safearea (fix, closes [#211](https://github.com/lobehub/lobe-chat/issues/211) ([68775b8](https://github.com/lobehub/lobe-chat/commit/68775b8))
1066
+ - **misc**: Fix mobile safe area (fix, closes [#211](https://github.com/lobehub/lobe-chat/issues/211) ([68775b8](https://github.com/lobehub/lobe-chat/commit/68775b8))
1017
1067
 
1018
1068
  </details>
1019
1069
 
@@ -1663,7 +1713,7 @@
1663
1713
 
1664
1714
  #### ๐Ÿ’„ Styles
1665
1715
 
1666
- - **misc**: Fix conversation mobile viewarea.
1716
+ - **misc**: Fix conversation mobile view area.
1667
1717
 
1668
1718
  <br/>
1669
1719
 
@@ -1672,7 +1722,7 @@
1672
1722
 
1673
1723
  #### Styles
1674
1724
 
1675
- - **misc**: Fix conversation mobile viewarea ([6668e11](https://github.com/lobehub/lobe-chat/commit/6668e11))
1725
+ - **misc**: Fix conversation mobile view area ([6668e11](https://github.com/lobehub/lobe-chat/commit/6668e11))
1676
1726
 
1677
1727
  </details>
1678
1728
 
@@ -1713,7 +1763,7 @@
1713
1763
 
1714
1764
  #### ๐Ÿ’„ Styles
1715
1765
 
1716
- - **misc**: Fix safeare in mobile.
1766
+ - **misc**: Fix safearea in mobile.
1717
1767
 
1718
1768
  <br/>
1719
1769
 
@@ -1722,7 +1772,7 @@
1722
1772
 
1723
1773
  #### Styles
1724
1774
 
1725
- - **misc**: Fix safeare in mobile ([2adfb04](https://github.com/lobehub/lobe-chat/commit/2adfb04))
1775
+ - **misc**: Fix safearea in mobile ([2adfb04](https://github.com/lobehub/lobe-chat/commit/2adfb04))
1726
1776
 
1727
1777
  </details>
1728
1778
 
@@ -1763,7 +1813,7 @@
1763
1813
 
1764
1814
  #### ๐Ÿ’„ Styles
1765
1815
 
1766
- - **misc**: Optmize PWA style and scroll effect.
1816
+ - **misc**: Optimize PWA style and scroll effect.
1767
1817
 
1768
1818
  <br/>
1769
1819
 
@@ -1772,7 +1822,7 @@
1772
1822
 
1773
1823
  #### Styles
1774
1824
 
1775
- - **misc**: Optmize PWA style and scroll effect ([0ae05b8](https://github.com/lobehub/lobe-chat/commit/0ae05b8))
1825
+ - **misc**: Optimize PWA style and scroll effect ([0ae05b8](https://github.com/lobehub/lobe-chat/commit/0ae05b8))
1776
1826
 
1777
1827
  </details>
1778
1828
 
@@ -2199,7 +2249,7 @@
2199
2249
 
2200
2250
  #### โœจ Features
2201
2251
 
2202
- - **misc**: Add russian localy, Update Russian and English localy (LLM tab).
2252
+ - **misc**: Add russian locally, Update Russian and English locally (LLM tab).
2203
2253
 
2204
2254
  <br/>
2205
2255
 
@@ -2208,8 +2258,8 @@
2208
2258
 
2209
2259
  #### What's improved
2210
2260
 
2211
- - **misc**: Add russian localy ([7b67c9f](https://github.com/lobehub/lobe-chat/commit/7b67c9f))
2212
- - **misc**: Update Russian and English localy (LLM tab) ([3b23e70](https://github.com/lobehub/lobe-chat/commit/3b23e70))
2261
+ - **misc**: Add russian locally ([7b67c9f](https://github.com/lobehub/lobe-chat/commit/7b67c9f))
2262
+ - **misc**: Update Russian and English locally (LLM tab) ([3b23e70](https://github.com/lobehub/lobe-chat/commit/3b23e70))
2213
2263
 
2214
2264
  </details>
2215
2265
 
@@ -2568,7 +2618,7 @@
2568
2618
 
2569
2619
  #### โ™ป Code Refactoring
2570
2620
 
2571
- - **misc**: Mirgrate openai-edge to openai.
2621
+ - **misc**: Migrate openai-edge to openai.
2572
2622
 
2573
2623
  <br/>
2574
2624
 
@@ -2577,7 +2627,7 @@
2577
2627
 
2578
2628
  #### Code refactoring
2579
2629
 
2580
- - **misc**: Mirgrate openai-edge to openai, closes [#145](https://github.com/lobehub/lobe-chat/issues/145) ([75ee574](https://github.com/lobehub/lobe-chat/commit/75ee574))
2630
+ - **misc**: Migrate openai-edge to openai, closes [#145](https://github.com/lobehub/lobe-chat/issues/145) ([75ee574](https://github.com/lobehub/lobe-chat/commit/75ee574))
2581
2631
 
2582
2632
  </details>
2583
2633
 
@@ -2712,7 +2762,7 @@
2712
2762
 
2713
2763
  #### โœจ Features
2714
2764
 
2715
- - **misc**: Add russian localy.
2765
+ - **misc**: Add russian locally.
2716
2766
 
2717
2767
  <br/>
2718
2768
 
@@ -2721,7 +2771,7 @@
2721
2771
 
2722
2772
  #### What's improved
2723
2773
 
2724
- - **misc**: Add russian localy, closes [#137](https://github.com/lobehub/lobe-chat/issues/137) ([785d50f](https://github.com/lobehub/lobe-chat/commit/785d50f))
2774
+ - **misc**: Add russian locally, closes [#137](https://github.com/lobehub/lobe-chat/issues/137) ([785d50f](https://github.com/lobehub/lobe-chat/commit/785d50f))
2725
2775
 
2726
2776
  </details>
2727
2777
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.96.2",
3
+ "version": "0.96.4",
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",
@@ -0,0 +1,19 @@
1
+ import { DEFAULT_LANG } from '@/const/locale';
2
+ import { getAgentJSON } from '@/const/url';
3
+
4
+ export const runtime = 'edge';
5
+
6
+ export const GET = async (req: Request, { params }: { params: { id: string } }) => {
7
+ const { searchParams } = new URL(req.url);
8
+
9
+ const locale = searchParams.get('locale');
10
+
11
+ let res: Response;
12
+
13
+ res = await fetch(getAgentJSON(params.id, locale as any));
14
+ if (res.status === 404) {
15
+ res = await fetch(getAgentJSON(params.id, DEFAULT_LANG));
16
+ }
17
+
18
+ return res;
19
+ };
@@ -0,0 +1,18 @@
1
+ import { DEFAULT_LANG } from '@/const/locale';
2
+ import { getAgentIndexJSON } from '@/const/url';
3
+
4
+ export const runtime = 'edge';
5
+
6
+ export const GET = async (req: Request) => {
7
+ const locale = new URL(req.url).searchParams.get('locale');
8
+
9
+ let res: Response;
10
+
11
+ res = await fetch(getAgentIndexJSON(locale as any));
12
+
13
+ if (res.status === 404) {
14
+ res = await fetch(getAgentIndexJSON(DEFAULT_LANG));
15
+ }
16
+
17
+ return res;
18
+ };
@@ -4,12 +4,16 @@ import { createStyles } from 'antd-style';
4
4
  import { ChevronDown } from 'lucide-react';
5
5
  import { memo } from 'react';
6
6
 
7
- const useStyles = createStyles(({ css, prefixCls, token }) => ({
7
+ const useStyles = createStyles(({ css, prefixCls, token, responsive }) => ({
8
8
  container: css`
9
9
  .${prefixCls}-collapse-header {
10
- padding-inline: 16px !important;
10
+ padding-inline: 16px 10px !important;
11
11
  color: ${token.colorTextDescription} !important;
12
- border-radius: 8px !important;
12
+ border-radius: ${token.borderRadius}px !important;
13
+
14
+ ${responsive.mobile} {
15
+ border-radius: 0 !important;
16
+ }
13
17
 
14
18
  &:hover {
15
19
  color: ${token.colorText} !important;
@@ -1,22 +1,16 @@
1
- import { Avatar, List } from '@lobehub/ui';
2
- import { useHover } from 'ahooks';
3
1
  import { useResponsive } from 'antd-style';
4
2
  import Link from 'next/link';
5
- import { memo, useMemo, useRef } from 'react';
3
+ import { memo } from 'react';
6
4
  import { useTranslation } from 'react-i18next';
7
5
 
8
- import { useStyles } from '@/app/chat/features/SessionListContent/List/Item';
9
6
  import { DEFAULT_INBOX_AVATAR } from '@/const/meta';
10
7
  import { INBOX_SESSION_ID } from '@/const/session';
11
8
  import { SESSION_CHAT_URL } from '@/const/url';
12
9
  import { useSessionStore } from '@/store/session';
13
10
 
14
- const { Item } = List;
11
+ import ListItem from '../ListItem';
15
12
 
16
13
  const Inbox = memo(() => {
17
- const ref = useRef(null);
18
- const { styles } = useStyles();
19
- const isHovering = useHover(ref);
20
14
  const { t } = useTranslation('chat');
21
15
  const { mobile } = useResponsive();
22
16
  const [activeId, activeSession, switchSession] = useSessionStore((s) => [
@@ -25,18 +19,6 @@ const Inbox = memo(() => {
25
19
  s.switchSession,
26
20
  ]);
27
21
 
28
- const avatarRender = useMemo(
29
- () => (
30
- <Avatar
31
- animation={isHovering}
32
- avatar={DEFAULT_INBOX_AVATAR}
33
- size={46}
34
- style={{ padding: 3 }}
35
- />
36
- ),
37
- [isHovering],
38
- );
39
-
40
22
  return (
41
23
  <Link
42
24
  aria-label={t('inbox.title')}
@@ -47,11 +29,9 @@ const Inbox = memo(() => {
47
29
  else activeSession(INBOX_SESSION_ID);
48
30
  }}
49
31
  >
50
- <Item
51
- active={mobile ? false : activeId === INBOX_SESSION_ID}
52
- avatar={avatarRender}
53
- className={styles.container}
54
- ref={ref}
32
+ <ListItem
33
+ active={activeId === INBOX_SESSION_ID}
34
+ avatar={DEFAULT_INBOX_AVATAR}
55
35
  title={t('inbox.title')}
56
36
  />
57
37
  </Link>
@@ -1,8 +1,6 @@
1
1
  import { SiOpenai } from '@icons-pack/react-simple-icons';
2
- import { Avatar, List, Tag } from '@lobehub/ui';
3
- import { useHover } from 'ahooks';
4
- import { createStyles, useResponsive } from 'antd-style';
5
- import { memo, useMemo, useRef, useState } from 'react';
2
+ import { Tag } from '@lobehub/ui';
3
+ import { memo, useMemo, useState } from 'react';
6
4
  import { Flexbox } from 'react-layout-kit';
7
5
  import { shallow } from 'zustand/shallow';
8
6
 
@@ -10,32 +8,16 @@ import { settingsSelectors, useGlobalStore } from '@/store/global';
10
8
  import { useSessionStore } from '@/store/session';
11
9
  import { agentSelectors, sessionSelectors } from '@/store/session/selectors';
12
10
 
11
+ import ListItem from '../../ListItem';
13
12
  import Actions from './Actions';
14
13
 
15
- const { Item } = List;
16
-
17
- export const useStyles = createStyles(({ css, token, responsive }) => {
18
- return {
19
- container: css`
20
- position: relative;
21
- border-radius: ${token.borderRadius}px;
22
- ${responsive.mobile} {
23
- border-radius: 0;
24
- }
25
- `,
26
- };
27
- });
28
-
29
14
  interface SessionItemProps {
30
15
  id: string;
31
16
  }
32
17
 
33
18
  const SessionItem = memo<SessionItemProps>(({ id }) => {
34
19
  const [open, setOpen] = useState(false);
35
- const ref = useRef(null);
36
- const isHovering = useHover(ref);
37
- const { mobile } = useResponsive();
38
- const { styles } = useStyles();
20
+
39
21
  const [defaultModel] = useGlobalStore((s) => [settingsSelectors.defaultAgentConfig(s).model]);
40
22
 
41
23
  const [
@@ -72,19 +54,6 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
72
54
 
73
55
  const actions = useMemo(() => <Actions id={id} setOpen={setOpen} />, [id]);
74
56
 
75
- const avatarRender = useMemo(
76
- () => (
77
- <Avatar
78
- animation={isHovering}
79
- avatar={avatar}
80
- background={avatarBackground}
81
- shape="circle"
82
- size={46}
83
- />
84
- ),
85
- [isHovering, avatar, avatarBackground],
86
- );
87
-
88
57
  const addon = useMemo(
89
58
  () =>
90
59
  !showModel ? undefined : (
@@ -96,23 +65,19 @@ const SessionItem = memo<SessionItemProps>(({ id }) => {
96
65
  );
97
66
 
98
67
  return (
99
- <Flexbox paddingBlock={1}>
100
- <Item
101
- actions={actions}
102
- // needn't active state in mobile
103
- active={mobile ? false : active}
104
- addon={addon}
105
- avatar={avatarRender}
106
- className={styles.container}
107
- date={updateAt}
108
- description={description || systemRole}
109
- loading={loading}
110
- pin={pin}
111
- ref={ref}
112
- showAction={open || isHovering}
113
- title={title}
114
- />
115
- </Flexbox>
68
+ <ListItem
69
+ actions={actions}
70
+ active={active}
71
+ addon={addon}
72
+ avatar={avatar}
73
+ avatarBackground={avatarBackground}
74
+ date={updateAt}
75
+ description={description || systemRole}
76
+ loading={loading}
77
+ pin={pin}
78
+ showAction={open}
79
+ title={title}
80
+ />
116
81
  );
117
82
  }, shallow);
118
83
 
@@ -0,0 +1,61 @@
1
+ import { Avatar, List, ListItemProps } from '@lobehub/ui';
2
+ import { useHover } from 'ahooks';
3
+ import { createStyles, useResponsive } from 'antd-style';
4
+ import { memo, useMemo, useRef } from 'react';
5
+
6
+ const { Item } = List;
7
+
8
+ const useStyles = createStyles(({ css, token, responsive }) => {
9
+ return {
10
+ container: css`
11
+ position: relative;
12
+
13
+ margin-block: 2px;
14
+ padding-right: 16px;
15
+ padding-left: 8px;
16
+
17
+ border-radius: ${token.borderRadius}px;
18
+ ${responsive.mobile} {
19
+ margin-block: 0;
20
+ padding-left: 12px;
21
+ border-radius: 0;
22
+ }
23
+ `,
24
+ };
25
+ });
26
+
27
+ const ListItem = memo<ListItemProps & { avatar: string; avatarBackground?: string }>(
28
+ ({ avatar, avatarBackground, active, showAction, actions, ...props }) => {
29
+ const ref = useRef(null);
30
+ const isHovering = useHover(ref);
31
+ const { mobile } = useResponsive();
32
+ const { styles } = useStyles();
33
+
34
+ const avatarRender = useMemo(
35
+ () => (
36
+ <Avatar
37
+ animation={isHovering}
38
+ avatar={avatar}
39
+ background={avatarBackground}
40
+ shape="circle"
41
+ size={46}
42
+ />
43
+ ),
44
+ [isHovering, avatar, avatarBackground],
45
+ );
46
+
47
+ return (
48
+ <Item
49
+ actions={actions}
50
+ active={mobile ? false : active}
51
+ avatar={avatarRender}
52
+ className={styles.container}
53
+ ref={ref}
54
+ showAction={actions && (isHovering || showAction)}
55
+ {...(props as any)}
56
+ />
57
+ );
58
+ },
59
+ );
60
+
61
+ export default ListItem;
@@ -1,4 +1,5 @@
1
1
  export const URLS = {
2
+ market: '/api/market',
2
3
  plugins: '/api/plugins',
3
4
  };
4
5
 
@@ -1,30 +1,21 @@
1
- import { getAgentIndexJSON, getAgentJSON } from '@/const/url';
2
- import { getCurrentLanguage } from '@/store/global/helpers';
1
+ import { URLS } from '@/services/_url';
3
2
  import { LobeChatAgentsMarketIndex } from '@/types/market';
4
3
 
5
4
  /**
6
5
  * ่ฏทๆฑ‚ๅŠฉๆ‰‹ๅˆ—่กจ
7
6
  */
8
- export const getAgentList = async () => {
9
- let res: Response;
7
+ export const getAgentList = async (locale: string): Promise<LobeChatAgentsMarketIndex> => {
8
+ const res = await fetch(`${URLS.market}?locale=${locale}`);
10
9
 
11
- res = await fetch(getAgentIndexJSON(getCurrentLanguage()));
12
-
13
- if (res.status === 404) {
14
- res = await fetch(getAgentIndexJSON('en-US'));
15
- }
16
-
17
- const data: LobeChatAgentsMarketIndex = await res.json();
18
-
19
- return data;
10
+ return res.json();
20
11
  };
21
12
 
22
13
  /**
23
14
  * ่ฏทๆฑ‚ๅŠฉๆ‰‹ manifest
24
15
  */
25
- export const getAgentManifest = async (identifier?: string) => {
16
+ export const getAgentManifest = async (identifier: string, locale: string) => {
26
17
  if (!identifier) return;
27
- const res = await fetch(getAgentJSON(identifier, getCurrentLanguage()));
18
+ const res = await fetch(`${URLS.market}/${identifier}?locale=${locale}`);
28
19
 
29
20
  return res.json();
30
21
  };
@@ -4,6 +4,7 @@ import useSWR, { SWRResponse } from 'swr';
4
4
  import type { StateCreator } from 'zustand/vanilla';
5
5
 
6
6
  import { getAgentList, getAgentManifest } from '@/services/agentMarket';
7
+ import { getCurrentLanguage } from '@/store/global/helpers';
7
8
  import { AgentsMarketItem, LobeChatAgentsMarketIndex } from '@/types/market';
8
9
 
9
10
  import type { Store } from './store';
@@ -40,16 +41,20 @@ export const createMarketAction: StateCreator<
40
41
  set({ agentMap: nextAgentMap }, false, `setAgentMap/${key}`);
41
42
  },
42
43
  useFetchAgent: (identifier) =>
43
- useSWR<AgentsMarketItem>(identifier, getAgentManifest, {
44
- onError: () => {
45
- get().deactivateAgent();
44
+ useSWR<AgentsMarketItem>(
45
+ [identifier, getCurrentLanguage()],
46
+ ([id, locale]) => getAgentManifest(id, locale as string),
47
+ {
48
+ onError: () => {
49
+ get().deactivateAgent();
50
+ },
51
+ onSuccess: (data) => {
52
+ get().updateAgentMap(identifier, data);
53
+ },
46
54
  },
47
- onSuccess: (data, key) => {
48
- get().updateAgentMap(key, data);
49
- },
50
- }),
55
+ ),
51
56
  useFetchAgentList: () =>
52
- useSWR<LobeChatAgentsMarketIndex>('fetchAgentList', getAgentList, {
57
+ useSWR<LobeChatAgentsMarketIndex>(getCurrentLanguage(), getAgentList, {
53
58
  onSuccess: (agentMarketIndex) => {
54
59
  set({ agentList: agentMarketIndex.agents }, false, 'useFetchAgentList');
55
60
  },