@lobehub/chat 1.60.8 → 1.61.0

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 (97) hide show
  1. package/.github/ISSUE_TEMPLATE/1_bug_report.yml +2 -1
  2. package/.github/ISSUE_TEMPLATE/1_bug_report_cn.yml +1 -0
  3. package/.github/workflows/docker-pglite.yml +161 -0
  4. package/CHANGELOG.md +50 -0
  5. package/Dockerfile.pglite +244 -0
  6. package/changelog/v1.json +17 -0
  7. package/locales/ar/error.json +1 -0
  8. package/locales/ar/modelProvider.json +7 -0
  9. package/locales/ar/models.json +3 -12
  10. package/locales/ar/providers.json +3 -0
  11. package/locales/bg-BG/error.json +1 -0
  12. package/locales/bg-BG/modelProvider.json +7 -0
  13. package/locales/bg-BG/models.json +3 -12
  14. package/locales/bg-BG/providers.json +3 -0
  15. package/locales/de-DE/error.json +1 -0
  16. package/locales/de-DE/modelProvider.json +7 -0
  17. package/locales/de-DE/models.json +3 -12
  18. package/locales/de-DE/providers.json +3 -0
  19. package/locales/en-US/error.json +1 -0
  20. package/locales/en-US/modelProvider.json +7 -0
  21. package/locales/en-US/models.json +3 -12
  22. package/locales/en-US/providers.json +3 -0
  23. package/locales/es-ES/error.json +1 -0
  24. package/locales/es-ES/modelProvider.json +7 -0
  25. package/locales/es-ES/models.json +3 -12
  26. package/locales/es-ES/providers.json +3 -0
  27. package/locales/fa-IR/error.json +1 -0
  28. package/locales/fa-IR/modelProvider.json +7 -0
  29. package/locales/fa-IR/models.json +3 -12
  30. package/locales/fa-IR/providers.json +3 -0
  31. package/locales/fr-FR/error.json +1 -0
  32. package/locales/fr-FR/modelProvider.json +7 -0
  33. package/locales/fr-FR/models.json +3 -12
  34. package/locales/fr-FR/providers.json +3 -0
  35. package/locales/it-IT/error.json +1 -0
  36. package/locales/it-IT/modelProvider.json +7 -0
  37. package/locales/it-IT/models.json +3 -12
  38. package/locales/it-IT/providers.json +3 -0
  39. package/locales/ja-JP/error.json +1 -0
  40. package/locales/ja-JP/modelProvider.json +7 -0
  41. package/locales/ja-JP/models.json +3 -12
  42. package/locales/ja-JP/providers.json +3 -0
  43. package/locales/ko-KR/error.json +1 -0
  44. package/locales/ko-KR/modelProvider.json +7 -0
  45. package/locales/ko-KR/models.json +3 -12
  46. package/locales/ko-KR/providers.json +3 -0
  47. package/locales/nl-NL/error.json +1 -0
  48. package/locales/nl-NL/modelProvider.json +7 -0
  49. package/locales/nl-NL/models.json +3 -12
  50. package/locales/nl-NL/providers.json +3 -0
  51. package/locales/pl-PL/error.json +1 -0
  52. package/locales/pl-PL/modelProvider.json +7 -0
  53. package/locales/pl-PL/models.json +3 -12
  54. package/locales/pl-PL/providers.json +3 -0
  55. package/locales/pt-BR/error.json +1 -0
  56. package/locales/pt-BR/modelProvider.json +7 -0
  57. package/locales/pt-BR/models.json +3 -12
  58. package/locales/pt-BR/providers.json +3 -0
  59. package/locales/ru-RU/error.json +1 -0
  60. package/locales/ru-RU/modelProvider.json +7 -0
  61. package/locales/ru-RU/models.json +3 -12
  62. package/locales/ru-RU/providers.json +3 -0
  63. package/locales/tr-TR/error.json +1 -0
  64. package/locales/tr-TR/modelProvider.json +7 -0
  65. package/locales/tr-TR/models.json +3 -12
  66. package/locales/tr-TR/providers.json +3 -0
  67. package/locales/vi-VN/error.json +1 -0
  68. package/locales/vi-VN/modelProvider.json +7 -0
  69. package/locales/vi-VN/models.json +3 -12
  70. package/locales/vi-VN/providers.json +3 -0
  71. package/locales/zh-CN/error.json +1 -0
  72. package/locales/zh-CN/modelProvider.json +7 -0
  73. package/locales/zh-CN/models.json +3 -12
  74. package/locales/zh-CN/providers.json +3 -0
  75. package/locales/zh-TW/error.json +1 -0
  76. package/locales/zh-TW/modelProvider.json +7 -0
  77. package/locales/zh-TW/models.json +3 -12
  78. package/locales/zh-TW/providers.json +3 -0
  79. package/package.json +2 -1
  80. package/src/app/(backend)/webapi/chat/vertexai/route.ts +35 -0
  81. package/src/app/[variants]/(main)/settings/provider/(detail)/huggingface/page.tsx +3 -3
  82. package/src/app/[variants]/(main)/settings/provider/(detail)/vertexai/page.tsx +67 -0
  83. package/src/config/aiModels/index.ts +3 -0
  84. package/src/config/aiModels/vertexai.ts +200 -0
  85. package/src/config/modelProviders/index.ts +3 -0
  86. package/src/config/modelProviders/vertexai.ts +22 -0
  87. package/src/database/client/db.ts +2 -1
  88. package/src/libs/agent-runtime/error.ts +1 -0
  89. package/src/libs/agent-runtime/google/index.ts +22 -4
  90. package/src/libs/agent-runtime/types/type.ts +1 -0
  91. package/src/libs/agent-runtime/utils/streams/vertex-ai.test.ts +236 -0
  92. package/src/libs/agent-runtime/utils/streams/vertex-ai.ts +75 -0
  93. package/src/libs/agent-runtime/vertexai/index.ts +23 -0
  94. package/src/locales/default/error.ts +1 -0
  95. package/src/locales/default/modelProvider.ts +7 -0
  96. package/src/types/user/settings/keyVaults.ts +1 -0
  97. package/src/utils/safeParseJSON.ts +1 -1
