@lobehub/chat 0.162.16 → 0.162.18

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.
Files changed (173) hide show
  1. package/.env.example +4 -0
  2. package/CHANGELOG.md +50 -0
  3. package/Dockerfile +3 -0
  4. package/README.md +1 -0
  5. package/README.zh-CN.md +1 -0
  6. package/docs/self-hosting/advanced/settings-url-share.mdx +89 -57
  7. package/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx +87 -56
  8. package/docs/self-hosting/advanced/upstream-sync.mdx +1 -1
  9. package/docs/self-hosting/environment-variables/model-provider.mdx +10 -1
  10. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +9 -0
  11. package/docs/usage/features/multi-ai-providers.mdx +1 -0
  12. package/docs/usage/features/multi-ai-providers.zh-CN.mdx +1 -0
  13. package/locales/ar/error.json +7 -37
  14. package/locales/ar/modelProvider.json +15 -171
  15. package/locales/ar/setting.json +5 -8
  16. package/locales/bg-BG/error.json +6 -36
  17. package/locales/bg-BG/modelProvider.json +15 -171
  18. package/locales/bg-BG/setting.json +5 -8
  19. package/locales/de-DE/error.json +6 -36
  20. package/locales/de-DE/modelProvider.json +15 -171
  21. package/locales/de-DE/setting.json +5 -8
  22. package/locales/en-US/error.json +6 -36
  23. package/locales/en-US/modelProvider.json +15 -171
  24. package/locales/en-US/setting.json +6 -9
  25. package/locales/es-ES/error.json +6 -36
  26. package/locales/es-ES/modelProvider.json +15 -171
  27. package/locales/es-ES/setting.json +5 -8
  28. package/locales/fr-FR/error.json +6 -36
  29. package/locales/fr-FR/modelProvider.json +15 -171
  30. package/locales/fr-FR/setting.json +9 -12
  31. package/locales/it-IT/error.json +6 -36
  32. package/locales/it-IT/modelProvider.json +15 -171
  33. package/locales/it-IT/setting.json +5 -8
  34. package/locales/ja-JP/error.json +6 -36
  35. package/locales/ja-JP/modelProvider.json +15 -171
  36. package/locales/ja-JP/setting.json +5 -8
  37. package/locales/ko-KR/error.json +6 -36
  38. package/locales/ko-KR/modelProvider.json +15 -171
  39. package/locales/ko-KR/setting.json +5 -8
  40. package/locales/nl-NL/error.json +6 -36
  41. package/locales/nl-NL/modelProvider.json +15 -171
  42. package/locales/nl-NL/setting.json +5 -8
  43. package/locales/pl-PL/error.json +6 -36
  44. package/locales/pl-PL/modelProvider.json +15 -171
  45. package/locales/pl-PL/setting.json +6 -9
  46. package/locales/pt-BR/error.json +6 -36
  47. package/locales/pt-BR/modelProvider.json +15 -171
  48. package/locales/pt-BR/setting.json +5 -8
  49. package/locales/ru-RU/error.json +6 -36
  50. package/locales/ru-RU/modelProvider.json +15 -171
  51. package/locales/ru-RU/setting.json +5 -8
  52. package/locales/tr-TR/error.json +6 -36
  53. package/locales/tr-TR/modelProvider.json +15 -171
  54. package/locales/tr-TR/setting.json +5 -8
  55. package/locales/vi-VN/error.json +6 -36
  56. package/locales/vi-VN/modelProvider.json +15 -171
  57. package/locales/vi-VN/setting.json +5 -8
  58. package/locales/zh-CN/error.json +7 -37
  59. package/locales/zh-CN/modelProvider.json +15 -171
  60. package/locales/zh-CN/setting.json +5 -8
  61. package/locales/zh-TW/error.json +7 -37
  62. package/locales/zh-TW/modelProvider.json +15 -171
  63. package/locales/zh-TW/setting.json +5 -8
  64. package/package.json +1 -2
  65. package/src/app/(main)/settings/llm/ProviderList/Azure/index.tsx +107 -0
  66. package/src/app/(main)/settings/llm/ProviderList/Bedrock/index.tsx +68 -0
  67. package/src/app/(main)/settings/llm/ProviderList/Ollama/index.tsx +29 -0
  68. package/src/app/(main)/settings/llm/ProviderList/OpenAI/index.tsx +20 -0
  69. package/src/app/(main)/settings/llm/ProviderList/providers.tsx +141 -0
  70. package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +18 -27
  71. package/src/app/(main)/settings/llm/index.tsx +7 -34
  72. package/src/app/(main)/settings/llm/type.ts +5 -0
  73. package/src/app/api/chat/[provider]/route.ts +8 -3
  74. package/src/app/api/chat/agentRuntime.test.ts +17 -0
  75. package/src/app/api/chat/agentRuntime.ts +7 -0
  76. package/src/app/api/errorResponse.test.ts +7 -89
  77. package/src/app/api/errorResponse.ts +6 -43
  78. package/src/app/api/middleware/auth/index.ts +7 -3
  79. package/src/components/ModelProviderIcon/index.tsx +5 -0
  80. package/src/components/ModelSelect/index.tsx +7 -10
  81. package/src/config/llm.ts +6 -0
  82. package/src/config/modelProviders/anthropic.ts +5 -0
  83. package/src/config/modelProviders/azure.ts +2 -0
  84. package/src/config/modelProviders/bedrock.ts +2 -0
  85. package/src/config/modelProviders/deepseek.ts +4 -1
  86. package/src/config/modelProviders/google.ts +5 -0
  87. package/src/config/modelProviders/groq.ts +5 -0
  88. package/src/config/modelProviders/index.ts +4 -0
  89. package/src/config/modelProviders/minimax.ts +2 -0
  90. package/src/config/modelProviders/mistral.ts +2 -0
  91. package/src/config/modelProviders/moonshot.ts +2 -0
  92. package/src/config/modelProviders/ollama.ts +4 -0
  93. package/src/config/modelProviders/openai.ts +3 -0
  94. package/src/config/modelProviders/openrouter.ts +3 -0
  95. package/src/config/modelProviders/perplexity.ts +5 -0
  96. package/src/config/modelProviders/qwen.ts +35 -0
  97. package/src/config/modelProviders/togetherai.ts +3 -0
  98. package/src/config/modelProviders/zeroone.ts +4 -2
  99. package/src/config/modelProviders/zhipu.ts +2 -0
  100. package/src/const/settings/llm.ts +5 -0
  101. package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +6 -3
  102. package/src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx +5 -0
  103. package/src/features/Conversation/Error/APIKeyForm/index.tsx +4 -0
  104. package/src/features/Conversation/Error/OllamaBizError/InvalidOllamaModel/index.tsx +11 -14
  105. package/src/features/Conversation/Error/index.tsx +29 -19
  106. package/src/features/Conversation/components/ChatItem/index.tsx +4 -13
  107. package/src/features/ModelSelect/index.tsx +1 -1
  108. package/src/features/ModelSwitchPanel/index.tsx +1 -1
  109. package/src/hooks/useProviderName.ts +8 -0
  110. package/src/libs/agent-runtime/AgentRuntime.ts +8 -1
  111. package/src/libs/agent-runtime/anthropic/index.test.ts +8 -5
  112. package/src/libs/agent-runtime/anthropic/index.ts +3 -3
  113. package/src/libs/agent-runtime/azureOpenai/index.test.ts +5 -2
  114. package/src/libs/agent-runtime/azureOpenai/index.ts +2 -2
  115. package/src/libs/agent-runtime/bedrock/index.test.ts +2 -2
  116. package/src/libs/agent-runtime/bedrock/index.ts +2 -2
  117. package/src/libs/agent-runtime/deepseek/index.test.ts +3 -2
  118. package/src/libs/agent-runtime/deepseek/index.ts +0 -5
  119. package/src/libs/agent-runtime/error.ts +11 -43
  120. package/src/libs/agent-runtime/google/index.test.ts +3 -4
  121. package/src/libs/agent-runtime/google/index.ts +4 -4
  122. package/src/libs/agent-runtime/groq/index.test.ts +3 -2
  123. package/src/libs/agent-runtime/groq/index.ts +0 -4
  124. package/src/libs/agent-runtime/index.ts +1 -0
  125. package/src/libs/agent-runtime/minimax/index.test.ts +3 -2
  126. package/src/libs/agent-runtime/minimax/index.ts +5 -5
  127. package/src/libs/agent-runtime/mistral/index.test.ts +2 -2
  128. package/src/libs/agent-runtime/mistral/index.ts +0 -5
  129. package/src/libs/agent-runtime/moonshot/index.test.ts +3 -2
  130. package/src/libs/agent-runtime/moonshot/index.ts +0 -5
  131. package/src/libs/agent-runtime/openrouter/index.test.ts +3 -2
  132. package/src/libs/agent-runtime/openrouter/index.ts +0 -6
  133. package/src/libs/agent-runtime/perplexity/index.test.ts +2 -2
  134. package/src/libs/agent-runtime/perplexity/index.ts +0 -5
  135. package/src/libs/agent-runtime/qwen/index.test.ts +251 -0
  136. package/src/libs/agent-runtime/qwen/index.ts +28 -0
  137. package/src/libs/agent-runtime/togetherai/index.test.ts +3 -2
  138. package/src/libs/agent-runtime/togetherai/index.ts +0 -5
  139. package/src/libs/agent-runtime/types/type.ts +1 -1
  140. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.test.ts +123 -6
  141. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +12 -6
  142. package/src/libs/agent-runtime/utils/streams/openai.ts +1 -1
  143. package/src/libs/agent-runtime/zeroone/index.test.ts +3 -2
  144. package/src/libs/agent-runtime/zeroone/index.ts +1 -5
  145. package/src/libs/agent-runtime/zhipu/index.test.ts +8 -5
  146. package/src/libs/agent-runtime/zhipu/index.ts +2 -2
  147. package/src/locales/default/error.ts +10 -51
  148. package/src/locales/default/modelProvider.ts +12 -169
  149. package/src/locales/default/setting.ts +5 -8
  150. package/src/server/globalConfig/index.ts +2 -0
  151. package/src/services/__tests__/chat.test.ts +16 -0
  152. package/src/services/chat.ts +3 -0
  153. package/src/services/message/client.test.ts +4 -1
  154. package/src/types/fetch.ts +3 -1
  155. package/src/types/llm.ts +22 -0
  156. package/src/types/user/settings/keyVaults.ts +1 -0
  157. package/src/app/(main)/settings/llm/Anthropic/index.tsx +0 -25
  158. package/src/app/(main)/settings/llm/Azure/index.tsx +0 -110
  159. package/src/app/(main)/settings/llm/Bedrock/index.tsx +0 -74
  160. package/src/app/(main)/settings/llm/DeepSeek/index.tsx +0 -21
  161. package/src/app/(main)/settings/llm/Google/index.tsx +0 -31
  162. package/src/app/(main)/settings/llm/Groq/index.tsx +0 -26
  163. package/src/app/(main)/settings/llm/Minimax/index.tsx +0 -20
  164. package/src/app/(main)/settings/llm/Mistral/index.tsx +0 -20
  165. package/src/app/(main)/settings/llm/Moonshot/index.tsx +0 -28
  166. package/src/app/(main)/settings/llm/Ollama/index.tsx +0 -37
  167. package/src/app/(main)/settings/llm/OpenAI/index.tsx +0 -28
  168. package/src/app/(main)/settings/llm/OpenRouter/index.tsx +0 -21
  169. package/src/app/(main)/settings/llm/Perplexity/index.tsx +0 -23
  170. package/src/app/(main)/settings/llm/TogetherAI/index.tsx +0 -19
  171. package/src/app/(main)/settings/llm/ZeroOne/index.tsx +0 -20
  172. package/src/app/(main)/settings/llm/Zhipu/index.tsx +0 -18
  173. /package/src/app/(main)/settings/llm/{Ollama → ProviderList/Ollama}/Checker.tsx +0 -0
