@lobehub/chat 0.96.3 โ†’ 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,31 @@
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
+
5
30
  ### [Version 0.96.3](https://github.com/lobehub/lobe-chat/compare/v0.96.2...v0.96.3)
6
31
 
7
32
  <sup>Released on **2023-10-28**</sup>
@@ -218,7 +243,7 @@
218
243
 
219
244
  #### ๐Ÿ› Bug Fixes
220
245
 
221
- - **misc**: Fix agent share formate.
246
+ - **misc**: Fix agent share format.
222
247
 
223
248
  <br/>
224
249
 
@@ -227,7 +252,7 @@
227
252
 
228
253
  #### What's fixed
229
254
 
230
- - **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))
231
256
 
232
257
  </details>
233
258
 
@@ -1029,7 +1054,7 @@
1029
1054
 
1030
1055
  #### ๐Ÿ› Bug Fixes
1031
1056
 
1032
- - **misc**: Fix mobile safearea (fix.
1057
+ - **misc**: Fix mobile safe area (fix.
1033
1058
 
1034
1059
  <br/>
1035
1060
 
@@ -1038,7 +1063,7 @@
1038
1063
 
1039
1064
  #### What's fixed
1040
1065
 
1041
- - **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))
1042
1067
 
1043
1068
  </details>
1044
1069
 
@@ -1688,7 +1713,7 @@
1688
1713
 
1689
1714
  #### ๐Ÿ’„ Styles
1690
1715
 
1691
- - **misc**: Fix conversation mobile viewarea.
1716
+ - **misc**: Fix conversation mobile view area.
1692
1717
 
1693
1718
  <br/>
1694
1719
 
@@ -1697,7 +1722,7 @@
1697
1722
 
1698
1723
  #### Styles
1699
1724
 
1700
- - **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))
1701
1726
 
1702
1727
  </details>
1703
1728
 
@@ -1738,7 +1763,7 @@
1738
1763
 
1739
1764
  #### ๐Ÿ’„ Styles
1740
1765
 
1741
- - **misc**: Fix safeare in mobile.
1766
+ - **misc**: Fix safearea in mobile.
1742
1767
 
1743
1768
  <br/>
1744
1769
 
@@ -1747,7 +1772,7 @@
1747
1772
 
1748
1773
  #### Styles
1749
1774
 
1750
- - **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))
1751
1776
 
1752
1777
  </details>
1753
1778
 
@@ -1788,7 +1813,7 @@
1788
1813
 
1789
1814
  #### ๐Ÿ’„ Styles
1790
1815
 
1791
- - **misc**: Optmize PWA style and scroll effect.
1816
+ - **misc**: Optimize PWA style and scroll effect.
1792
1817
 
1793
1818
  <br/>
1794
1819
 
@@ -1797,7 +1822,7 @@
1797
1822
 
1798
1823
  #### Styles
1799
1824
 
1800
- - **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))
1801
1826
 
1802
1827
  </details>
1803
1828
 
@@ -2224,7 +2249,7 @@
2224
2249
 
2225
2250
  #### โœจ Features
2226
2251
 
2227
- - **misc**: Add russian localy, Update Russian and English localy (LLM tab).
2252
+ - **misc**: Add russian locally, Update Russian and English locally (LLM tab).
2228
2253
 
2229
2254
  <br/>
2230
2255
 
@@ -2233,8 +2258,8 @@
2233
2258
 
2234
2259
  #### What's improved
2235
2260
 
2236
- - **misc**: Add russian localy ([7b67c9f](https://github.com/lobehub/lobe-chat/commit/7b67c9f))
2237
- - **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))
2238
2263
 
2239
2264
  </details>
2240
2265
 
@@ -2593,7 +2618,7 @@
2593
2618
 
2594
2619
  #### โ™ป Code Refactoring
2595
2620
 
2596
- - **misc**: Mirgrate openai-edge to openai.
2621
+ - **misc**: Migrate openai-edge to openai.
2597
2622
 
2598
2623
  <br/>
2599
2624
 
@@ -2602,7 +2627,7 @@
2602
2627
 
2603
2628
  #### Code refactoring
2604
2629
 
2605
- - **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))
2606
2631
 
2607
2632
  </details>
2608
2633
 
@@ -2737,7 +2762,7 @@
2737
2762
 
2738
2763
  #### โœจ Features
2739
2764
 
2740
- - **misc**: Add russian localy.
2765
+ - **misc**: Add russian locally.
2741
2766
 
2742
2767
  <br/>
2743
2768
 
@@ -2746,7 +2771,7 @@
2746
2771
 
2747
2772
  #### What's improved
2748
2773
 
2749
- - **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))
2750
2775
 
2751
2776
  </details>
2752
2777
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.96.3",
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
+ };
@@ -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
  },