@lobehub/chat 0.142.1 → 0.142.3

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/.env.example CHANGED
@@ -98,6 +98,7 @@ OPENAI_API_KEY=sk-xxxxxxxxx
98
98
  ########################################
99
99
 
100
100
  #OPENROUTER_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
101
+ #OPENROUTER_CUSTOM_MODELS=model1,model2,model3
101
102
 
102
103
  ########################################
103
104
  ######### 01.AI Service ##########
package/CHANGELOG.md CHANGED
@@ -2,6 +2,56 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 0.142.3](https://github.com/lobehub/lobe-chat/compare/v0.142.2...v0.142.3)
6
+
7
+ <sup>Released on **2024-03-26**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Pin `next-auth` temporary to fix build error.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Pin `next-auth` temporary to fix build error, closes [#1739](https://github.com/lobehub/lobe-chat/issues/1739) ([e9ece9f](https://github.com/lobehub/lobe-chat/commit/e9ece9f))
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.142.2](https://github.com/lobehub/lobe-chat/compare/v0.142.1...v0.142.2)
31
+
32
+ <sup>Released on **2024-03-25**</sup>
33
+
34
+ #### 🐛 Bug Fixes
35
+
36
+ - **misc**: Support openrouter custom models env.
37
+
38
+ <br/>
39
+
40
+ <details>
41
+ <summary><kbd>Improvements and Fixes</kbd></summary>
42
+
43
+ #### What's fixed
44
+
45
+ - **misc**: Support openrouter custom models env, closes [#1647](https://github.com/lobehub/lobe-chat/issues/1647) ([78baa16](https://github.com/lobehub/lobe-chat/commit/78baa16))
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.142.1](https://github.com/lobehub/lobe-chat/compare/v0.142.0...v0.142.1)
6
56
 
7
57
  <sup>Released on **2024-03-25**</sup>
package/Dockerfile CHANGED
@@ -94,6 +94,7 @@ ENV MISTRAL_API_KEY ""
94
94
 
95
95
  # OpenRouter
96
96
  ENV OPENROUTER_API_KEY ""
97
+ ENV OPENROUTER_CUSTOM_MODELS ""
97
98
 
98
99
  # 01.AI
99
100
  ENV ZEROONE_API_KEY ""
@@ -188,5 +188,12 @@ When using the `turn` mode, the API Keys will be retrieved in a round-robin mann
188
188
  - Default: -
189
189
  - Example: `sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=`
190
190
 
191
+ ### `OPENROUTER_CUSTOM_MODELS`
192
+
193
+ - Type: Optional
194
+ - Description: Used to control the model list, use `+` to add a model, use `-` to hide a model, use `model_name=display_name` to customize the display name of a model, separated by commas.
195
+ - Default: `-`
196
+ - Example: `-all,+01-ai/yi-34b-chat,+huggingfaceh4/zephyr-7b-beta`
197
+
191
198
 
192
199
  [azure-api-verion-url]: https://docs.microsoft.com/zh-cn/azure/developer/javascript/api-reference/es-modules/azure-sdk/ai-translation/translationconfiguration?view=azure-node-latest#api-version
@@ -186,6 +186,13 @@ LobeChat 在部署时提供了丰富的模型服务商相关的环境变量,
186
186
  - 默认值:-
187
187
  - 示例:`sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=`
188
188
 
189
+ ### `OPENROUTER_CUSTOM_MODELS`
190
+
191
+ - 类型:可选
192
+ - 描述:用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。
193
+ - 默认值:`-`
194
+ - 示例:`-all,+01-ai/yi-34b-chat,+huggingfaceh4/zephyr-7b-beta`
195
+
189
196
  ## 01 AI
190
197
 
191
198
  ### `ZEROONE_API_KEY`
@@ -13,7 +13,7 @@
13
13
 
14
14
  前往 [OpenAI API Key](https://platform.openai.com/account/api-keys) 获取你的 OpenAI API Key
15
15
 
16
- ### 在 Netflix 工作台导入
16
+ ### 在 Netlify 工作台导入
17
17
 
18
18
  <Callout>经过测试,暂不支持类似 Vercel/Zeabur 的一键部署按钮,原因未知。因此需要手动导入</Callout>
19
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.142.1",
3
+ "version": "0.142.3",
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",
@@ -80,7 +80,7 @@
80
80
  "dependencies": {
81
81
  "@ant-design/icons": "^5",
82
82
  "@anthropic-ai/sdk": "^0.18.0",
83
- "@auth/core": "latest",
83
+ "@auth/core": "0.28.0",
84
84
  "@aws-sdk/client-bedrock-runtime": "^3.525.0",
85
85
  "@azure/openai": "^1.0.0-beta.11",
86
86
  "@cfworker/json-schema": "^1",
@@ -119,7 +119,7 @@
119
119
  "modern-screenshot": "^4",
120
120
  "nanoid": "^5",
121
121
  "next": "^14.1",
122
- "next-auth": "beta",
122
+ "next-auth": "5.0.0-beta.15",
123
123
  "next-sitemap": "^4",
124
124
  "numeral": "^2",
125
125
  "nuqs": "^1",
@@ -26,6 +26,7 @@ export const GET = async () => {
26
26
  ENABLED_ZEROONE,
27
27
  DEFAULT_AGENT_CONFIG,
28
28
  OLLAMA_CUSTOM_MODELS,
29
+ OPENROUTER_CUSTOM_MODELS,
29
30
  } = getServerConfig();
30
31
 
31
32
  const config: GlobalServerConfig = {
@@ -43,7 +44,7 @@ export const GET = async () => {
43
44
  mistral: { enabled: ENABLED_MISTRAL },
44
45
  moonshot: { enabled: ENABLED_MOONSHOT },
45
46
  ollama: { customModelName: OLLAMA_CUSTOM_MODELS, enabled: ENABLE_OLLAMA },
46
- openrouter: { enabled: ENABLED_OPENROUTER },
47
+ openrouter: { customModelName: OPENROUTER_CUSTOM_MODELS, enabled: ENABLED_OPENROUTER },
47
48
  perplexity: { enabled: ENABLED_PERPLEXITY },
48
49
  zeroone: { enabled: ENABLED_ZEROONE },
49
50
  zhipu: { enabled: ENABLED_ZHIPU },
@@ -45,6 +45,7 @@ declare global {
45
45
 
46
46
  // OpenRouter Provider
47
47
  OPENROUTER_API_KEY?: string;
48
+ OPENROUTER_CUSTOM_MODELS?: string;
48
49
 
49
50
  // ZeroOne Provider
50
51
  ZEROONE_API_KEY?: string;
@@ -118,6 +119,7 @@ export const getProviderConfig = () => {
118
119
 
119
120
  ENABLED_OPENROUTER: !!OPENROUTER_API_KEY,
120
121
  OPENROUTER_API_KEY,
122
+ OPENROUTER_CUSTOM_MODELS: process.env.OPENROUTER_CUSTOM_MODELS,
121
123
 
122
124
  ENABLED_MOONSHOT: !!MOONSHOT_API_KEY,
123
125
  MOONSHOT_API_KEY,
@@ -86,3 +86,145 @@ exports[`modelProviderSelectors > CUSTOM_MODELS > should work correct with gpt-4
86
86
  },
87
87
  ]
88
88
  `;
89
+
90
+ exports[`modelProviderSelectors > OPENROUTER_CUSTOM_MODELS > custom deletion, addition, and renaming of models 1`] = `
91
+ [
92
+ {
93
+ "chatModels": [
94
+ {
95
+ "description": "GPT 3.5 Turbo,适用于各种文本生成和理解任务",
96
+ "displayName": "GPT-3.5 Turbo",
97
+ "functionCall": true,
98
+ "id": "gpt-3.5-turbo",
99
+ "tokens": 16385,
100
+ },
101
+ {
102
+ "displayName": "GPT-3.5 Turbo (0125)",
103
+ "functionCall": true,
104
+ "hidden": true,
105
+ "id": "gpt-3.5-turbo-0125",
106
+ "tokens": 16385,
107
+ },
108
+ {
109
+ "displayName": "GPT-3.5 Turbo (1106)",
110
+ "functionCall": true,
111
+ "hidden": true,
112
+ "id": "gpt-3.5-turbo-1106",
113
+ "tokens": 16385,
114
+ },
115
+ {
116
+ "displayName": "GPT-3.5 Turbo Instruct",
117
+ "hidden": true,
118
+ "id": "gpt-3.5-turbo-instruct",
119
+ "tokens": 4096,
120
+ },
121
+ {
122
+ "displayName": "GPT-3.5 Turbo 16K",
123
+ "hidden": true,
124
+ "id": "gpt-3.5-turbo-16k",
125
+ "tokens": 16385,
126
+ },
127
+ {
128
+ "displayName": "GPT-3.5 Turbo (0613)",
129
+ "hidden": true,
130
+ "id": "gpt-3.5-turbo-0613",
131
+ "legacy": true,
132
+ "tokens": 4096,
133
+ },
134
+ {
135
+ "displayName": "GPT-3.5 Turbo 16K (0613)",
136
+ "hidden": true,
137
+ "id": "gpt-3.5-turbo-16k-0613",
138
+ "legacy": true,
139
+ "tokens": 4096,
140
+ },
141
+ {
142
+ "displayName": "GPT-4 Turbo Preview",
143
+ "functionCall": true,
144
+ "id": "gpt-4-turbo-preview",
145
+ "tokens": 128000,
146
+ },
147
+ {
148
+ "displayName": "GPT-4 Turbo Preview (0125)",
149
+ "functionCall": true,
150
+ "hidden": true,
151
+ "id": "gpt-4-0125-preview",
152
+ "tokens": 128000,
153
+ },
154
+ {
155
+ "description": "GPT-4 视觉预览版,支持视觉任务",
156
+ "displayName": "GPT-4 Turbo Vision Preview",
157
+ "id": "gpt-4-vision-preview",
158
+ "tokens": 128000,
159
+ "vision": true,
160
+ },
161
+ {
162
+ "displayName": "GPT-4 Turbo Preview (1106)",
163
+ "functionCall": true,
164
+ "hidden": true,
165
+ "id": "gpt-4-1106-preview",
166
+ "tokens": 128000,
167
+ },
168
+ {
169
+ "displayName": "GPT-4",
170
+ "functionCall": true,
171
+ "hidden": true,
172
+ "id": "gpt-4",
173
+ "tokens": 8192,
174
+ },
175
+ {
176
+ "displayName": "GPT-4 (0613)",
177
+ "functionCall": true,
178
+ "hidden": true,
179
+ "id": "gpt-4-0613",
180
+ "tokens": 8192,
181
+ },
182
+ {
183
+ "displayName": "GPT-4 32K",
184
+ "functionCall": true,
185
+ "hidden": true,
186
+ "id": "gpt-4-32k",
187
+ "tokens": 32768,
188
+ },
189
+ {
190
+ "displayName": "GPT-4 32K (0613)",
191
+ "functionCall": true,
192
+ "hidden": true,
193
+ "id": "gpt-4-32k-0613",
194
+ "tokens": 32768,
195
+ },
196
+ {
197
+ "displayName": "GPT-4 ALL",
198
+ "files": true,
199
+ "functionCall": true,
200
+ "hidden": true,
201
+ "id": "gpt-4-all",
202
+ "tokens": 32768,
203
+ "vision": true,
204
+ },
205
+ ],
206
+ "enabled": true,
207
+ "id": "openai",
208
+ },
209
+ {
210
+ "chatModels": [
211
+ {
212
+ "displayName": "google/gemma-7b-it",
213
+ "functionCall": true,
214
+ "id": "google/gemma-7b-it",
215
+ "isCustom": true,
216
+ "vision": true,
217
+ },
218
+ {
219
+ "displayName": "Mistral-7B-Instruct",
220
+ "functionCall": true,
221
+ "id": "mistralai/mistral-7b-instruct",
222
+ "isCustom": true,
223
+ "vision": true,
224
+ },
225
+ ],
226
+ "enabled": true,
227
+ "id": "openrouter",
228
+ },
229
+ ]
230
+ `;
@@ -131,6 +131,32 @@ describe('modelProviderSelectors', () => {
131
131
  });
132
132
  });
133
133
 
134
+ describe('OPENROUTER_CUSTOM_MODELS', () => {
135
+ it('custom deletion, addition, and renaming of models', () => {
136
+ const s = merge(initialSettingsState, {
137
+ settings: {
138
+ languageModel: {
139
+ openrouter: {
140
+ enabled: true,
141
+ },
142
+ }
143
+ },
144
+ serverConfig: {
145
+ languageModel: {
146
+ openrouter: {
147
+ apiKey: 'test-openrouter-api-key',
148
+ customModelName:
149
+ '-all,+google/gemma-7b-it,+mistralai/mistral-7b-instruct=Mistral-7B-Instruct',
150
+ },
151
+ }
152
+ },
153
+ }) as unknown as GlobalStore;
154
+
155
+ const result = modelProviderSelectors.modelSelectList(s).filter((r) => r.enabled);
156
+ expect(result).toMatchSnapshot();
157
+ });
158
+ });
159
+
134
160
  describe('modelEnabledVision', () => {
135
161
  it('should return true if the model has vision ability', () => {
136
162
  const hasAbility = modelProviderSelectors.modelEnabledVision('gpt-4-vision-preview')(
@@ -149,9 +149,15 @@ const modelSelectList = (s: GlobalStore): ModelProviderCard[] => {
149
149
 
150
150
  const ollamaChatModels = processChatModels(ollamaModelConfig, OllamaProvider.chatModels);
151
151
 
152
- const openrouterModelConfig = parseModelString(
153
- currentSettings(s).languageModel.openrouter.customModelName,
154
- )
152
+ const openrouterModelString = [
153
+ s.serverConfig.languageModel?.openrouter?.customModelName,
154
+ currentSettings(s).languageModel.openrouter.customModelName
155
+ ]
156
+ .filter(Boolean)
157
+ .join(',');
158
+
159
+ const openrouterModelConfig = parseModelString(openrouterModelString);
160
+
155
161
  const openrouterChatModels = processChatModels(openrouterModelConfig, OpenRouterProvider.chatModels);
156
162
 
157
163
  return [