@@ -9,6 +9,9 @@ import { LobeAnthropicAI } from './index';
9
9
 
10
10
  const provider = 'anthropic';
11
11
 
12
+ const bizErrorType = 'ProviderBizError';
13
+ const invalidErrorType = 'InvalidProviderAPIKey';
14
+
12
15
  // Mock the console.error to avoid polluting test output
13
16
  vi.spyOn(console, 'error').mockImplementation(() => {});
14
17
 
@@ -315,7 +318,7 @@ describe('LobeAnthropicAI', () => {
315
318
  expect(e).toEqual({
316
319
  endpoint: 'https://api.anthropic.com',
317
320
  error: apiError,
318
- errorType: 'InvalidAnthropicAPIKey',
321
+ errorType: invalidErrorType,
319
322
  provider,
320
323
  });
321
324
  }
@@ -346,7 +349,7 @@ describe('LobeAnthropicAI', () => {
346
349
  expect(e).toEqual({
347
350
  endpoint: 'https://api.anthropic.com',
348
351
  error: apiError,
349
- errorType: 'AnthropicBizError',
352
+ errorType: bizErrorType,
350
353
  provider,
351
354
  });
352
355
  }
@@ -356,7 +359,7 @@ describe('LobeAnthropicAI', () => {
356
359
  try {
357
360
  new LobeAnthropicAI({});
358
361
  } catch (e) {
359
- expect(e).toEqual({ errorType: 'InvalidAnthropicAPIKey' });
362
+ expect(e).toEqual({ errorType: invalidErrorType });
360
363
  }
361
364
  });
362
365
  });
