@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.
- package/.env.example +4 -0
- package/CHANGELOG.md +50 -0
- package/Dockerfile +3 -0
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/docs/self-hosting/advanced/settings-url-share.mdx +89 -57
- package/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx +87 -56
- package/docs/self-hosting/advanced/upstream-sync.mdx +1 -1
- package/docs/self-hosting/environment-variables/model-provider.mdx +10 -1
- package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +9 -0
- package/docs/usage/features/multi-ai-providers.mdx +1 -0
- package/docs/usage/features/multi-ai-providers.zh-CN.mdx +1 -0
- package/locales/ar/error.json +7 -37
- package/locales/ar/modelProvider.json +15 -171
- package/locales/ar/setting.json +5 -8
- package/locales/bg-BG/error.json +6 -36
- package/locales/bg-BG/modelProvider.json +15 -171
- package/locales/bg-BG/setting.json +5 -8
- package/locales/de-DE/error.json +6 -36
- package/locales/de-DE/modelProvider.json +15 -171
- package/locales/de-DE/setting.json +5 -8
- package/locales/en-US/error.json +6 -36
- package/locales/en-US/modelProvider.json +15 -171
- package/locales/en-US/setting.json +6 -9
- package/locales/es-ES/error.json +6 -36
- package/locales/es-ES/modelProvider.json +15 -171
- package/locales/es-ES/setting.json +5 -8
- package/locales/fr-FR/error.json +6 -36
- package/locales/fr-FR/modelProvider.json +15 -171
- package/locales/fr-FR/setting.json +9 -12
- package/locales/it-IT/error.json +6 -36
- package/locales/it-IT/modelProvider.json +15 -171
- package/locales/it-IT/setting.json +5 -8
- package/locales/ja-JP/error.json +6 -36
- package/locales/ja-JP/modelProvider.json +15 -171
- package/locales/ja-JP/setting.json +5 -8
- package/locales/ko-KR/error.json +6 -36
- package/locales/ko-KR/modelProvider.json +15 -171
- package/locales/ko-KR/setting.json +5 -8
- package/locales/nl-NL/error.json +6 -36
- package/locales/nl-NL/modelProvider.json +15 -171
- package/locales/nl-NL/setting.json +5 -8
- package/locales/pl-PL/error.json +6 -36
- package/locales/pl-PL/modelProvider.json +15 -171
- package/locales/pl-PL/setting.json +6 -9
- package/locales/pt-BR/error.json +6 -36
- package/locales/pt-BR/modelProvider.json +15 -171
- package/locales/pt-BR/setting.json +5 -8
- package/locales/ru-RU/error.json +6 -36
- package/locales/ru-RU/modelProvider.json +15 -171
- package/locales/ru-RU/setting.json +5 -8
- package/locales/tr-TR/error.json +6 -36
- package/locales/tr-TR/modelProvider.json +15 -171
- package/locales/tr-TR/setting.json +5 -8
- package/locales/vi-VN/error.json +6 -36
- package/locales/vi-VN/modelProvider.json +15 -171
- package/locales/vi-VN/setting.json +5 -8
- package/locales/zh-CN/error.json +7 -37
- package/locales/zh-CN/modelProvider.json +15 -171
- package/locales/zh-CN/setting.json +5 -8
- package/locales/zh-TW/error.json +7 -37
- package/locales/zh-TW/modelProvider.json +15 -171
- package/locales/zh-TW/setting.json +5 -8
- package/package.json +1 -2
- package/src/app/(main)/settings/llm/ProviderList/Azure/index.tsx +107 -0
- package/src/app/(main)/settings/llm/ProviderList/Bedrock/index.tsx +68 -0
- package/src/app/(main)/settings/llm/ProviderList/Ollama/index.tsx +29 -0
- package/src/app/(main)/settings/llm/ProviderList/OpenAI/index.tsx +20 -0
- package/src/app/(main)/settings/llm/ProviderList/providers.tsx +141 -0
- package/src/app/(main)/settings/llm/components/ProviderConfig/index.tsx +18 -27
- package/src/app/(main)/settings/llm/index.tsx +7 -34
- package/src/app/(main)/settings/llm/type.ts +5 -0
- package/src/app/api/chat/[provider]/route.ts +8 -3
- package/src/app/api/chat/agentRuntime.test.ts +17 -0
- package/src/app/api/chat/agentRuntime.ts +7 -0
- package/src/app/api/errorResponse.test.ts +7 -89
- package/src/app/api/errorResponse.ts +6 -43
- package/src/app/api/middleware/auth/index.ts +7 -3
- package/src/components/ModelProviderIcon/index.tsx +5 -0
- package/src/components/ModelSelect/index.tsx +7 -10
- package/src/config/llm.ts +6 -0
- package/src/config/modelProviders/anthropic.ts +5 -0
- package/src/config/modelProviders/azure.ts +2 -0
- package/src/config/modelProviders/bedrock.ts +2 -0
- package/src/config/modelProviders/deepseek.ts +4 -1
- package/src/config/modelProviders/google.ts +5 -0
- package/src/config/modelProviders/groq.ts +5 -0
- package/src/config/modelProviders/index.ts +4 -0
- package/src/config/modelProviders/minimax.ts +2 -0
- package/src/config/modelProviders/mistral.ts +2 -0
- package/src/config/modelProviders/moonshot.ts +2 -0
- package/src/config/modelProviders/ollama.ts +4 -0
- package/src/config/modelProviders/openai.ts +3 -0
- package/src/config/modelProviders/openrouter.ts +3 -0
- package/src/config/modelProviders/perplexity.ts +5 -0
- package/src/config/modelProviders/qwen.ts +35 -0
- package/src/config/modelProviders/togetherai.ts +3 -0
- package/src/config/modelProviders/zeroone.ts +4 -2
- package/src/config/modelProviders/zhipu.ts +2 -0
- package/src/const/settings/llm.ts +5 -0
- package/src/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +6 -3
- package/src/features/Conversation/Error/APIKeyForm/ProviderAvatar.tsx +5 -0
- package/src/features/Conversation/Error/APIKeyForm/index.tsx +4 -0
- package/src/features/Conversation/Error/OllamaBizError/InvalidOllamaModel/index.tsx +11 -14
- package/src/features/Conversation/Error/index.tsx +29 -19
- package/src/features/Conversation/components/ChatItem/index.tsx +4 -13
- package/src/features/ModelSelect/index.tsx +1 -1
- package/src/features/ModelSwitchPanel/index.tsx +1 -1
- package/src/hooks/useProviderName.ts +8 -0
- package/src/libs/agent-runtime/AgentRuntime.ts +8 -1
- package/src/libs/agent-runtime/anthropic/index.test.ts +8 -5
- package/src/libs/agent-runtime/anthropic/index.ts +3 -3
- package/src/libs/agent-runtime/azureOpenai/index.test.ts +5 -2
- package/src/libs/agent-runtime/azureOpenai/index.ts +2 -2
- package/src/libs/agent-runtime/bedrock/index.test.ts +2 -2
- package/src/libs/agent-runtime/bedrock/index.ts +2 -2
- package/src/libs/agent-runtime/deepseek/index.test.ts +3 -2
- package/src/libs/agent-runtime/deepseek/index.ts +0 -5
- package/src/libs/agent-runtime/error.ts +11 -43
- package/src/libs/agent-runtime/google/index.test.ts +3 -4
- package/src/libs/agent-runtime/google/index.ts +4 -4
- package/src/libs/agent-runtime/groq/index.test.ts +3 -2
- package/src/libs/agent-runtime/groq/index.ts +0 -4
- package/src/libs/agent-runtime/index.ts +1 -0
- package/src/libs/agent-runtime/minimax/index.test.ts +3 -2
- package/src/libs/agent-runtime/minimax/index.ts +5 -5
- package/src/libs/agent-runtime/mistral/index.test.ts +2 -2
- package/src/libs/agent-runtime/mistral/index.ts +0 -5
- package/src/libs/agent-runtime/moonshot/index.test.ts +3 -2
- package/src/libs/agent-runtime/moonshot/index.ts +0 -5
- package/src/libs/agent-runtime/openrouter/index.test.ts +3 -2
- package/src/libs/agent-runtime/openrouter/index.ts +0 -6
- package/src/libs/agent-runtime/perplexity/index.test.ts +2 -2
- package/src/libs/agent-runtime/perplexity/index.ts +0 -5
- package/src/libs/agent-runtime/qwen/index.test.ts +251 -0
- package/src/libs/agent-runtime/qwen/index.ts +28 -0
- package/src/libs/agent-runtime/togetherai/index.test.ts +3 -2
- package/src/libs/agent-runtime/togetherai/index.ts +0 -5
- package/src/libs/agent-runtime/types/type.ts +1 -1
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.test.ts +123 -6
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +12 -6
- package/src/libs/agent-runtime/utils/streams/openai.ts +1 -1
- package/src/libs/agent-runtime/zeroone/index.test.ts +3 -2
- package/src/libs/agent-runtime/zeroone/index.ts +1 -5
- package/src/libs/agent-runtime/zhipu/index.test.ts +8 -5
- package/src/libs/agent-runtime/zhipu/index.ts +2 -2
- package/src/locales/default/error.ts +10 -51
- package/src/locales/default/modelProvider.ts +12 -169
- package/src/locales/default/setting.ts +5 -8
- package/src/server/globalConfig/index.ts +2 -0
- package/src/services/__tests__/chat.test.ts +16 -0
- package/src/services/chat.ts +3 -0
- package/src/services/message/client.test.ts +4 -1
- package/src/types/fetch.ts +3 -1
- package/src/types/llm.ts +22 -0
- package/src/types/user/settings/keyVaults.ts +1 -0
- package/src/app/(main)/settings/llm/Anthropic/index.tsx +0 -25
- package/src/app/(main)/settings/llm/Azure/index.tsx +0 -110
- package/src/app/(main)/settings/llm/Bedrock/index.tsx +0 -74
- package/src/app/(main)/settings/llm/DeepSeek/index.tsx +0 -21
- package/src/app/(main)/settings/llm/Google/index.tsx +0 -31
- package/src/app/(main)/settings/llm/Groq/index.tsx +0 -26
- package/src/app/(main)/settings/llm/Minimax/index.tsx +0 -20
- package/src/app/(main)/settings/llm/Mistral/index.tsx +0 -20
- package/src/app/(main)/settings/llm/Moonshot/index.tsx +0 -28
- package/src/app/(main)/settings/llm/Ollama/index.tsx +0 -37
- package/src/app/(main)/settings/llm/OpenAI/index.tsx +0 -28
- package/src/app/(main)/settings/llm/OpenRouter/index.tsx +0 -21
- package/src/app/(main)/settings/llm/Perplexity/index.tsx +0 -23
- package/src/app/(main)/settings/llm/TogetherAI/index.tsx +0 -19
- package/src/app/(main)/settings/llm/ZeroOne/index.tsx +0 -20
- package/src/app/(main)/settings/llm/Zhipu/index.tsx +0 -18
- /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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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:
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
17
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
54
|
-
|
|
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
|
|
14
|
-
const
|
|
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:
|
|
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.
|
|
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.
|
|
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.
|
|
243
|
+
return { ...defaultError, errorType: AgentRuntimeErrorType.InvalidProviderAPIKey };
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
default: {
|
|
247
|
-
return { error: json, errorType: AgentRuntimeErrorType.
|
|
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
|
-
|
|
13
|
-
const
|
|
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 = '
|
|
11
|
-
const invalidErrorType = '
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 = '
|
|
13
|
-
const invalidErrorType = '
|
|
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
|
-
|
|
13
|
-
const
|
|
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
|
-
|
|
14
|
-
const
|
|
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 = '
|
|
13
|
-
const invalidErrorType = '
|
|
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
|
});
|