@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.
Files changed (55) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/changelog/v1.json +18 -0
  5. package/docs/self-hosting/advanced/model-list.mdx +5 -3
  6. package/docs/self-hosting/advanced/model-list.zh-CN.mdx +5 -3
  7. package/docs/usage/providers/infiniai.zh-CN.mdx +4 -0
  8. package/locales/ar/models.json +51 -54
  9. package/locales/ar/providers.json +3 -0
  10. package/locales/bg-BG/models.json +51 -54
  11. package/locales/bg-BG/providers.json +3 -0
  12. package/locales/de-DE/models.json +51 -54
  13. package/locales/de-DE/providers.json +3 -0
  14. package/locales/en-US/models.json +51 -54
  15. package/locales/en-US/providers.json +3 -0
  16. package/locales/es-ES/models.json +51 -54
  17. package/locales/es-ES/providers.json +3 -0
  18. package/locales/fa-IR/models.json +51 -54
  19. package/locales/fa-IR/providers.json +3 -0
  20. package/locales/fr-FR/models.json +51 -54
  21. package/locales/fr-FR/providers.json +3 -0
  22. package/locales/it-IT/models.json +51 -54
  23. package/locales/it-IT/providers.json +3 -0
  24. package/locales/ja-JP/models.json +51 -54
  25. package/locales/ja-JP/providers.json +3 -0
  26. package/locales/ko-KR/models.json +51 -54
  27. package/locales/ko-KR/providers.json +3 -0
  28. package/locales/nl-NL/models.json +51 -54
  29. package/locales/nl-NL/providers.json +3 -0
  30. package/locales/pl-PL/models.json +51 -54
  31. package/locales/pl-PL/providers.json +3 -0
  32. package/locales/pt-BR/models.json +51 -54
  33. package/locales/pt-BR/providers.json +3 -0
  34. package/locales/ru-RU/models.json +51 -54
  35. package/locales/ru-RU/providers.json +3 -0
  36. package/locales/tr-TR/models.json +51 -54
  37. package/locales/tr-TR/providers.json +3 -0
  38. package/locales/vi-VN/models.json +51 -54
  39. package/locales/vi-VN/providers.json +3 -0
  40. package/locales/zh-CN/models.json +55 -58
  41. package/locales/zh-CN/providers.json +3 -0
  42. package/locales/zh-TW/models.json +51 -54
  43. package/locales/zh-TW/providers.json +3 -0
  44. package/package.json +1 -1
  45. package/src/config/aiModels/google.ts +17 -43
  46. package/src/config/aiModels/infiniai.ts +52 -55
  47. package/src/config/aiModels/qwen.ts +17 -1
  48. package/src/config/aiModels/siliconcloud.ts +33 -1
  49. package/src/config/aiModels/tencentcloud.ts +17 -0
  50. package/src/config/aiModels/vertexai.ts +1 -53
  51. package/src/config/aiModels/volcengine.ts +1 -1
  52. package/src/libs/agent-runtime/infiniai/index.ts +38 -3
  53. package/src/utils/format.ts +1 -1
  54. package/src/utils/parseModels.test.ts +14 -0
  55. 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 { ModelProvider } from '../types';
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: knownModel?.abilities?.vision || false,
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[];
@@ -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>',
@@ -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
  }