@@ -397,7 +400,7 @@ describe('LobeAnthropicAI', () => {
397
400
  ).rejects.toEqual({
398
401
  endpoint: 'https://api.anthropic.com',
399
402
  error: apiError,
400
- errorType: 'AnthropicBizError',
403
+ errorType: bizErrorType,
401
404
  provider,
402
405
  });
403
406
  });
@@ -421,7 +424,7 @@ describe('LobeAnthropicAI', () => {
421
424
  ).rejects.toEqual({
422
425
  endpoint: 'https://api.cu****om.com/v1',
423
426
  error: apiError,
424
- errorType: 'InvalidAnthropicAPIKey',
427
+ errorType: invalidErrorType,
425
428
  provider,
426
429
  });
427
430
  });
@@ -21,7 +21,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
21
21
  baseURL: string;
22
22
 
23
23
  constructor({ apiKey, baseURL = DEFAULT_BASE_URL }: ClientOptions) {
24
- if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidAnthropicAPIKey);
24
+ if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);
25
25
 
26
26
  this.client = new Anthropic({ apiKey, baseURL });
27
27
  this.baseURL = this.client.baseURL;
@@ -80,7 +80,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
80
80
  throw AgentRuntimeError.chat({
81
81
  endpoint: desensitizedEndpoint,
82
82
  error: error as any,
83
- errorType: AgentRuntimeErrorType.InvalidAnthropicAPIKey,
83
+ errorType: AgentRuntimeErrorType.InvalidProviderAPIKey,
84
84
  provider: ModelProvider.Anthropic,
85
85
  });
