@lobehub/chat 1.75.3 → 1.75.5
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 +52 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/advanced/model-list.mdx +5 -3
- package/docs/self-hosting/advanced/model-list.zh-CN.mdx +5 -3
- package/docs/usage/providers/infiniai.zh-CN.mdx +4 -0
- package/locales/ar/models.json +51 -54
- package/locales/ar/providers.json +3 -0
- package/locales/bg-BG/models.json +51 -54
- package/locales/bg-BG/providers.json +3 -0
- package/locales/de-DE/models.json +51 -54
- package/locales/de-DE/providers.json +3 -0
- package/locales/en-US/models.json +51 -54
- package/locales/en-US/providers.json +3 -0
- package/locales/es-ES/models.json +51 -54
- package/locales/es-ES/providers.json +3 -0
- package/locales/fa-IR/models.json +51 -54
- package/locales/fa-IR/providers.json +3 -0
- package/locales/fr-FR/models.json +51 -54
- package/locales/fr-FR/providers.json +3 -0
- package/locales/it-IT/models.json +51 -54
- package/locales/it-IT/providers.json +3 -0
- package/locales/ja-JP/models.json +51 -54
- package/locales/ja-JP/providers.json +3 -0
- package/locales/ko-KR/models.json +51 -54
- package/locales/ko-KR/providers.json +3 -0
- package/locales/nl-NL/models.json +51 -54
- package/locales/nl-NL/providers.json +3 -0
- package/locales/pl-PL/models.json +51 -54
- package/locales/pl-PL/providers.json +3 -0
- package/locales/pt-BR/models.json +51 -54
- package/locales/pt-BR/providers.json +3 -0
- package/locales/ru-RU/models.json +51 -54
- package/locales/ru-RU/providers.json +3 -0
- package/locales/tr-TR/models.json +51 -54
- package/locales/tr-TR/providers.json +3 -0
- package/locales/vi-VN/models.json +51 -54
- package/locales/vi-VN/providers.json +3 -0
- package/locales/zh-CN/models.json +55 -58
- package/locales/zh-CN/providers.json +3 -0
- package/locales/zh-TW/models.json +51 -54
- package/locales/zh-TW/providers.json +3 -0
- package/package.json +1 -1
- package/src/config/aiModels/google.ts +17 -43
- package/src/config/aiModels/infiniai.ts +52 -55
- package/src/config/aiModels/qwen.ts +17 -1
- package/src/config/aiModels/siliconcloud.ts +33 -1
- package/src/config/aiModels/tencentcloud.ts +17 -0
- package/src/config/aiModels/vertexai.ts +1 -53
- package/src/config/aiModels/volcengine.ts +1 -1
- package/src/libs/agent-runtime/infiniai/index.ts +38 -3
- package/src/utils/format.ts +1 -1
- package/src/utils/parseModels.test.ts +14 -0
- package/src/utils/parseModels.ts +4 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
// import { AgentRuntimeErrorType } from '../error';
|
2
1
|
import type { ChatModelCard } from '@/types/llm';
|
3
2
|
|
4
|
-
import {
|
3
|
+
import { AgentRuntimeErrorType } from '../error';
|
4
|
+
import { ChatCompletionErrorPayload, ModelProvider } from '../types';
|
5
5
|
import { LobeOpenAICompatibleFactory } from '../utils/openaiCompatibleFactory';
|
6
6
|
|
7
7
|
export interface InfiniAIModelCard {
|
@@ -10,10 +10,42 @@ export interface InfiniAIModelCard {
|
|
10
10
|
|
11
11
|
export const LobeInfiniAI = LobeOpenAICompatibleFactory({
|
12
12
|
baseURL: 'https://cloud.infini-ai.com/maas/v1',
|
13
|
+
chatCompletion: {
|
14
|
+
handleError(error): Omit<ChatCompletionErrorPayload, 'provider'> | undefined {
|
15
|
+
let errorResponse: Response | undefined;
|
16
|
+
if (error instanceof Response) {
|
17
|
+
errorResponse = error;
|
18
|
+
} else if ('status' in (error as any)) {
|
19
|
+
errorResponse = error as Response;
|
20
|
+
}
|
21
|
+
if (errorResponse) {
|
22
|
+
if (errorResponse.status === 401) {
|
23
|
+
return {
|
24
|
+
error,
|
25
|
+
errorType: AgentRuntimeErrorType.InvalidProviderAPIKey,
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
if (errorResponse.status === 429) {
|
30
|
+
return {
|
31
|
+
error,
|
32
|
+
errorType: AgentRuntimeErrorType.QuotaLimitReached,
|
33
|
+
};
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return {
|
37
|
+
error,
|
38
|
+
};
|
39
|
+
},
|
40
|
+
},
|
41
|
+
debug: {
|
42
|
+
chatCompletion: () => process.env.DEBUG_INFINIAI_CHAT_COMPLETION === '1',
|
43
|
+
},
|
13
44
|
models: async ({ client }) => {
|
14
45
|
const { LOBE_DEFAULT_MODEL_LIST } = await import('@/config/aiModels');
|
15
46
|
|
16
47
|
const reasoningKeywords = ['deepseek-r1', 'qwq'];
|
48
|
+
const visionKeywords = ['qwen2.5-vl'];
|
17
49
|
|
18
50
|
const modelsPage = (await client.models.list()) as any;
|
19
51
|
const modelList: InfiniAIModelCard[] = modelsPage.data;
|
@@ -34,7 +66,10 @@ export const LobeInfiniAI = LobeOpenAICompatibleFactory({
|
|
34
66
|
reasoningKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
|
35
67
|
knownModel?.abilities?.reasoning ||
|
36
68
|
false,
|
37
|
-
vision:
|
69
|
+
vision:
|
70
|
+
visionKeywords.some((keyword) => model.id.toLowerCase().includes(keyword)) ||
|
71
|
+
knownModel?.abilities?.vision ||
|
72
|
+
false,
|
38
73
|
};
|
39
74
|
})
|
40
75
|
.filter(Boolean) as ChatModelCard[];
|
package/src/utils/format.ts
CHANGED
@@ -117,7 +117,7 @@ export const formatPrice = (price: number, fractionDigits: number = 2) => {
|
|
117
117
|
};
|
118
118
|
|
119
119
|
export const formatPriceByCurrency = (price?: number, currency?: ModelPriceCurrency) => {
|
120
|
-
if (!price) return '-';
|
120
|
+
if (!price && price !== 0) return '-';
|
121
121
|
|
122
122
|
if (currency === 'CNY') {
|
123
123
|
return formatPrice(price / USD_TO_CNY);
|
@@ -86,6 +86,20 @@ describe('parseModelString', () => {
|
|
86
86
|
});
|
87
87
|
});
|
88
88
|
|
89
|
+
it('token and image output', () => {
|
90
|
+
const result = parseModelString('gemini-2.0-flash-exp-image-generation=Gemini 2.0 Flash (Image Generation) Experimental<32768:imageOutput>');
|
91
|
+
|
92
|
+
expect(result.add[0]).toEqual({
|
93
|
+
displayName: 'Gemini 2.0 Flash (Image Generation) Experimental',
|
94
|
+
abilities: {
|
95
|
+
imageOutput: true,
|
96
|
+
},
|
97
|
+
id: 'gemini-2.0-flash-exp-image-generation',
|
98
|
+
contextWindowTokens: 32_768,
|
99
|
+
type: 'chat',
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
89
103
|
it('multi models', () => {
|
90
104
|
const result = parseModelString(
|
91
105
|
'gemini-1.5-flash-latest=Gemini 1.5 Flash<16000:vision>,gpt-4-all=ChatGPT Plus<128000:fc:vision:file>',
|
package/src/utils/parseModels.ts
CHANGED
@@ -84,6 +84,10 @@ export const parseModelString = (modelString: string = '', withDeploymentName =
|
|
84
84
|
model.abilities!.search = true;
|
85
85
|
break;
|
86
86
|
}
|
87
|
+
case 'imageOutput': {
|
88
|
+
model.abilities!.imageOutput = true;
|
89
|
+
break;
|
90
|
+
}
|
87
91
|
default: {
|
88
92
|
console.warn(`Unknown capability: ${capability}`);
|
89
93
|
}
|