@@ -371,9 +371,6 @@
371
371
  "abab6.5t-chat": {
372
372
  "description": "针对中文人设对话场景优化,提供流畅且符合中文表达习惯的对话生成能力。"
373
373
  },
374
- "abab7-chat-preview": {
375
- "description": "相对于abab6.5系列模型在长文、数学、写作等能力有大幅度提升。"
376
- },
377
374
  "accounts/fireworks/models/deepseek-r1": {
378
375
  "description": "DeepSeek-R1 是一款最先进的大型语言模型,经过强化学习和冷启动数据的优化,具有出色的推理、数学和编程性能。"
379
376
  },
@@ -728,6 +725,9 @@
728
725
  "gemini-1.0-pro-latest": {
729
726
  "description": "Gemini 1.0 Pro 是Google的高性能AI模型,专为广泛任务扩展而设计。"
730
727
  },
728
+ "gemini-1.5-flash": {
729
+ "description": "Gemini 1.5 Flash 是Google最新的多模态AI模型,具备快速处理能力,支持文本、图像和视频输入,适用于多种任务的高效扩展。"
730
+ },
731
731
  "gemini-1.5-flash-001": {
732
732
  "description": "Gemini 1.5 Flash 001 是一款高效的多模态模型,支持广泛应用的扩展。"
733
733
  },
@@ -767,24 +767,15 @@
767
767
  "gemini-2.0-flash-001": {
768
768
  "description": "Gemini 2.0 Flash 提供下一代功能和改进,包括卓越的速度、原生工具使用、多模态生成和1M令牌上下文窗口。"
769
769
  },
770
- "gemini-2.0-flash-exp": {
771
- "description": "Gemini 2.0 Flash Exp 是 Google 的实验性多模态AI模型,拥有下一代特性,卓越的速度,原生工具调用以及多模态生成。"
772
- },
773
770
  "gemini-2.0-flash-lite-preview-02-05": {
774
771
  "description": "一个 Gemini 2.0 Flash 模型,针对成本效益和低延迟等目标进行了优化。"
775
772
  },
776
773
  "gemini-2.0-flash-thinking-exp-01-21": {
777
774
  "description": "Gemini 2.0 Flash Thinking Exp 是 Google 的实验性多模态推理AI模型,能对复杂问题进行推理,拥有新的思维能力。"
778
775
  },
779
- "gemini-2.0-flash-thinking-exp-1219": {
780
- "description": "Gemini 2.0 Flash Thinking Exp 是 Google 的实验性多模态推理AI模型,能对复杂问题进行推理,拥有新的思维能力。"
781
- },
782
776
  "gemini-2.0-pro-exp-02-05": {
783
777
  "description": "Gemini 2.0 Pro Experimental 是 Google 最新的实验性多模态AI模型,与历史版本相比有一定的质量提升,特别是对于世界知识、代码和长上下文。"
784
778
  },
785
- "gemini-exp-1206": {
786
- "description": "Gemini Exp 1206 是 Google 的实验性多模态AI模型,与历史版本相比有一定的质量提升。"
787
- },
788
779
  "gemma-7b-it": {
789
780
  "description": "Gemma 7B 适合中小规模任务处理,兼具成本效益。"
790
781
  },
@@ -119,6 +119,9 @@
119
119
  "upstage": {
120
120
  "description": "Upstage 专注于为各种商业需求开发AI模型,包括 Solar LLM 和文档 AI,旨在实现工作的人造通用智能(AGI)。通过 Chat API 创建简单的对话代理,并支持功能调用、翻译、嵌入以及特定领域应用。"
121
121
  },