86
86
  }
@@ -101,7 +101,7 @@ export class LobeAnthropicAI implements LobeRuntimeAI {
101
101
  throw AgentRuntimeError.chat({
102
102
  endpoint: desensitizedEndpoint,
103
103
  error: error as any,
104
- errorType: AgentRuntimeErrorType.AnthropicBizError,
104
+ errorType: AgentRuntimeErrorType.ProviderBizError,
105
105
  provider: ModelProvider.Anthropic,
106
106
  });
107
107
  }
@@ -6,6 +6,9 @@ import { Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
6
  import * as debugStreamModule from '../utils/debugStream';
7
7
  import { LobeAzureOpenAI } from './index';
8
8
 
9
+ const bizErrorType = 'ProviderBizError';
10
+ const invalidErrorType = 'InvalidProviderAPIKey';
11
+
9
12
  // Mock the console.error to avoid polluting test output
10
13
  vi.spyOn(console, 'error').mockImplementation(() => {});
11
14
 
@@ -34,7 +37,7 @@ describe('LobeAzureOpenAI', () => {
34
37
  try {
35
38
  new LobeAzureOpenAI();
36
39
  } catch (e) {
37
- expect(e).toEqual({ errorType: 'InvalidAzureAPIKey' });
40
+ expect(e).toEqual({ errorType: invalidErrorType });
38
41
  }
39
42
  });
40
43
 
@@ -229,7 +232,7 @@ describe('LobeAzureOpenAI', () => {
229
232
  message: 'Deployment not found',
230
233
  deployId: 'text-davinci-003',
231
234
  },
232
- errorType: 'AzureBizError',
235
+ errorType: bizErrorType,
233
236
  provider: 'azure',
234
237
  });
235
238
  }
@@ -18,7 +18,7 @@ export class LobeAzureOpenAI implements LobeRuntimeAI {
18
18
 
19
19
  constructor(endpoint?: string, apikey?: string, apiVersion?: string) {
20
20
  if (!apikey || !endpoint)
21
- throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidAzureAPIKey);
21
+ throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);
22
22
 
23
23
  this.client = new OpenAIClient(endpoint, new AzureKeyCredential(apikey), { apiVersion });
24
24
 
@@ -68,7 +68,7 @@ export class LobeAzureOpenAI implements LobeRuntimeAI {
68
68
  }
69
69
 
70
70
  const errorType = error.code
71
- ? AgentRuntimeErrorType.AzureBizError
71
+ ? AgentRuntimeErrorType.ProviderBizError
72
72
  : AgentRuntimeErrorType.AgentRuntimeError;
73
73
 
74
74
  throw AgentRuntimeError.chat({
@@ -281,7 +281,7 @@ describe('LobeBedrockAI', () => {
281
281
  message: errorMessage,
282
282
  type: 'Error',
283
283
  },
284
- errorType: AgentRuntimeErrorType.BedrockBizError,
284
+ errorType: AgentRuntimeErrorType.ProviderBizError,
285
285
  provider: ModelProvider.Bedrock,
286
286
  region: 'us-west-2',
287
287
  }),
@@ -346,7 +346,7 @@ describe('LobeBedrockAI', () => {
346
346
  region: 'us-west-2',
347
347
  type: 'Error',
348
348
  },
349
- errorType: AgentRuntimeErrorType.BedrockBizError,
349
+ errorType: AgentRuntimeErrorType.ProviderBizError,
350
350
  provider: ModelProvider.Bedrock,
351
351
  region: 'us-west-2',
352
352
  }),
