@lobehub/chat 1.3.3 → 1.3.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 1.3.4](https://github.com/lobehub/lobe-chat/compare/v1.3.3...v1.3.4)
6
+
7
+ <sup>Released on **2024-07-09**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Support disable clientFetch by default.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### Code refactoring
19
+
20
+ - **misc**: Support disable clientFetch by default, closes [#3133](https://github.com/lobehub/lobe-chat/issues/3133) [#3108](https://github.com/lobehub/lobe-chat/issues/3108) ([4415652](https://github.com/lobehub/lobe-chat/commit/4415652))
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 1.3.3](https://github.com/lobehub/lobe-chat/compare/v1.3.2...v1.3.3)
6
31
 
7
32
  <sup>Released on **2024-07-09**</sup>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
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",
@@ -70,6 +70,11 @@ export const filterEnabledModels = (provider: ModelProviderCard) => {
70
70
  return provider.chatModels.filter((v) => v.enabled).map((m) => m.id);
71
71
  };
72
72
 
73
+ export const isProviderDisableBroswerRequest = (id: string) => {
74
+ const provider = DEFAULT_MODEL_PROVIDER_LIST.find((v) => v.id === id && v.disableBrowserRequest);
75
+ return !!provider;
76
+ };
77
+
73
78
  export { default as AnthropicProviderCard } from './anthropic';
74
79
  export { default as AzureProviderCard } from './azure';
75
80
  export { default as BaichuanProviderCard } from './baichuan';
@@ -18,14 +18,16 @@ const Qwen: ModelProviderCard = {
18
18
  tokens: 32_000,
19
19
  },
20
20
  {
21
- description: '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,当前通义千问2.5产品版本背后的API模型',
21
+ description:
22
+ '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,当前通义千问2.5产品版本背后的API模型',
22
23
  displayName: 'Qwen Max',
23
24
  enabled: true,
24
25
  id: 'qwen-max',
25
26
  tokens: 8000,
26
27
  },
27
28
  {
28
- description: '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,扩展了上下文窗口',
29
+ description:
30
+ '通义千问千亿级别超大规模语言模型,支持中文、英文等不同语言输入,扩展了上下文窗口',
29
31
  displayName: 'Qwen Max LongContext',
30
32
  id: 'qwen-max-longcontext',
31
33
  tokens: 30_000,
@@ -50,6 +52,7 @@ const Qwen: ModelProviderCard = {
50
52
  },
51
53
  ],
52
54
  checkModel: 'qwen-turbo',
55
+ disableBrowserRequest: true,
53
56
  id: 'qwen',
54
57
  modelList: { showModelFetcher: true },
55
58
  name: 'Qwen',
@@ -109,6 +109,25 @@ describe('modelConfigSelectors', () => {
109
109
  } as UserSettingsState) as unknown as UserStore;
110
110
  expect(modelConfigSelectors.isProviderFetchOnClient('azure')(s)).toBe(true);
111
111
  });
112
+
113
+ // Qwen provider not work in broswer request. Please skip this case if it work in future.
114
+ // Issue: https://github.com/lobehub/lobe-chat/issues/3108
115
+ // PR: https://github.com/lobehub/lobe-chat/pull/3133
116
+ it('client fecth should be disabled if provider is disable broswer request', () => {
117
+ const s = merge(initialSettingsState, {
118
+ settings: {
119
+ languageModel: {
120
+ qwen: { fetchOnClient: true },
121
+ },
122
+ keyVaults: {
123
+ qwen: {
124
+ apiKey: 'apikey',
125
+ },
126
+ },
127
+ },
128
+ } as UserSettingsState) as unknown as UserStore;
129
+ expect(modelConfigSelectors.isAutoFetchModelsEnabled('qwen')(s)).toBe(false);
130
+ });
112
131
  });
113
132
 
114
133
  describe('getCustomModelCardById', () => {
@@ -1,3 +1,4 @@
1
+ import { isProviderDisableBroswerRequest } from '@/config/modelProviders';
1
2
  import { UserStore } from '@/store/user';
2
3
  import { GlobalLLMProviderKey } from '@/types/user/settings';
3
4
 
@@ -18,6 +19,9 @@ const providerWhitelist = new Set(['ollama']);
18
19
  const isProviderFetchOnClient = (provider: GlobalLLMProviderKey | string) => (s: UserStore) => {
19
20
  const config = getProviderConfigById(provider)(s);
20
21
 
22
+ // If the provider already disable broswer request in model config, force on Server.
23
+ if (isProviderDisableBroswerRequest(provider)) return false;
24
+
21
25
  // If the provider in the whitelist, follow the user settings
22
26
  if (providerWhitelist.has(provider) && typeof config?.fetchOnClient !== 'undefined')
23
27
  return config?.fetchOnClient;