122
+ "vertexai": {
123
+ "description": "Google 的 Gemini 系列是其最先进、通用的 AI模型,由 Google DeepMind 打造,专为多模态设计,支持文本、代码、图像、音频和视频的无缝理解与处理。适用于从数据中心到移动设备的多种环境,极大提升了AI模型的效率与应用广泛性。"
124
+ },
122
125
  "vllm": {
123
126
  "description": "vLLM 是一个快速且易于使用的库,用于 LLM 推理和服务。"
124
127
  },
@@ -76,6 +76,7 @@
76
76
  "InvalidGithubToken": "Github 個人存取權杖不正確或為空,請檢查 Github 個人存取權杖後再試一次",
77
77
  "InvalidOllamaArgs": "Ollama 配置不正確,請檢查 Ollama 配置後重試",
78
78
  "InvalidProviderAPIKey": "{{provider}} API 金鑰不正確或為空,請檢查 {{provider}} API 金鑰後重試",
79
+ "InvalidVertexCredentials": "Vertex 認證未通過,請檢查認證憑證後重試",
79
80
  "LocationNotSupportError": "很抱歉,你的所在位置不支持此模型服務,可能是由於地區限制或服務未開通。請確認當前位置是否支持使用此服務,或嘗試使用其他位置信息。",
80
81
  "NoOpenAIAPIKey": "OpenAI API 金鑰為空,請添加自訂 OpenAI API 金鑰",
81
82
  "OllamaBizError": "請求 Ollama 服務出錯,請根據以下資訊排查或重試",
@@ -322,6 +322,13 @@
322
322
  "tooltip": "更新服務商基礎配置",
323
323
  "updateSuccess": "更新成功"
324
324
  },
325
+ "vertexai": {
326
+ "apiKey": {
327
+ "desc": "填入你的 Vertex AI 金鑰",
328
+ "placeholder": "{ \"type\": \"service_account\", \"project_id\": \"xxx\", \"private_key_id\": ... }",
329
+ "title": "Vertex AI 金鑰"
330
+ }
331
+ },
325
332
  "zeroone": {
326
333
  "title": "01.AI 零一萬物"
327
334
  },
@@ -371,9 +371,6 @@
371
371
  "abab6.5t-chat": {
372
372
  "description": "針對中文人設對話場景優化,提供流暢且符合中文表達習慣的對話生成能力。"
373
373
  },
374
- "abab7-chat-preview": {
375
- "description": "相對於abab6.5系列模型在長文、數學、寫作等能力有大幅度提升。"
376
- },
377
374
  "accounts/fireworks/models/deepseek-r1": {
378
375
  "description": "DeepSeek-R1 是一款最先進的大型語言模型,經過強化學習和冷啟動數據的優化,具有出色的推理、數學和編程性能。"
379
376
  },
@@ -728,6 +725,9 @@
728
725
  "gemini-1.0-pro-latest": {
729
726
  "description": "Gemini 1.0 Pro 是 Google 的高性能 AI 模型,專為廣泛任務擴展而設計。"
730
727
  },
728
+ "gemini-1.5-flash": {
729
+ "description": "Gemini 1.5 Flash 是 Google 最新的多模態 AI 模型,具備快速處理能力,支持文本、圖像和視頻輸入,適用於多種任務的高效擴展。"
730
+ },
731
731
  "gemini-1.5-flash-001": {
732
732
  "description": "Gemini 1.5 Flash 001 是一款高效的多模態模型,支持廣泛應用的擴展。"
733
733
  },
@@ -767,24 +767,15 @@
767
767
  "gemini-2.0-flash-001": {
768
768
  "description": "Gemini 2.0 Flash 提供下一代功能和改進,包括卓越的速度、原生工具使用、多模態生成和1M令牌上下文窗口。"
769
769
  },
770
- "gemini-2.0-flash-exp": {
771
- "description": "Gemini 2.0 Flash Exp 是 Google 最新的實驗性多模態AI模型,擁有下一代特性,卓越的速度,原生工具調用以及多模態生成。"
772
- },
773
770
  "gemini-2.0-flash-lite-preview-02-05": {
774
771
  "description": "一個 Gemini 2.0 Flash 模型,針對成本效益和低延遲等目標進行了優化。"
775
772
  },
776
773
  "gemini-2.0-flash-thinking-exp-01-21": {
777
774
  "description": "Gemini 2.0 Flash Exp 是 Google 最新的實驗性多模態AI模型,擁有下一代特性,卓越的速度,原生工具調用以及多模態生成。"
778
775
  },
779
- "gemini-2.0-flash-thinking-exp-1219": {
780
- "description": "Gemini 2.0 Flash Exp 是 Google 最新的實驗性多模態AI模型,擁有下一代特性,卓越的速度,原生工具調用以及多模態生成。"
781
- },
782
776
  "gemini-2.0-pro-exp-02-05": {
783
777
  "description": "Gemini 2.0 Pro Experimental 是 Google 最新的實驗性多模態AI模型,與歷史版本相比有一定的質量提升,特別是對於世界知識、代碼和長上下文。"
784
778
  },