@@ -96,7 +96,7 @@ export class LobeBedrockAI implements LobeRuntimeAI {
96
96
  message: err.message,
97
97
  type: err.name,
98
98
  },
99
- errorType: AgentRuntimeErrorType.BedrockBizError,
99
+ errorType: AgentRuntimeErrorType.ProviderBizError,
100
100
  provider: ModelProvider.Bedrock,
101
101
  region: this.region,
102
102
  });
@@ -143,7 +143,7 @@ export class LobeBedrockAI implements LobeRuntimeAI {
143
143
  region: this.region,
144
144
  type: err.name,
145
145
  },
146
- errorType: AgentRuntimeErrorType.BedrockBizError,
146
+ errorType: AgentRuntimeErrorType.ProviderBizError,
147
147
  provider: ModelProvider.Bedrock,
148
148
  region: this.region,
149
149
  });
@@ -13,8 +13,9 @@ import { LobeDeepSeekAI } from './index';
13
13
 
14
14
  const provider = ModelProvider.DeepSeek;
15
15
  const defaultBaseURL = 'https://api.deepseek.com/v1';
16
- const bizErrorType = 'DeepSeekBizError';
17
- const invalidErrorType = 'InvalidDeepSeekAPIKey';
16
+
17
+ const bizErrorType = 'ProviderBizError';
18
+ const invalidErrorType = 'InvalidProviderAPIKey';
18
19
 
19
20
  // Mock the console.error to avoid polluting test output
20
21
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -1,4 +1,3 @@
1
- import { AgentRuntimeErrorType } from '../error';
2
1
  import { ModelProvider } from '../types';
3
2
  import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
4
3
 
@@ -7,9 +6,5 @@ export const LobeDeepSeekAI = LobeOpenAICompatibleFactory({
7
6
  debug: {
8
7
  chatCompletion: () => process.env.DEBUG_DEEPSEEK_CHAT_COMPLETION === '1',
9
8
  },
10
- errorType: {
11
- bizError: AgentRuntimeErrorType.DeepSeekBizError,
12
- invalidAPIKey: AgentRuntimeErrorType.InvalidDeepSeekAPIKey,
13
- },
14
9
  provider: ModelProvider.DeepSeek,
15
10
  });
@@ -4,54 +4,22 @@ export const AgentRuntimeErrorType = {
4
4
  AgentRuntimeError: 'AgentRuntimeError', // Agent Runtime 模块运行时错误
5
5
  LocationNotSupportError: 'LocationNotSupportError',
6
6
 
7
- OpenAIBizError: 'OpenAIBizError',
8
-
9
- NoOpenAIAPIKey: 'NoOpenAIAPIKey',
10
-
11
- InvalidAzureAPIKey: 'InvalidAzureAPIKey',
12
- AzureBizError: 'AzureBizError',
13
-
14
- InvalidZhipuAPIKey: 'InvalidZhipuAPIKey',
15
- ZhipuBizError: 'ZhipuBizError',
16
-
17
- InvalidGoogleAPIKey: 'InvalidGoogleAPIKey',
18
- GoogleBizError: 'GoogleBizError',
19
-
20
- InvalidBedrockCredentials: 'InvalidBedrockCredentials',
21
- BedrockBizError: 'BedrockBizError',
22
-
23
- InvalidMistralAPIKey: 'InvalidMistralAPIKey',
24
- MistralBizError: 'MistralBizError',
25
-
26
- InvalidMoonshotAPIKey: 'InvalidMoonshotAPIKey',
27
- MoonshotBizError: 'MoonshotBizError',
7
+ InvalidProviderAPIKey: 'InvalidProviderAPIKey',
8
+ ProviderBizError: 'ProviderBizError',
28
9
 
29
10
  InvalidOllamaArgs: 'InvalidOllamaArgs',
30
11
  OllamaBizError: 'OllamaBizError',
31
12
 
32
- InvalidPerplexityAPIKey: 'InvalidPerplexityAPIKey',
33
- PerplexityBizError: 'PerplexityBizError',
34
-
35
- InvalidAnthropicAPIKey: 'InvalidAnthropicAPIKey',
36
- AnthropicBizError: 'AnthropicBizError',
37
-
38
- InvalidGroqAPIKey: 'InvalidGroqAPIKey',
39
- GroqBizError: 'GroqBizError',
40
-
41
- InvalidZeroOneAPIKey: 'InvalidZeroOneAPIKey',
42
- ZeroOneBizError: 'ZeroOneBizError',
43
-
44
- InvalidOpenRouterAPIKey: 'InvalidOpenRouterAPIKey',
45
- OpenRouterBizError: 'OpenRouterBizError',
46
-
47
- InvalidTogetherAIAPIKey: 'InvalidTogetherAIAPIKey',
48
- TogetherAIBizError: 'TogetherAIBizError',
49
-
50
- InvalidMinimaxAPIKey: 'InvalidMinimaxAPIKey',
51
- MinimaxBizError: 'MinimaxBizError',
13
+ InvalidBedrockCredentials: 'InvalidBedrockCredentials',
52
14
 
53
- InvalidDeepSeekAPIKey: 'InvalidDeepSeekAPIKey',
54
- DeepSeekBizError: 'DeepSeekBizError',
15
+ /**
16
+ * @deprecated
17
+ */
18
+ NoOpenAIAPIKey: 'NoOpenAIAPIKey',
19
+ /**
20
+ * @deprecated
21
+ */
22
+ OpenAIBizError: 'OpenAIBizError',
55
23
  } as const;
