@lobehub/chat 0.162.17 → 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/CHANGELOG.md +25 -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/locales/ar/error.json +7 -39
- package/locales/ar/modelProvider.json +15 -183
- package/locales/ar/setting.json +5 -8
- package/locales/bg-BG/error.json +6 -38
- package/locales/bg-BG/modelProvider.json +15 -183
- package/locales/bg-BG/setting.json +5 -8
- package/locales/de-DE/error.json +6 -38
- package/locales/de-DE/modelProvider.json +15 -183
- package/locales/de-DE/setting.json +5 -8
- package/locales/en-US/error.json +6 -38
- package/locales/en-US/modelProvider.json +15 -183
- package/locales/en-US/setting.json +6 -9
- package/locales/es-ES/error.json +6 -38
- package/locales/es-ES/modelProvider.json +15 -183
- package/locales/es-ES/setting.json +5 -8
- package/locales/fr-FR/error.json +6 -38
- package/locales/fr-FR/modelProvider.json +15 -183
- package/locales/fr-FR/setting.json +9 -12
- package/locales/it-IT/error.json +6 -38
- package/locales/it-IT/modelProvider.json +15 -183
- package/locales/it-IT/setting.json +5 -8
- package/locales/ja-JP/error.json +6 -38
- package/locales/ja-JP/modelProvider.json +15 -183
- package/locales/ja-JP/setting.json +5 -8
- package/locales/ko-KR/error.json +6 -38
- package/locales/ko-KR/modelProvider.json +15 -183
- package/locales/ko-KR/setting.json +5 -8
- package/locales/nl-NL/error.json +6 -38
- package/locales/nl-NL/modelProvider.json +15 -183
- package/locales/nl-NL/setting.json +5 -8
- package/locales/pl-PL/error.json +6 -38
- package/locales/pl-PL/modelProvider.json +15 -183
- package/locales/pl-PL/setting.json +6 -9
- package/locales/pt-BR/error.json +6 -38
- package/locales/pt-BR/modelProvider.json +15 -183
- package/locales/pt-BR/setting.json +5 -8
- package/locales/ru-RU/error.json +6 -38
- package/locales/ru-RU/modelProvider.json +15 -183
- package/locales/ru-RU/setting.json +5 -8
- package/locales/tr-TR/error.json +6 -38
- package/locales/tr-TR/modelProvider.json +15 -183
- package/locales/tr-TR/setting.json +5 -8
- package/locales/vi-VN/error.json +6 -38
- package/locales/vi-VN/modelProvider.json +15 -183
- package/locales/vi-VN/setting.json +5 -8
- package/locales/zh-CN/error.json +7 -39
- package/locales/zh-CN/modelProvider.json +15 -183
- package/locales/zh-CN/setting.json +5 -8
- package/locales/zh-TW/error.json +7 -39
- package/locales/zh-TW/modelProvider.json +15 -183
- 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 -36
- package/src/app/(main)/settings/llm/type.ts +5 -0
- package/src/app/api/chat/[provider]/route.ts +8 -3
- package/src/app/api/errorResponse.test.ts +7 -95
- package/src/app/api/errorResponse.ts +6 -46
- package/src/app/api/middleware/auth/index.ts +7 -3
- package/src/components/ModelSelect/index.tsx +7 -10
- 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/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 +3 -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/features/Conversation/Error/APIKeyForm/ProviderApiKeyForm.tsx +6 -3
- package/src/features/Conversation/Error/OllamaBizError/InvalidOllamaModel/index.tsx +11 -14
- package/src/features/Conversation/Error/index.tsx +29 -20
- 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/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 -46
- 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/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 +2 -2
- package/src/libs/agent-runtime/qwen/index.ts +0 -5
- 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/utils/openaiCompatibleFactory/index.test.ts +2 -6
- package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +12 -6
- 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/services/message/client.test.ts +4 -1
- package/src/types/fetch.ts +3 -1
- package/src/types/llm.ts +22 -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/Qwen/index.tsx +0 -21
- 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
|
@@ -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
|
});
|
|
@@ -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
|
});
|
|
@@ -11,8 +11,8 @@ import { LobeQwenAI } from './index';
|
|
|
11
11
|
|
|
12
12
|
const provider = ModelProvider.Qwen;
|
|
13
13
|
const defaultBaseURL = 'https://dashscope.aliyuncs.com/compatible-mode/v1';
|
|
14
|
-
const bizErrorType = AgentRuntimeErrorType.
|
|
15
|
-
const invalidErrorType = AgentRuntimeErrorType.
|
|
14
|
+
const bizErrorType = AgentRuntimeErrorType.ProviderBizError;
|
|
15
|
+
const invalidErrorType = AgentRuntimeErrorType.InvalidProviderAPIKey;
|
|
16
16
|
|
|
17
17
|
// Mock the console.error to avoid polluting test output
|
|
18
18
|
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 { ModelProvider } from '../types';
|
|
5
4
|
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
|
|
6
5
|
|
|
@@ -24,10 +23,6 @@ export const LobeQwenAI = LobeOpenAICompatibleFactory({
|
|
|
24
23
|
debug: {
|
|
25
24
|
chatCompletion: () => process.env.DEBUG_QWEN_CHAT_COMPLETION === '1',
|
|
26
25
|
},
|
|
27
|
-
errorType: {
|
|
28
|
-
bizError: AgentRuntimeErrorType.QwenBizError,
|
|
29
|
-
invalidAPIKey: AgentRuntimeErrorType.InvalidQwenAPIKey,
|
|
30
|
-
},
|
|
31
26
|
|
|
32
27
|
provider: ModelProvider.Qwen,
|
|
33
28
|
});
|
|
@@ -10,8 +10,9 @@ import { LobeTogetherAI } from './index';
|
|
|
10
10
|
|
|
11
11
|
const provider = 'togetherai';
|
|
12
12
|
const defaultBaseURL = 'https://api.together.xyz/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 { TogetherAIModel } from './type';
|
|
@@ -17,10 +16,6 @@ export const LobeTogetherAI = LobeOpenAICompatibleFactory({
|
|
|
17
16
|
debug: {
|
|
18
17
|
chatCompletion: () => process.env.DEBUG_TOGETHERAI_CHAT_COMPLETION === '1',
|
|
19
18
|
},
|
|
20
|
-
errorType: {
|
|
21
|
-
bizError: AgentRuntimeErrorType.TogetherAIBizError,
|
|
22
|
-
invalidAPIKey: AgentRuntimeErrorType.InvalidTogetherAIAPIKey,
|
|
23
|
-
},
|
|
24
19
|
models: async ({ apiKey }) => {
|
|
25
20
|
const data = await fetch(`${baseURL}/api/models`, {
|
|
26
21
|
headers: {
|
|
@@ -14,8 +14,8 @@ import { LobeOpenAICompatibleFactory } from './index';
|
|
|
14
14
|
|
|
15
15
|
const provider = 'groq';
|
|
16
16
|
const defaultBaseURL = 'https://api.groq.com/openai/v1';
|
|
17
|
-
const bizErrorType = '
|
|
18
|
-
const invalidErrorType = '
|
|
17
|
+
const bizErrorType = 'ProviderBizError';
|
|
18
|
+
const invalidErrorType = 'InvalidProviderAPIKey';
|
|
19
19
|
|
|
20
20
|
// Mock the console.error to avoid polluting test output
|
|
21
21
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
@@ -34,10 +34,6 @@ const LobeMockProvider = LobeOpenAICompatibleFactory({
|
|
|
34
34
|
debug: {
|
|
35
35
|
chatCompletion: () => process.env.DEBUG_MOCKPROVIDER_CHAT_COMPLETION === '1',
|
|
36
36
|
},
|
|
37
|
-
errorType: {
|
|
38
|
-
bizError: AgentRuntimeErrorType.GroqBizError,
|
|
39
|
-
invalidAPIKey: AgentRuntimeErrorType.InvalidGroqAPIKey,
|
|
40
|
-
},
|
|
41
37
|
provider: ModelProvider.Groq,
|
|
42
38
|
});
|
|
43
39
|
|
|
@@ -5,7 +5,7 @@ import { TextToImagePayload } from '@/libs/agent-runtime/types/textToImage';
|
|
|
5
5
|
import { ChatModelCard } from '@/types/llm';
|
|
6
6
|
|
|
7
7
|
import { LobeRuntimeAI } from '../../BaseAI';
|
|
8
|
-
import { ILobeAgentRuntimeErrorType } from '../../error';
|
|
8
|
+
import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '../../error';
|
|
9
9
|
import { ChatCompetitionOptions, ChatCompletionErrorPayload, ChatStreamPayload } from '../../types';
|
|
10
10
|
import { AgentRuntimeError } from '../createError';
|
|
11
11
|
import { debugStream } from '../debugStream';
|
|
@@ -37,7 +37,7 @@ interface OpenAICompatibleFactoryOptions {
|
|
|
37
37
|
debug?: {
|
|
38
38
|
chatCompletion: () => boolean;
|
|
39
39
|
};
|
|
40
|
-
errorType
|
|
40
|
+
errorType?: {
|
|
41
41
|
bizError: ILobeAgentRuntimeErrorType;
|
|
42
42
|
invalidAPIKey: ILobeAgentRuntimeErrorType;
|
|
43
43
|
};
|
|
@@ -52,19 +52,24 @@ interface OpenAICompatibleFactoryOptions {
|
|
|
52
52
|
export const LobeOpenAICompatibleFactory = ({
|
|
53
53
|
provider,
|
|
54
54
|
baseURL: DEFAULT_BASE_URL,
|
|
55
|
-
errorType
|
|
55
|
+
errorType,
|
|
56
56
|
debug,
|
|
57
57
|
constructorOptions,
|
|
58
58
|
chatCompletion,
|
|
59
59
|
models,
|
|
60
|
-
}: OpenAICompatibleFactoryOptions) =>
|
|
61
|
-
|
|
60
|
+
}: OpenAICompatibleFactoryOptions) => {
|
|
61
|
+
const ErrorType = {
|
|
62
|
+
bizError: errorType?.bizError || AgentRuntimeErrorType.ProviderBizError,
|
|
63
|
+
invalidAPIKey: errorType?.invalidAPIKey || AgentRuntimeErrorType.InvalidProviderAPIKey,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return class LobeOpenAICompatibleAI implements LobeRuntimeAI {
|
|
62
67
|
client: OpenAI;
|
|
63
68
|
|
|
64
69
|
baseURL: string;
|
|
65
70
|
|
|
66
71
|
constructor({ apiKey, baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions) {
|
|
67
|
-
if (!apiKey) throw AgentRuntimeError.createError(ErrorType
|
|
72
|
+
if (!apiKey) throw AgentRuntimeError.createError(ErrorType?.invalidAPIKey);
|
|
68
73
|
|
|
69
74
|
this.client = new OpenAI({ apiKey, baseURL, ...constructorOptions, ...res });
|
|
70
75
|
this.baseURL = this.client.baseURL;
|
|
@@ -286,3 +291,4 @@ export const LobeOpenAICompatibleFactory = ({
|
|
|
286
291
|
});
|
|
287
292
|
}
|
|
288
293
|
};
|
|
294
|
+
};
|
|
@@ -9,8 +9,9 @@ import { LobeZeroOneAI } from './index';
|
|
|
9
9
|
|
|
10
10
|
const provider = 'zeroone';
|
|
11
11
|
const defaultBaseURL = 'https://api.lingyiwanwu.com/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,6 @@ export const LobeZeroOneAI = LobeOpenAICompatibleFactory({
|
|
|
7
6
|
debug: {
|
|
8
7
|
chatCompletion: () => process.env.DEBUG_ZEROONE_CHAT_COMPLETION === '1',
|
|
9
8
|
},
|
|
10
|
-
|
|
11
|
-
bizError: AgentRuntimeErrorType.ZeroOneBizError,
|
|
12
|
-
invalidAPIKey: AgentRuntimeErrorType.InvalidZeroOneAPIKey,
|
|
13
|
-
},
|
|
9
|
+
|
|
14
10
|
provider: ModelProvider.ZeroOne,
|
|
15
11
|
});
|
|
@@ -8,6 +8,9 @@ import * as debugStreamModule from '@/libs/agent-runtime/utils/debugStream';
|
|
|
8
8
|
import * as authTokenModule from './authToken';
|
|
9
9
|
import { LobeZhipuAI } from './index';
|
|
10
10
|
|
|
11
|
+
const bizErrorType = 'ProviderBizError';
|
|
12
|
+
const invalidErrorType = 'InvalidProviderAPIKey';
|
|
13
|
+
|
|
11
14
|
// Mock相关依赖
|
|
12
15
|
vi.mock('./authToken');
|
|
13
16
|
|
|
@@ -33,7 +36,7 @@ describe('LobeZhipuAI', () => {
|
|
|
33
36
|
try {
|
|
34
37
|
await LobeZhipuAI.fromAPIKey({ apiKey: 'asd' });
|
|
35
38
|
} catch (e) {
|
|
36
|
-
expect(e).toEqual({ errorType:
|
|
39
|
+
expect(e).toEqual({ errorType: invalidErrorType });
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
42
|
});
|
|
@@ -164,7 +167,7 @@ describe('LobeZhipuAI', () => {
|
|
|
164
167
|
error: { message: 'Bad Request' },
|
|
165
168
|
status: 400,
|
|
166
169
|
},
|
|
167
|
-
errorType:
|
|
170
|
+
errorType: bizErrorType,
|
|
168
171
|
provider: 'zhipu',
|
|
169
172
|
});
|
|
170
173
|
}
|
|
@@ -174,7 +177,7 @@ describe('LobeZhipuAI', () => {
|
|
|
174
177
|
try {
|
|
175
178
|
await LobeZhipuAI.fromAPIKey({ apiKey: '' });
|
|
176
179
|
} catch (e) {
|
|
177
|
-
expect(e).toEqual({ errorType:
|
|
180
|
+
expect(e).toEqual({ errorType: invalidErrorType });
|
|
178
181
|
}
|
|
179
182
|
});
|
|
180
183
|
|
|
@@ -204,7 +207,7 @@ describe('LobeZhipuAI', () => {
|
|
|
204
207
|
cause: { message: 'api is undefined' },
|
|
205
208
|
stack: 'abc',
|
|
206
209
|
},
|
|
207
|
-
errorType:
|
|
210
|
+
errorType: bizErrorType,
|
|
208
211
|
provider: 'zhipu',
|
|
209
212
|
});
|
|
210
213
|
}
|
|
@@ -240,7 +243,7 @@ describe('LobeZhipuAI', () => {
|
|
|
240
243
|
cause: { message: 'api is undefined' },
|
|
241
244
|
stack: 'abc',
|
|
242
245
|
},
|
|
243
|
-
errorType:
|
|
246
|
+
errorType: bizErrorType,
|
|
244
247
|
provider: 'zhipu',
|
|
245
248
|
});
|
|
246
249
|
}
|
|
@@ -31,7 +31,7 @@ export class LobeZhipuAI implements LobeRuntimeAI {
|
|
|
31
31
|
|
|
32
32
|
static async fromAPIKey({ apiKey, baseURL = DEFAULT_BASE_URL, ...res }: ClientOptions) {
|
|
33
33
|
const invalidZhipuAPIKey = AgentRuntimeError.createError(
|
|
34
|
-
AgentRuntimeErrorType.
|
|
34
|
+
AgentRuntimeErrorType.InvalidProviderAPIKey,
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
if (!apiKey) throw invalidZhipuAPIKey;
|
|
@@ -70,7 +70,7 @@ export class LobeZhipuAI implements LobeRuntimeAI {
|
|
|
70
70
|
} catch (error) {
|
|
71
71
|
const { errorResult, RuntimeError } = handleOpenAIError(error);
|
|
72
72
|
|
|
73
|
-
const errorType = RuntimeError || AgentRuntimeErrorType.
|
|
73
|
+
const errorType = RuntimeError || AgentRuntimeErrorType.ProviderBizError;
|
|
74
74
|
let desensitizedEndpoint = this.baseURL;
|
|
75
75
|
|
|
76
76
|
if (this.baseURL !== DEFAULT_BASE_URL) {
|
|
@@ -76,56 +76,20 @@ export default {
|
|
|
76
76
|
LocationNotSupportError:
|
|
77
77
|
'很抱歉,你的所在地区不支持此模型服务,可能是由于区域限制或服务未开通。请确认当前地区是否支持使用此服务,或尝试使用切换到其他地区后重试。',
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
MistralBizError: '请求 Mistral AI 服务出错,请根据以下信息排查或重试',
|
|
86
|
-
InvalidMistralAPIKey: 'Mistral AI API Key 不正确或为空,请检查 Mistral API Key 后重试',
|
|
87
|
-
|
|
88
|
-
MoonshotBizError: '请求月之暗面服务出错,请根据以下信息排查或重试',
|
|
89
|
-
InvalidMoonshotAPIKey: 'Moonshot AI API Key 不正确或为空,请检查 Moonshot API Key 后重试',
|
|
90
|
-
|
|
91
|
-
GoogleBizError: '请求 Google 服务出错,请根据以下信息排查或重试',
|
|
92
|
-
InvalidGoogleAPIKey: 'Google API Key 不正确或为空,请检查 Google API Key 后重试',
|
|
79
|
+
InvalidProviderAPIKey: '{{provider}} API Key 不正确或为空,请检查 {{provider}} API Key 后重试',
|
|
80
|
+
ProviderBizAPIKey: '请求 {{provider}} 服务出错,请根据以下信息排查或重试',
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated
|
|
83
|
+
*/
|
|
84
|
+
NoOpenAIAPIKey: 'OpenAI API Key 不正确或为空,请添加自定义 OpenAI API Key',
|
|
93
85
|
|
|
94
86
|
InvalidBedrockCredentials: 'Bedrock 鉴权未通过,请检查 AccessKeyId/SecretAccessKey 后重试',
|
|
95
|
-
BedrockBizError: '请求 Bedrock 服务出错,请根据以下信息排查或重试',
|
|
96
|
-
|
|
97
|
-
InvalidDeepSeekAPIKey: 'DeepSeek API Key 不正确或为空,请检查 DeepSeek API Key 后重试',
|
|
98
|
-
DeepSeekBizError: '请求 DeepSeek 服务出错,请根据以下信息排查或重试',
|
|
99
|
-
|
|
100
|
-
InvalidAzureAPIKey: 'Azure API Key 不正确或为空,请检查 Azure API Key 后重试',
|
|
101
|
-
AzureBizError: '请求 Azure AI 服务出错,请根据以下信息排查或重试',
|
|
102
|
-
|
|
103
|
-
InvalidPerplexityAPIKey: 'Perplexity API Key 不正确或为空,请检查 Perplexity API Key 后重试',
|
|
104
|
-
PerplexityBizError: '请求 Perplexity AI 服务出错,请根据以下信息排查或重试',
|
|
105
|
-
|
|
106
|
-
InvalidAnthropicAPIKey: 'Anthropic API Key 不正确或为空,请检查 Anthropic API Key 后重试',
|
|
107
|
-
AnthropicBizError: '请求 Anthropic AI 服务出错,请根据以下信息排查或重试',
|
|
108
|
-
|
|
109
|
-
InvalidGroqAPIKey: 'Groq API Key 不正确或为空,请检查 Groq API Key 后重试',
|
|
110
|
-
GroqBizError: '请求 Groq 服务出错,请根据以下信息排查或重试',
|
|
111
|
-
|
|
112
|
-
InvalidOpenRouterAPIKey: 'OpenRouter API Key 不正确或为空,请检查 OpenRouter API Key 后重试',
|
|
113
|
-
OpenRouterBizError: '请求 OpenRouter AI 服务出错,请根据以下信息排查或重试',
|
|
114
|
-
|
|
115
|
-
InvalidTogetherAIAPIKey: 'TogetherAI API Key 不正确或为空,请检查 TogetherAI API Key 后重试',
|
|
116
|
-
TogetherAIBizError: '请求 TogetherAI AI 服务出错,请根据以下信息排查或重试',
|
|
117
|
-
|
|
118
|
-
ZeroOneBizError: '请求零一万物服务出错,请根据以下信息排查或重试',
|
|
119
|
-
InvalidZeroOneAPIKey: '零一万物 API Key 不正确或为空,请检查零一万物 API Key 后重试',
|
|
120
87
|
|
|
121
88
|
InvalidOllamaArgs: 'Ollama 配置不正确,请检查 Ollama 配置后重试',
|
|
122
89
|
OllamaBizError: '请求 Ollama 服务出错,请根据以下信息排查或重试',
|
|
123
90
|
OllamaServiceUnavailable:
|
|
124
91
|
'Ollama 服务连接失败,请检查 Ollama 是否运行正常,或是否正确设置 Ollama 的跨域配置',
|
|
125
92
|
|
|
126
|
-
MinimaxBizError: '请求 Minimax 服务出错,请根据以下信息排查或重试',
|
|
127
|
-
InvalidMinimaxAPIKey: 'Minimax API Key 不正确或为空,请检查 Minimax API Key 后重试',
|
|
128
|
-
|
|
129
93
|
AgentRuntimeError: 'Lobe AI Runtime 执行出错,请根据以下信息排查或重试',
|
|
130
94
|
/* eslint-enable */
|
|
131
95
|
},
|
|
@@ -137,23 +101,18 @@ export default {
|
|
|
137
101
|
},
|
|
138
102
|
unlock: {
|
|
139
103
|
addProxyUrl: '添加 OpenAI 代理地址(可选)',
|
|
104
|
+
apiKey: {
|
|
105
|
+
description: '输入你的 {{name}} API Key 即可开始会话',
|
|
106
|
+
title: '使用自定义 {{name}} API Key',
|
|
107
|
+
},
|
|
140
108
|
closeMessage: '关闭提示',
|
|
141
109
|
confirm: '确认并重试',
|
|
142
|
-
|
|
143
110
|
oauth: {
|
|
144
111
|
description: '管理员已开启统一登录认证,点击下方按钮登录,即可解锁应用',
|
|
145
112
|
success: '登录成功',
|
|
146
113
|
title: '登录账号',
|
|
147
114
|
welcome: '欢迎你!',
|
|
148
115
|
},
|
|
149
|
-
ollama: {
|
|
150
|
-
cancel: '取消下载',
|
|
151
|
-
confirm: '下载',
|
|
152
|
-
description: '输入你的 Ollama 模型标签,完成即可继续会话',
|
|
153
|
-
downloaded: '{{completed}} / {{total}}',
|
|
154
|
-
starting: '开始下载...',
|
|
155
|
-
title: '下载指定的 Ollama 模型',
|
|
156
|
-
},
|
|
157
116
|
password: {
|
|
158
117
|
description: '管理员已开启应用加密,输入应用密码后即可解锁应用。密码只需填写一次',
|
|
159
118
|
placeholder: '请输入密码',
|