785
- "gemini-exp-1206": {
786
- "description": "Gemini Exp 1206 是 Google 最新的實驗性多模態 AI 模型,與歷史版本相比有一定的質量提升。"
787
- },
788
779
  "gemma-7b-it": {
789
780
  "description": "Gemma 7B 適合中小規模任務處理,兼具成本效益。"
790
781
  },
@@ -119,6 +119,9 @@
119
119
  "upstage": {
120
120
  "description": "Upstage 專注於為各種商業需求開發 AI 模型,包括 Solar LLM 和文檔 AI,旨在實現工作的人工通用智能(AGI)。通過 Chat API 創建簡單的對話代理,並支持功能調用、翻譯、嵌入以及特定領域應用。"
121
121
  },
122
+ "vertexai": {
123
+ "description": "Google 的 Gemini 系列是其最先進、通用的 AI 模型,由 Google DeepMind 打造,專為多模態設計,支持文本、程式碼、圖像、音訊和視頻的無縫理解與處理。適用於從數據中心到行動裝置的多種環境,極大提升了 AI 模型的效率與應用廣泛性。"
124
+ },
122
125
  "vllm": {
123
126
  "description": "vLLM 是一個快速且易於使用的庫,用於 LLM 推理和服務。"
124
127
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "1.60.8",
3
+ "version": "1.61.0",
4
4
  "description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -118,6 +118,7 @@
118
118
  "@codesandbox/sandpack-react": "^2.19.10",
119
119
  "@cyntler/react-doc-viewer": "^1.17.0",
120
120
  "@electric-sql/pglite": "0.2.13",
121
+ "@google-cloud/vertexai": "^1.9.2",
121
122
  "@google/generative-ai": "^0.21.0",
122
123
  "@huggingface/inference": "^2.8.1",
123
124
  "@icons-pack/react-simple-icons": "9.6.0",
@@ -0,0 +1,35 @@
1
+ import { checkAuth } from '@/app/(backend)/middleware/auth';
2
+ import { AgentRuntime, ModelProvider } from '@/libs/agent-runtime';
3
+ import { LobeVertexAI } from '@/libs/agent-runtime/vertexai';
4
+ import { safeParseJSON } from '@/utils/safeParseJSON';
5
+
6
+ import { POST as UniverseRoute } from '../[provider]/route';
7
+
8
+ // due to the Chinese region does not support accessing Google
9
+ // we need to use proxy to access it
10
+ // refs: https://github.com/google/generative-ai-js/issues/29#issuecomment-1866246513
11
+ // if (process.env.HTTP_PROXY_URL) {
12
+ // const { setGlobalDispatcher, ProxyAgent } = require('undici');
13
+ //
14
+ // setGlobalDispatcher(new ProxyAgent({ uri: process.env.HTTP_PROXY_URL }));
15
+ // }
16
+
17
+ export const POST = checkAuth(async (req: Request, { jwtPayload }) =>
18
+ UniverseRoute(req, {
19
+ createRuntime: () => {
20
+ const googleAuthStr = jwtPayload.apiKey ?? process.env.VERTEXAI_CREDENTIALS ?? undefined;
21
+
22
+ const credentials = safeParseJSON(googleAuthStr);
23
+ const googleAuthOptions = credentials ? { credentials } : undefined;
24
+
25
+ const instance = LobeVertexAI.initFromVertexAI({
26
+ googleAuthOptions,
27
+ location: process.env.VERTEXAI_LOCATION,
28
+ project: !!credentials?.project_id ? credentials?.project_id : process.env.VERTEXAI_PROJECT,
29
+ });
30
+
31
+ return new AgentRuntime(instance);
32
+ },
33
+ params: Promise.resolve({ provider: ModelProvider.VertexAI }),
34
+ }),
35
+ );
@@ -43,15 +43,15 @@ const useProviderCard = (): ProviderItem => {
43
43
  ) : (
44
44
  <FormPassword
45
45
  autoComplete={'new-password'}
46
- placeholder={t(`huggingface.accessToken.placeholder`)}
46
+ placeholder={t('huggingface.accessToken.placeholder')}
47
47
  />
48
48
  ),
49
49
  desc: (
50
50
  <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
51
- {t(`huggingface.accessToken.desc`)}
51
+ {t('huggingface.accessToken.desc')}
52
52
  </Markdown>
53
53
  ),
54
- label: t(`huggingface.accessToken.title`),
54
+ label: t('huggingface.accessToken.title'),
55
55
  name: [KeyVaultsConfigKey, LLMProviderApiTokenKey],
56
56
  },
57
57
  ],