56
24
 
57
25
  export type ILobeAgentRuntimeErrorType =
@@ -10,9 +10,8 @@ import * as debugStreamModule from '../utils/debugStream';
10
10
  import { LobeGoogleAI } from './index';
11
11
 
12
12
  const provider = 'google';
13
- const defaultBaseURL = 'https://api.moonshot.cn/v1';
14
- const bizErrorType = 'GoogleBizError';
15
- const invalidErrorType = 'InvalidGoogleAPIKey';
13
+ const bizErrorType = 'ProviderBizError';
14
+ const invalidErrorType = 'InvalidProviderAPIKey';
16
15
 
17
16
  // Mock the console.error to avoid polluting test output
18
17
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -291,7 +290,7 @@ describe('LobeGoogleAI', () => {
291
290
  });
292
291
  } catch (e) {
293
292
  expect(e).toEqual({
294
- errorType: 'GoogleBizError',
293
+ errorType: bizErrorType,
295
294
  provider,
296
295
  error: {
297
296
  message: 'Generic Error',
@@ -42,7 +42,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
42
42
  baseURL?: string;
43
43
 
44
44
  constructor({ apiKey, baseURL }: { apiKey?: string; baseURL?: string }) {
45
- if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidGoogleAPIKey);
45
+ if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);
46
46
 
47
47
  this.client = new GoogleGenerativeAI(apiKey);
48
48
  this.baseURL = baseURL;
@@ -218,7 +218,7 @@ export class LobeGoogleAI implements LobeRuntimeAI {
218
218
  } {
219
219
  const defaultError = {
220
220
  error: { message },
221
- errorType: AgentRuntimeErrorType.GoogleBizError,
221
+ errorType: AgentRuntimeErrorType.ProviderBizError,
222
222
  };
223
223
 
224
224
  if (message.includes('location is not supported'))
@@ -240,11 +240,11 @@ export class LobeGoogleAI implements LobeRuntimeAI {
240
240
 
241
241
  switch (bizError.reason) {
242
242
  case 'API_KEY_INVALID': {
243
- return { ...defaultError, errorType: AgentRuntimeErrorType.InvalidGoogleAPIKey };
243
+ return { ...defaultError, errorType: AgentRuntimeErrorType.InvalidProviderAPIKey };
244
244
  }
245
245
 
246
246
  default: {
247
- return { error: json, errorType: AgentRuntimeErrorType.GoogleBizError };
247
+ return { error: json, errorType: AgentRuntimeErrorType.ProviderBizError };
248
248
  }
249
249
  }
250
250
  } catch {
@@ -9,8 +9,9 @@ import { LobeGroq } from './index';
9
9
 
10
10
  const provider = 'groq';
11
11
  const defaultBaseURL = 'https://api.groq.com/openai/v1';
12
- const bizErrorType = 'GroqBizError';
13
- const invalidErrorType = 'InvalidGroqAPIKey';
12
+
13
+ const bizErrorType = 'ProviderBizError';
14
+ const invalidErrorType = 'InvalidProviderAPIKey';
14
15
 
15
16
  // Mock the console.error to avoid polluting test output
16
17
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -21,9 +21,5 @@ export const LobeGroq = LobeOpenAICompatibleFactory({
21
21
  debug: {
22
22
  chatCompletion: () => process.env.DEBUG_GROQ_CHAT_COMPLETION === '1',
23
23
  },
24
- errorType: {
25
- bizError: AgentRuntimeErrorType.GroqBizError,
26
- invalidAPIKey: AgentRuntimeErrorType.InvalidGroqAPIKey,
27
- },
28
24
  provider: ModelProvider.Groq,
29
25
  });
@@ -14,6 +14,7 @@ export { LobeOllamaAI } from './ollama';
14
14
  export { LobeOpenAI } from './openai';
15
15
  export { LobeOpenRouterAI } from './openrouter';
16
16
  export { LobePerplexityAI } from './perplexity';
17
+ export { LobeQwenAI } from './qwen';
17
18
  export { LobeTogetherAI } from './togetherai';
18
19
  export * from './types';
19
20
  export { AgentRuntimeError } from './utils/createError';
@@ -7,8 +7,9 @@ import * as debugStreamModule from '@/libs/agent-runtime/utils/debugStream';
7
7
  import { LobeMinimaxAI } from './index';
8
8
 
9
9
  const provider = ModelProvider.Minimax;
10
- const bizErrorType = 'MinimaxBizError';
11
- const invalidErrorType = 'InvalidMinimaxAPIKey';
10
+ const bizErrorType = 'ProviderBizError';
11
+ const invalidErrorType = 'InvalidProviderAPIKey';
12
+
12
13
  const encoder = new TextEncoder();
13
14
 
14
15
  // Mock the console.error to avoid polluting test output
@@ -35,7 +35,7 @@ function throwIfErrorResponse(data: MinimaxResponse) {
35
35
  code: data.base_resp.status_code,
36
36
  message: data.base_resp.status_msg,
37
37
  },
38
- errorType: AgentRuntimeErrorType.InvalidMinimaxAPIKey,
38
+ errorType: AgentRuntimeErrorType.InvalidProviderAPIKey,
39
39
  provider: ModelProvider.Minimax,
40
40
  });
41
41
  }
@@ -44,7 +44,7 @@ function throwIfErrorResponse(data: MinimaxResponse) {
44
44
  code: data.base_resp.status_code,
45
45
  message: data.base_resp.status_msg,
46
46
  },
47
- errorType: AgentRuntimeErrorType.MinimaxBizError,
47
+ errorType: AgentRuntimeErrorType.ProviderBizError,
48
48
  provider: ModelProvider.Minimax,
49
49
  });
50
50
  }
@@ -64,7 +64,7 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
64
64
  apiKey: string;
65
65
 
66
66
  constructor({ apiKey }: { apiKey?: string }) {
67
- if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidMinimaxAPIKey);
67
+ if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);
68
68
 
69
69
  this.apiKey = apiKey;
70
70
  }
@@ -85,7 +85,7 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
85
85
  status: response.status,
86
86
  statusText: response.statusText,
87
87
  },
88
- errorType: AgentRuntimeErrorType.MinimaxBizError,
88
+ errorType: AgentRuntimeErrorType.ProviderBizError,
89
89
  provider: ModelProvider.Minimax,
90
90
  });
91
91
  }
@@ -115,7 +115,7 @@ export class LobeMinimaxAI implements LobeRuntimeAI {
115
115
  };
116
116
  throw AgentRuntimeError.chat({
117
117
  error: errorResult,
118
- errorType: AgentRuntimeErrorType.MinimaxBizError,
118
+ errorType: AgentRuntimeErrorType.ProviderBizError,
119
119
  provider: ModelProvider.Minimax,
120
120
  });
121
121
  }
@@ -9,8 +9,8 @@ import { LobeMistralAI } from './index';
9
9
 
10
10
  const provider = 'mistral';
11
11
  const defaultBaseURL = 'https://api.mistral.ai/v1';
12
- const bizErrorType = 'MistralBizError';
13
- const invalidErrorType = 'InvalidMistralAPIKey';
12
+ const bizErrorType = 'ProviderBizError';
13
+ const invalidErrorType = 'InvalidProviderAPIKey';
14
14
 
15
15
  // Mock the console.error to avoid polluting test output
16
16
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -1,4 +1,3 @@
1
- import { AgentRuntimeErrorType } from '../error';
2
1
  import { ModelProvider } from '../types';
3
2
  import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
4
3
 
@@ -18,9 +17,5 @@ export const LobeMistralAI = LobeOpenAICompatibleFactory({
18
17
  debug: {
19
18
  chatCompletion: () => process.env.DEBUG_MISTRAL_CHAT_COMPLETION === '1',
20
19
  },
21
- errorType: {
22
- bizError: AgentRuntimeErrorType.MistralBizError,
23
- invalidAPIKey: AgentRuntimeErrorType.InvalidMistralAPIKey,
24
- },
25
20
  provider: ModelProvider.Mistral,
26
21
  });