@@ -0,0 +1,67 @@
1
+ 'use client';
2
+
3
+ import { Markdown } from '@lobehub/ui';
4
+ import { createStyles } from 'antd-style';
5
+ import { useTranslation } from 'react-i18next';
6
+
7
+ import { FormPassword } from '@/components/FormInput';
8
+ import { VertexAIProviderCard } from '@/config/modelProviders';
9
+ import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
10
+ import { GlobalLLMProviderKey } from '@/types/user/settings';
11
+
12
+ import { KeyVaultsConfigKey, LLMProviderApiTokenKey } from '../../const';
13
+ import { SkeletonInput } from '../../features/ProviderConfig';
14
+ import { ProviderItem } from '../../type';
15
+ import ProviderDetail from '../[id]';
16
+
17
+ const useStyles = createStyles(({ css, token }) => ({
18
+ markdown: css`
19
+ p {
20
+ color: ${token.colorTextDescription} !important;
21
+ }
22
+ `,
23
+ tip: css`
24
+ font-size: 12px;
25
+ color: ${token.colorTextDescription};
26
+ `,
27
+ }));
28
+
29
+ const providerKey: GlobalLLMProviderKey = 'vertexai';
30
+
31
+ // Same as OpenAIProvider, but replace API Key with HuggingFace Access Token
32
+ const useProviderCard = (): ProviderItem => {
33
+ const { t } = useTranslation('modelProvider');
34
+ const { styles } = useStyles();
35
+ const isLoading = useAiInfraStore(aiProviderSelectors.isAiProviderConfigLoading(providerKey));
36
+
37
+ return {
38
+ ...VertexAIProviderCard,
39
+ apiKeyItems: [
40
+ {
41
+ children: isLoading ? (
42
+ <SkeletonInput />
43
+ ) : (
44
+ <FormPassword
45
+ autoComplete={'new-password'}
46
+ placeholder={t('vertexai.apiKey.placeholder')}
47
+ />
48
+ ),
49
+ desc: (
50
+ <Markdown className={styles.markdown} fontSize={12} variant={'chat'}>
51
+ {t('vertexai.apiKey.desc')}
52
+ </Markdown>
53
+ ),
54
+ label: t('vertexai.apiKey.title'),
55
+ name: [KeyVaultsConfigKey, LLMProviderApiTokenKey],
56
+ },
57
+ ],
58
+ };
59
+ };
60
+
61
+ const Page = () => {
62
+ const card = useProviderCard();
63
+
64
+ return <ProviderDetail {...card} />;
65
+ };
66
+
67
+ export default Page;
@@ -40,6 +40,7 @@ import { default as taichu } from './taichu';
40
40
  import { default as tencentcloud } from './tencentcloud';
41
41
  import { default as togetherai } from './togetherai';
42
42
  import { default as upstage } from './upstage';
43
+ import { default as vertexai } from './vertexai';
43
44
  import { default as vllm } from './vllm';
44
45
  import { default as volcengine } from './volcengine';
45
46
  import { default as wenxin } from './wenxin';
@@ -107,6 +108,7 @@ export const LOBE_DEFAULT_MODEL_LIST = buildDefaultModelList({
107
108
  tencentcloud,
108
109
  togetherai,
109
110
  upstage,
111
+ vertexai,
110
112
  vllm,
111
113
  volcengine,
112
114
  wenxin,
@@ -155,6 +157,7 @@ export { default as taichu } from './taichu';
155
157
  export { default as tencentcloud } from './tencentcloud';
156
158
  export { default as togetherai } from './togetherai';
157
159
  export { default as upstage } from './upstage';
160
+ export { default as vertexai } from './vertexai';
158
161
  export { default as vllm } from './vllm';
159
162
  export { default as volcengine } from './volcengine';
160
163
  export { default as wenxin } from './wenxin';
@@ -0,0 +1,200 @@
1
+ import { AIChatModelCard } from '@/types/aiModel';
2
+
3
+ // ref: https://ai.google.dev/gemini-api/docs/models/gemini
4
+ const vertexaiChatModels: AIChatModelCard[] = [
5
+ {
6
+ abilities: {
7
+ functionCall: true,
8
+ vision: true,
9
+ },
10
+ contextWindowTokens: 2_097_152 + 8192,
11
+ description:
12
+ 'Gemini 2.0 Pro Experimental 是 Google 最新的实验性多模态AI模型,与历史版本相比有一定的质量提升,特别是对于世界知识、代码和长上下文。',
13
+ displayName: 'Gemini 2.0 Pro Experimental 02-05',
14
+ enabled: true,
15
+ id: 'gemini-2.0-pro-exp-02-05',
16
+ maxOutput: 8192,
17
+ pricing: {
18
+ cachedInput: 0,
19
+ input: 0,
20
+ output: 0,
21
+ },
22
+ releasedAt: '2025-02-05',
23
+ type: 'chat',
24
+ },
25
+ {
26
+ abilities: {
27
+ functionCall: true,
28
+ vision: true,
29
+ },
30
+ contextWindowTokens: 1_048_576 + 8192,
31
+ description:
32
+ 'Gemini 2.0 Flash 提供下一代功能和改进,包括卓越的速度、原生工具使用、多模态生成和1M令牌上下文窗口。',
33
+ displayName: 'Gemini 2.0 Flash',
34
+ enabled: true,
35
+ id: 'gemini-2.0-flash',
36
+ maxOutput: 8192,
37
+ pricing: {
38
+ cachedInput: 0.025,
39
+ input: 0.1,
40
+ output: 0.4,
41
+ },
42
+ releasedAt: '2025-02-05',
43
+ type: 'chat',
44
+ },
45
+ {
46
+ abilities: {
47
+ functionCall: true,
48
+ vision: true,
49
+ },
50
+ contextWindowTokens: 1_048_576 + 8192,
51
+ description:
52
+ 'Gemini 2.0 Flash 提供下一代功能和改进,包括卓越的速度、原生工具使用、多模态生成和1M令牌上下文窗口。',
53
+ displayName: 'Gemini 2.0 Flash 001',
54
+ id: 'gemini-2.0-flash-001',
55
+ maxOutput: 8192,
56
+ pricing: {
57
+ cachedInput: 0.025,
58
+ input: 0.1,
59
+ output: 0.4,
60
+ },
61
+ releasedAt: '2025-02-05',
62
+ type: 'chat',
63
+ },
64
+ {
65
+ abilities: {
66
+ vision: true,
67
+ },
68
+ contextWindowTokens: 1_048_576 + 8192,
69
+ description: '一个 Gemini 2.0 Flash 模型,针对成本效益和低延迟等目标进行了优化。',
70
+ displayName: 'Gemini 2.0 Flash-Lite Preview 02-05',
71
+ id: 'gemini-2.0-flash-lite-preview-02-05',
72
+ maxOutput: 8192,
73
+ pricing: {
74
+ cachedInput: 0.018_75,
75
+ input: 0.075,
76
+ output: 0.3,
77
+ },
78
+ releasedAt: '2025-02-05',
79
+ type: 'chat',
80
+ },
81
+ {
82
+ abilities: {
83
+ reasoning: true,
84
+ vision: true,
85
+ },
86
+ contextWindowTokens: 1_048_576 + 65_536,
87
+ description:
88
+ 'Gemini 2.0 Flash Thinking Exp 是 Google 的实验性多模态推理AI模型,能对复杂问题进行推理,拥有新的思维能力。',
89
+ displayName: 'Gemini 2.0 Flash Thinking Experimental 01-21',
90
+ enabled: true,
91
+ id: 'gemini-2.0-flash-thinking-exp-01-21',
92
+ maxOutput: 65_536,
93
+ pricing: {
94
+ cachedInput: 0,
95
+ input: 0,
96
+ output: 0,
97
+ },
98
+ releasedAt: '2025-01-21',
99
+ type: 'chat',
100
+ },
101
+ {
102
+ abilities: { functionCall: true, vision: true },
103
+ contextWindowTokens: 1_000_000 + 8192,
104
+ description:
105
+ 'Gemini 1.5 Flash 是Google最新的多模态AI模型,具备快速处理能力,支持文本、图像和视频输入,适用于多种任务的高效扩展。',
106
+ displayName: 'Gemini 1.5 Flash',
107
+ enabled: true,
108
+ id: 'gemini-1.5-flash',
109
+ maxOutput: 8192,
110
+ pricing: {
111
+ cachedInput: 0.018_75,
112
+ input: 0.075,
113
+ output: 0.3,
114
+ },
115
+ type: 'chat',
116
+ },
117
+ {
118
+ abilities: { functionCall: true, vision: true },
119
+ contextWindowTokens: 1_000_000 + 8192,
120
+ description: 'Gemini 1.5 Flash 002 是一款高效的多模态模型,支持广泛应用的扩展。',
121
+ displayName: 'Gemini 1.5 Flash 002',
122
+ enabled: true,
123
+ id: 'gemini-1.5-flash-002',
124
+ maxOutput: 8192,
125
+ pricing: {
126
+ cachedInput: 0.018_75,
127
+ input: 0.075,
128
+ output: 0.3,
129
+ },
130
+ releasedAt: '2024-09-25',
131
+ type: 'chat',
132
+ },
133
+ {
134
+ abilities: { functionCall: true, vision: true },
135
+ contextWindowTokens: 1_000_000 + 8192,
136
+ description: 'Gemini 1.5 Flash 001 是一款高效的多模态模型,支持广泛应用的扩展。',
137
+ displayName: 'Gemini 1.5 Flash 001',
138
+ id: 'gemini-1.5-flash-001',
139
+ maxOutput: 8192,
140
+ pricing: {
141
+ cachedInput: 0.018_75,
142
+ input: 0.075,
143
+ output: 0.3,
144
+ },
145
+ type: 'chat',
146
+ },
147
+ {
148
+ abilities: { functionCall: true, vision: true },
149
+ contextWindowTokens: 2_000_000 + 8192,
150
+ description:
151
+ 'Gemini 1.5 Pro 支持高达200万个tokens,是中型多模态模型的理想选择,适用于复杂任务的多方面支持。',
152
+ displayName: 'Gemini 1.5 Pro',
153
+ enabled: true,
154
+ id: 'gemini-1.5-pro-latest',
155
+ maxOutput: 8192,
156
+ pricing: {
157
+ cachedInput: 0.875,
158
+ input: 3.5,
159
+ output: 10.5,
160
+ },
161
+ releasedAt: '2024-02-15',
162
+ type: 'chat',
163
+ },
164
+ {
165
+ abilities: { functionCall: true, vision: true },
166
+ contextWindowTokens: 2_000_000 + 8192,
167
+ description:
168
+ 'Gemini 1.5 Pro 002 是最新的生产就绪模型,提供更高质量的输出,特别在数学、长上下文和视觉任务方面有显著提升。',
169
+ displayName: 'Gemini 1.5 Pro 002',
170
+ enabled: true,
171
+ id: 'gemini-1.5-pro-002',
172
+ maxOutput: 8192,
173
+ pricing: {
174
+ cachedInput: 0.315,
175
+ input: 1.25,
176
+ output: 2.5,
177
+ },
178
+ releasedAt: '2024-09-24',
179
+ type: 'chat',
180
+ },
181
+ {
182
+ abilities: { functionCall: true, vision: true },
183
+ contextWindowTokens: 2_000_000 + 8192,
184
+ description: 'Gemini 1.5 Pro 001 是可扩展的多模态AI解决方案,支持广泛的复杂任务。',
185
+ displayName: 'Gemini 1.5 Pro 001',
186
+ id: 'gemini-1.5-pro-001',
187
+ maxOutput: 8192,
188
+ pricing: {
189
+ cachedInput: 0.875,
190
+ input: 3.5,
191
+ output: 10.5,
192
+ },
193
+ releasedAt: '2024-02-15',
194
+ type: 'chat',
195
+ },
196
+ ];
197
+
198
+ export const allModels = [...vertexaiChatModels];
199
+
200
+ export default allModels;
@@ -40,6 +40,7 @@ import TaichuProvider from './taichu';
40
40
  import TencentcloudProvider from './tencentcloud';
41
41
  import TogetherAIProvider from './togetherai';
42
42
  import UpstageProvider from './upstage';
43
+ import VertexAIProvider from './vertexai';
43
44
  import VLLMProvider from './vllm';
44
45
  import VolcengineProvider from './volcengine';
45
46
  import WenxinProvider from './wenxin';
@@ -102,6 +103,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
102
103
  AnthropicProvider,
103
104
  BedrockProvider,
104
105
  GoogleProvider,
106
+ VertexAIProvider,
105
107
  DeepSeekProvider,
106
108
  HuggingFaceProvider,
107
109
  OpenRouterProvider,
@@ -191,6 +193,7 @@ export { default as TaichuProviderCard } from './taichu';
191
193
  export { default as TencentCloudProviderCard } from './tencentcloud';
192
194
  export { default as TogetherAIProviderCard } from './togetherai';
193
195
  export { default as UpstageProviderCard } from './upstage';
196
+ export { default as VertexAIProviderCard } from './vertexai';
194
197
  export { default as VLLMProviderCard } from './vllm';
195
198
  export { default as VolcengineProviderCard } from './volcengine';
196
199
  export { default as WenxinProviderCard } from './wenxin';
@@ -0,0 +1,22 @@
1
+ import { ModelProviderCard } from '@/types/llm';
2
+
3
+ // ref: https://ai.google.dev/gemini-api/docs/models/gemini
4
+ const VertexAI: ModelProviderCard = {
5
+ chatModels: [],
6
+ checkModel: 'gemini-1.5-flash-001',
7
+ description:
8
+ 'Google 的 Gemini 系列是其最先进、通用的 AI模型,由 Google DeepMind 打造,专为多模态设计,支持文本、代码、图像、音频和视频的无缝理解与处理。适用于从数据中心到移动设备的多种环境,极大提升了AI模型的效率与应用广泛性。',
9
+ id: 'vertexai',
10
+ modelsUrl: 'https://console.cloud.google.com/vertex-ai/model-garden',
11
+ name: 'VertexAI',
12
+ settings: {
13
+ disableBrowserRequest: true,
14
+ smoothing: {
15
+ speed: 2,
16
+ text: true,
17
+ },
18
+ },
19
+ url: 'https://cloud.google.com/vertex-ai',
20
+ };
21
+
22
+ export default VertexAI;
@@ -201,7 +201,8 @@ export class DatabaseManager {
201
201
  const dbName = 'lobechat';
202
202
 
203
203
  // make db as web worker if worker is available
204
- if (typeof Worker !== 'undefined') {
204
+ // https://github.com/lobehub/lobe-chat/issues/5785
205
+ if (typeof Worker !== 'undefined' && typeof navigator.locks !== 'undefined') {
205
206
  db = await initPgliteWorker({
206
207
  dbName,
207
208
  fsBundle: fsBundle as Blob,
@@ -13,6 +13,7 @@ export const AgentRuntimeErrorType = {
13
13
  OllamaBizError: 'OllamaBizError',
14
14
 
15
15
  InvalidBedrockCredentials: 'InvalidBedrockCredentials',
16
+ InvalidVertexCredentials: 'InvalidVertexCredentials',
16
17
  StreamChunkError: 'StreamChunkError',
17
18
 
18
19
  InvalidGithubToken: 'InvalidGithubToken',
@@ -1,3 +1,4 @@
1
+ import type { VertexAI } from '@google-cloud/vertexai';
1
2
  import {
2
3
  Content,
3
4
  FunctionCallPart,
@@ -9,6 +10,7 @@ import {
9
10
  } from '@google/generative-ai';
10
11
 
11
12
  import type { ChatModelCard } from '@/types/llm';
13
+ import { VertexAIStream } from '@/libs/agent-runtime/utils/streams/vertex-ai';
12
14
  import { imageUrlToBase64 } from '@/utils/imageToBase64';
13
15
  import { safeParseJSON } from '@/utils/safeParseJSON';
14
16
 
@@ -56,17 +58,27 @@ function getThreshold(model: string): HarmBlockThreshold {
56
58
 
57
59
  const DEFAULT_BASE_URL = 'https://generativelanguage.googleapis.com';
58
60
 
61
+ interface LobeGoogleAIParams {
62
+ apiKey?: string;
63
+ baseURL?: string;
64
+ client?: GoogleGenerativeAI | VertexAI;
65
+ isVertexAi?: boolean;
66
+ }
67
+
59
68
  export class LobeGoogleAI implements LobeRuntimeAI {
60
69
  private client: GoogleGenerativeAI;
70
+ private isVertexAi: boolean;
61
71
  baseURL?: string;
62
72
  apiKey?: string;
63
73
 
64
- constructor({ apiKey, baseURL }: { apiKey?: string; baseURL?: string } = {}) {
74
+ constructor({ apiKey, baseURL, client, isVertexAi }: LobeGoogleAIParams = {}) {
65
75
  if (!apiKey) throw AgentRuntimeError.createError(AgentRuntimeErrorType.InvalidProviderAPIKey);
66
76
 
67
77
  this.client = new GoogleGenerativeAI(apiKey);
68
- this.baseURL = baseURL || DEFAULT_BASE_URL;
69
78
  this.apiKey = apiKey;
79
+ this.client = client ? (client as GoogleGenerativeAI) : new GoogleGenerativeAI(apiKey);
80
+ this.baseURL = client ? undefined : baseURL || DEFAULT_BASE_URL;
81
+ this.isVertexAi = isVertexAi || false;
70
82
  }
71
83
 
72
84
  async chat(rawPayload: ChatStreamPayload, options?: ChatCompetitionOptions) {
@@ -117,18 +129,24 @@ export class LobeGoogleAI implements LobeRuntimeAI {
117
129
  const googleStream = convertIterableToStream(geminiStreamResult.stream);
118
130
  const [prod, useForDebug] = googleStream.tee();
119
131
 
120
- if (process.env.DEBUG_GOOGLE_CHAT_COMPLETION === '1') {
132
+ const key = this.isVertexAi
133
+ ? 'DEBUG_VERTEX_AI_CHAT_COMPLETION'
134
+ : 'DEBUG_GOOGLE_CHAT_COMPLETION';
135
+
136
+ if (process.env[key] === '1') {
121
137
  debugStream(useForDebug).catch();
122
138
  }
123
139
 
124
140
  // Convert the response into a friendly text-stream
125
- const stream = GoogleGenerativeAIStream(prod, options?.callback);
141
+ const Stream = this.isVertexAi ? VertexAIStream : GoogleGenerativeAIStream;
142
+ const stream = Stream(prod, options?.callback);
126
143
 
127
144
  // Respond with the stream
128
145
  return StreamingResponse(stream, { headers: options?.headers });
129
146
  } catch (e) {
130
147
  const err = e as Error;
131
148
 
149
+ console.log(err);
132
150
  const { errorType, error } = this.parseErrorMessage(err.message);
133
151
 
134
152
  throw AgentRuntimeError.chat({ error, errorType, provider: ModelProvider.Google });
@@ -66,6 +66,7 @@ export enum ModelProvider {
66
66
  TogetherAI = 'togetherai',
67
67
  Upstage = 'upstage',
68
68
  VLLM = 'vllm',
69
+ VertexAI = 'vertexai',
69
70
  Volcengine = 'volcengine',
70
71
  Wenxin = 'wenxin',
71
72
  XAI = 'xai',