@@ -9,8 +9,9 @@ import { LobeMoonshotAI } from './index';
9
9
 
10
10
  const provider = 'moonshot';
11
11
  const defaultBaseURL = 'https://api.moonshot.cn/v1';
12
- const bizErrorType = 'MoonshotBizError';
13
- const invalidErrorType = 'InvalidMoonshotAPIKey';
12
+
13
+ const bizErrorType = 'ProviderBizError';
14
+ const invalidErrorType = 'InvalidProviderAPIKey';
14
15
 
15
16
  // Mock the console.error to avoid polluting test output
16
17
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -1,4 +1,3 @@
1
- import { AgentRuntimeErrorType } from '../error';
2
1
  import { ModelProvider } from '../types';
3
2
  import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
4
3
 
@@ -7,9 +6,5 @@ export const LobeMoonshotAI = LobeOpenAICompatibleFactory({
7
6
  debug: {
8
7
  chatCompletion: () => process.env.DEBUG_MOONSHOT_CHAT_COMPLETION === '1',
9
8
  },
10
- errorType: {
11
- bizError: AgentRuntimeErrorType.MoonshotBizError,
12
- invalidAPIKey: AgentRuntimeErrorType.InvalidMoonshotAPIKey,
13
- },
14
9
  provider: ModelProvider.Moonshot,
15
10
  });
@@ -10,8 +10,9 @@ import { LobeOpenRouterAI } from './index';
10
10
 
11
11
  const provider = 'openrouter';
12
12
  const defaultBaseURL = 'https://openrouter.ai/api/v1';
13
- const bizErrorType = 'OpenRouterBizError';
14
- const invalidErrorType = 'InvalidOpenRouterAPIKey';
13
+
14
+ const bizErrorType = 'ProviderBizError';
15
+ const invalidErrorType = 'InvalidProviderAPIKey';
15
16
 
16
17
  // Mock the console.error to avoid polluting test output
17
18
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -1,6 +1,5 @@
1
1
  import { LOBE_DEFAULT_MODEL_LIST } from '@/config/modelProviders';
2
2
 
3
- import { AgentRuntimeErrorType } from '../error';
4
3
  import { ModelProvider } from '../types';
5
4
  import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
6
5
  import { OpenRouterModelCard } from './type';
@@ -16,11 +15,6 @@ export const LobeOpenRouterAI = LobeOpenAICompatibleFactory({
16
15
  debug: {
17
16
  chatCompletion: () => process.env.DEBUG_OPENROUTER_CHAT_COMPLETION === '1',
18
17
  },
19
-
20
- errorType: {
21
- bizError: AgentRuntimeErrorType.OpenRouterBizError,
22
- invalidAPIKey: AgentRuntimeErrorType.InvalidOpenRouterAPIKey,
23
- },
24
18
  models: {
25
19
  transformModel: (m) => {
26
20
  const model = m as unknown as OpenRouterModelCard;
@@ -9,8 +9,8 @@ import { LobePerplexityAI } from './index';
9
9
 
10
10
  const provider = 'perplexity';
11
11
  const defaultBaseURL = 'https://api.perplexity.ai';
12
- const bizErrorType = 'PerplexityBizError';
13
- const invalidErrorType = 'InvalidPerplexityAPIKey';
12
+ const bizErrorType = 'ProviderBizError';
13
+ const invalidErrorType = 'InvalidProviderAPIKey';
14
14
 
15
15
  // Mock the console.error to avoid polluting test output
16
16
  vi.spyOn(console, 'error').mockImplementation(() => {});
@@ -1,6 +1,5 @@
1
1
  import OpenAI from 'openai';
2
2
 
3
- import { AgentRuntimeErrorType } from '../error';
4
3
  import { ChatStreamPayload, ModelProvider } from '../types';
5
4
  import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
6
5
 
@@ -28,9 +27,5 @@ export const LobePerplexityAI = LobeOpenAICompatibleFactory({
28
27
  debug: {
29
28
  chatCompletion: () => process.env.DEBUG_PERPLEXITY_CHAT_COMPLETION === '1',
30
29
  },
31
- errorType: {
32
- bizError: AgentRuntimeErrorType.PerplexityBizError,
33
- invalidAPIKey: AgentRuntimeErrorType.InvalidPerplexityAPIKey,
34
- },
35
30
  provider: ModelProvider.Perplexity,
36
31
  });