@lobehub/chat 1.60.9 → 1.61.1

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 (101) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/changelog/v1.json +21 -0
  3. package/locales/ar/error.json +4 -1
  4. package/locales/ar/modelProvider.json +7 -0
  5. package/locales/ar/models.json +3 -12
  6. package/locales/ar/providers.json +3 -0
  7. package/locales/bg-BG/error.json +4 -1
  8. package/locales/bg-BG/modelProvider.json +7 -0
  9. package/locales/bg-BG/models.json +3 -12
  10. package/locales/bg-BG/providers.json +3 -0
  11. package/locales/de-DE/error.json +4 -1
  12. package/locales/de-DE/modelProvider.json +7 -0
  13. package/locales/de-DE/models.json +3 -12
  14. package/locales/de-DE/providers.json +3 -0
  15. package/locales/en-US/error.json +4 -1
  16. package/locales/en-US/modelProvider.json +7 -0
  17. package/locales/en-US/models.json +3 -12
  18. package/locales/en-US/providers.json +3 -0
  19. package/locales/es-ES/error.json +4 -1
  20. package/locales/es-ES/modelProvider.json +7 -0
  21. package/locales/es-ES/models.json +3 -12
  22. package/locales/es-ES/providers.json +3 -0
  23. package/locales/fa-IR/error.json +4 -1
  24. package/locales/fa-IR/modelProvider.json +7 -0
  25. package/locales/fa-IR/models.json +3 -12
  26. package/locales/fa-IR/providers.json +3 -0
  27. package/locales/fr-FR/error.json +4 -1
  28. package/locales/fr-FR/modelProvider.json +7 -0
  29. package/locales/fr-FR/models.json +3 -12
  30. package/locales/fr-FR/providers.json +3 -0
  31. package/locales/it-IT/error.json +4 -1
  32. package/locales/it-IT/modelProvider.json +7 -0
  33. package/locales/it-IT/models.json +3 -12
  34. package/locales/it-IT/providers.json +3 -0
  35. package/locales/ja-JP/error.json +4 -1
  36. package/locales/ja-JP/modelProvider.json +7 -0
  37. package/locales/ja-JP/models.json +3 -12
  38. package/locales/ja-JP/providers.json +3 -0
  39. package/locales/ko-KR/error.json +4 -1
  40. package/locales/ko-KR/modelProvider.json +7 -0
  41. package/locales/ko-KR/models.json +3 -12
  42. package/locales/ko-KR/providers.json +3 -0
  43. package/locales/nl-NL/error.json +4 -1
  44. package/locales/nl-NL/modelProvider.json +7 -0
  45. package/locales/nl-NL/models.json +3 -12
  46. package/locales/nl-NL/providers.json +3 -0
  47. package/locales/pl-PL/error.json +4 -1
  48. package/locales/pl-PL/modelProvider.json +7 -0
  49. package/locales/pl-PL/models.json +3 -12
  50. package/locales/pl-PL/providers.json +3 -0
  51. package/locales/pt-BR/error.json +4 -1
  52. package/locales/pt-BR/modelProvider.json +7 -0
  53. package/locales/pt-BR/models.json +3 -12
  54. package/locales/pt-BR/providers.json +3 -0
  55. package/locales/ru-RU/error.json +4 -1
  56. package/locales/ru-RU/modelProvider.json +7 -0
  57. package/locales/ru-RU/models.json +3 -12
  58. package/locales/ru-RU/providers.json +3 -0
  59. package/locales/tr-TR/error.json +4 -1
  60. package/locales/tr-TR/modelProvider.json +7 -0
  61. package/locales/tr-TR/models.json +3 -12
  62. package/locales/tr-TR/providers.json +3 -0
  63. package/locales/vi-VN/error.json +4 -1
  64. package/locales/vi-VN/modelProvider.json +7 -0
  65. package/locales/vi-VN/models.json +3 -12
  66. package/locales/vi-VN/providers.json +3 -0
  67. package/locales/zh-CN/error.json +5 -2
  68. package/locales/zh-CN/modelProvider.json +7 -0
  69. package/locales/zh-CN/models.json +3 -12
  70. package/locales/zh-CN/providers.json +3 -0
  71. package/locales/zh-TW/error.json +4 -1
  72. package/locales/zh-TW/modelProvider.json +7 -0
  73. package/locales/zh-TW/models.json +3 -12
  74. package/locales/zh-TW/providers.json +3 -0
  75. package/package.json +2 -1
  76. package/src/app/(backend)/middleware/auth/index.ts +14 -1
  77. package/src/app/(backend)/webapi/chat/vertexai/route.ts +35 -0
  78. package/src/app/[variants]/(main)/settings/provider/(detail)/huggingface/page.tsx +3 -3
  79. package/src/app/[variants]/(main)/settings/provider/(detail)/vertexai/page.tsx +67 -0
  80. package/src/config/aiModels/index.ts +3 -0
  81. package/src/config/aiModels/vertexai.ts +200 -0
  82. package/src/config/modelProviders/index.ts +3 -0
  83. package/src/config/modelProviders/vertexai.ts +22 -0
  84. package/src/database/client/db.ts +2 -1
  85. package/src/features/Conversation/Error/index.tsx +3 -5
  86. package/src/features/Conversation/Messages/User/MarkdownRender/ContentPreview.tsx +6 -0
  87. package/src/libs/agent-runtime/error.ts +5 -4
  88. package/src/libs/agent-runtime/google/index.ts +22 -4
  89. package/src/libs/agent-runtime/types/type.ts +1 -0
  90. package/src/libs/agent-runtime/utils/openaiCompatibleFactory/index.ts +22 -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 +5 -4
  95. package/src/locales/default/modelProvider.ts +7 -0
  96. package/src/types/fetch.ts +1 -0
  97. package/src/types/user/settings/keyVaults.ts +1 -0
  98. package/src/utils/errorResponse.test.ts +0 -12
  99. package/src/utils/errorResponse.ts +7 -2
  100. package/src/utils/safeParseJSON.ts +1 -1
  101. package/src/features/Conversation/Error/OpenAiBizError.tsx +0 -29
@@ -371,9 +371,6 @@
371
371
  "abab6.5t-chat": {
372
372
  "description": "Tối ưu hóa cho các tình huống đối thoại bằng tiếng Trung, cung cấp khả năng sinh đối thoại mượt mà và phù hợp với thói quen diễn đạt tiếng Trung."
373
373
  },
374
- "abab7-chat-preview": {
375
- "description": "So với các mô hình trong series abab6.5, khả năng xử lý văn bản dài, toán học, viết lách, v.v. đã được cải thiện đáng kể."
376
- },
377
374
  "accounts/fireworks/models/deepseek-r1": {
378
375
  "description": "DeepSeek-R1 là một mô hình ngôn ngữ lớn tiên tiến, được tối ưu hóa thông qua học tăng cường và dữ liệu khởi động lạnh, có hiệu suất suy luận, toán học và lập trình xuất sắc."
379
376
  },
@@ -728,6 +725,9 @@
728
725
  "gemini-1.0-pro-latest": {
729
726
  "description": "Gemini 1.0 Pro là mô hình AI hiệu suất cao của Google, được thiết kế để mở rộng cho nhiều nhiệm vụ."
730
727
  },
728
+ "gemini-1.5-flash": {
729
+ "description": "Gemini 1.5 Flash là mô hình AI đa phương thức mới nhất của Google, có khả năng xử lý nhanh, hỗ trợ đầu vào văn bản, hình ảnh và video, phù hợp cho việc mở rộng hiệu quả cho nhiều nhiệm vụ."
730
+ },
731
731
  "gemini-1.5-flash-001": {
732
732
  "description": "Gemini 1.5 Flash 001 là một mô hình đa phương thức hiệu quả, hỗ trợ mở rộng cho nhiều ứng dụng."
733
733
  },
@@ -767,24 +767,15 @@
767
767
  "gemini-2.0-flash-001": {
768
768
  "description": "Gemini 2.0 Flash cung cấp các tính năng và cải tiến thế hệ tiếp theo, bao gồm tốc độ vượt trội, sử dụng công cụ bản địa, tạo đa phương tiện và cửa sổ ngữ cảnh 1M token."
769
769
  },
770
- "gemini-2.0-flash-exp": {
771
- "description": "Gemini 2.0 Flash Exp là mô hình AI đa phương thức thử nghiệm mới nhất của Google, có các tính năng thế hệ tiếp theo, tốc độ vượt trội, khả năng gọi công cụ nguyên bản và tạo ra đa phương thức."
772
- },
773
770
  "gemini-2.0-flash-lite-preview-02-05": {
774
771
  "description": "Một mô hình Gemini 2.0 Flash được tối ưu hóa cho hiệu quả chi phí và độ trễ thấp."
775
772
  },
776
773
  "gemini-2.0-flash-thinking-exp-01-21": {
777
774
  "description": "Gemini 2.0 Flash Exp là mô hình AI đa phương thức thử nghiệm mới nhất của Google, sở hữu các tính năng thế hệ tiếp theo, tốc độ vượt trội, gọi công cụ bản địa và sinh ra đa phương thức."
778
775
  },
779
- "gemini-2.0-flash-thinking-exp-1219": {
780
- "description": "Gemini 2.0 Flash Exp là mô hình AI đa phương thức thử nghiệm mới nhất của Google, với các tính năng thế hệ tiếp theo, tốc độ vượt trội, gọi công cụ bản địa và tạo ra đa phương thức."
781
- },
782
776
  "gemini-2.0-pro-exp-02-05": {
783
777
  "description": "Gemini 2.0 Pro Experimental là mô hình AI đa phương tiện thử nghiệm mới nhất của Google, có sự cải thiện chất lượng nhất định so với các phiên bản trước, đặc biệt là về kiến thức thế giới, mã và ngữ cảnh dài."
784
778
  },
785
- "gemini-exp-1206": {
786
- "description": "Gemini Exp 1206 là mô hình AI đa phương tiện thử nghiệm mới nhất của Google, có sự cải thiện về chất lượng so với các phiên bản trước."
787
- },
788
779
  "gemma-7b-it": {
789
780
  "description": "Gemma 7B phù hợp cho việc xử lý các nhiệm vụ quy mô vừa và nhỏ, đồng thời mang lại hiệu quả chi phí."
790
781
  },
@@ -119,6 +119,9 @@
119
119
  "upstage": {
120
120
  "description": "Upstage tập trung vào việc phát triển các mô hình AI cho nhiều nhu cầu thương mại khác nhau, bao gồm Solar LLM và AI tài liệu, nhằm đạt được trí thông minh nhân tạo tổng quát (AGI) cho công việc. Tạo ra các đại lý đối thoại đơn giản thông qua Chat API, và hỗ trợ gọi chức năng, dịch thuật, nhúng và ứng dụng trong các lĩnh vực cụ thể."
121
121
  },
122
+ "vertexai": {
123
+ "description": "Dòng sản phẩm Gemini của Google là mô hình AI tiên tiến và đa năng nhất của họ, được phát triển bởi Google DeepMind, được thiết kế đặc biệt cho đa phương thức, hỗ trợ hiểu và xử lý liền mạch văn bản, mã, hình ảnh, âm thanh và video. Phù hợp với nhiều môi trường từ trung tâm dữ liệu đến thiết bị di động, nâng cao đáng kể hiệu quả và tính ứng dụng của mô hình AI."
124
+ },
122
125
  "vllm": {
123
126
  "description": "vLLM là một thư viện nhanh chóng và dễ sử dụng cho suy diễn và dịch vụ LLM."
124
127
  },
@@ -82,13 +82,16 @@
82
82
  "PluginFailToTransformArguments": "很抱歉,插件调用参数解析失败,请尝试重新生成助手消息,或更换 Tools Calling 能力更强的 AI 模型后重试",
83
83
  "InvalidAccessCode": "密码不正确或为空,请输入正确的访问密码,或者添加自定义 API Key",
84
84
  "InvalidClerkUser": "很抱歉,你当前尚未登录,请先登录或注册账号后继续操作",
85
+ "SystemTimeNotMatchError": "很抱歉,您的系统时间和服务器不匹配,请检查您的系统时间后重试",
85
86
  "LocationNotSupportError": "很抱歉,你的所在地区不支持此模型服务,可能是由于区域限制或服务未开通。请确认当前地区是否支持使用此服务,或尝试使用切换到其他地区后重试。",
87
+ "InsufficientQuota": "很抱歉,该密钥的配额(quota)已达上限,请检查账户余额是否充足,或增大密钥配额后再试",
88
+ "ExceededContextWindow": "当前请求内容超出模型可处理的长度,请减少内容量后重试",
86
89
  "QuotaLimitReached": "很抱歉,当前 Token 用量或请求次数已达该密钥的配额(quota)上限,请增加该密钥的配额或稍后再试",
87
90
  "PermissionDenied": "很抱歉,你没有权限访问该服务,请检查你的密钥是否有访问权限",
88
91
  "InvalidProviderAPIKey": "{{provider}} API Key 不正确或为空,请检查 {{provider}} API Key 后重试",
89
92
  "ProviderBizError": "请求 {{provider}} 服务出错,请根据以下信息排查或重试",
90
93
  "NoOpenAIAPIKey": "OpenAI API Key 不正确或为空,请添加自定义 OpenAI API Key",
91
- "OpenAIBizError": "请求 OpenAI 服务出错,请根据以下信息排查或重试",
94
+ "InvalidVertexCredentials": "Vertex 鉴权未通过,请检查鉴权凭证后重试",
92
95
  "InvalidBedrockCredentials": "Bedrock 鉴权未通过,请检查 AccessKeyId/SecretAccessKey 后重试",
93
96
  "StreamChunkError": "流式请求的消息块解析错误,请检查当前 API 接口是否符合标准规范,或联系你的 API 供应商咨询",
94
97
  "UnknownChatFetchError": "很抱歉,遇到未知请求错误,请根据以下信息排查或重试",
@@ -139,4 +142,4 @@
139
142
  "unknownError": "错误原因: {{reason}}",
140
143
  "uploadFailed": "文件上传失败"
141
144
  }
142
- }
145
+ }
@@ -322,6 +322,13 @@
322
322
  "tooltip": "更新服务商基础配置",
323
323
  "updateSuccess": "更新成功"
324
324
  },
325
+ "vertexai": {
326
+ "apiKey": {
327
+ "desc": "填入你的 Vertex Ai Keys",
328
+ "placeholder": "{ \"type\": \"service_account\", \"project_id\": \"xxx\", \"private_key_id\": ... }",
329
+ "title": "Vertex AI Keys"
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 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
  },
@@ -69,18 +69,20 @@
69
69
  "524": "很抱歉,伺服器在等待回覆時超時,可能是因為回應太慢,請稍後再試",
70
70
  "AgentRuntimeError": "Lobe 語言模型運行時執行出錯,請根據以下信息排查或重試",
71
71
  "ConnectionCheckFailed": "請求返回為空,請檢查 API 代理地址末尾是否未包含 `/v1`",
72
+ "ExceededContextWindow": "當前請求內容超出模型可處理的長度,請減少內容量後重試",
72
73
  "FreePlanLimit": "目前為免費用戶,無法使用該功能,請升級到付費計劃後繼續使用",
74
+ "InsufficientQuota": "很抱歉,該金鑰的配額已達上限,請檢查帳戶餘額是否充足,或增加金鑰配額後再試",
73
75
  "InvalidAccessCode": "密碼不正確或為空,請輸入正確的訪問密碼,或添加自定義 API 金鑰",
74
76
  "InvalidBedrockCredentials": "Bedrock 驗證未通過,請檢查 AccessKeyId/SecretAccessKey 後重試",
75
77
  "InvalidClerkUser": "很抱歉,你當前尚未登錄,請先登錄或註冊帳號後繼續操作",
76
78
  "InvalidGithubToken": "Github 個人存取權杖不正確或為空,請檢查 Github 個人存取權杖後再試一次",
77
79
  "InvalidOllamaArgs": "Ollama 配置不正確,請檢查 Ollama 配置後重試",
78
80
  "InvalidProviderAPIKey": "{{provider}} API 金鑰不正確或為空,請檢查 {{provider}} API 金鑰後重試",
81
+ "InvalidVertexCredentials": "Vertex 認證未通過,請檢查認證憑證後重試",
79
82
  "LocationNotSupportError": "很抱歉,你的所在位置不支持此模型服務,可能是由於地區限制或服務未開通。請確認當前位置是否支持使用此服務,或嘗試使用其他位置信息。",
80
83
  "NoOpenAIAPIKey": "OpenAI API 金鑰為空,請添加自訂 OpenAI API 金鑰",
81
84
  "OllamaBizError": "請求 Ollama 服務出錯,請根據以下資訊排查或重試",
82
85
  "OllamaServiceUnavailable": "Ollama 服務暫時無法使用,請檢查 Ollama 是否運作正常,或是否正確設定 Ollama 的跨域配置",
83
- "OpenAIBizError": "請求 OpenAI 服務出錯,請根據以下資訊排查或重試",
84
86
  "PermissionDenied": "很抱歉,您沒有權限訪問該服務,請檢查您的金鑰是否具有訪問權限",
85
87
  "PluginApiNotFound": "抱歉,外掛描述檔案中不存在該 API。請檢查您的請求方法與外掛清單 API 是否相符",
86
88
  "PluginApiParamsError": "抱歉,該外掛請求的輸入參數驗證失敗。請檢查輸入參數與 API 描述資訊是否相符",
@@ -99,6 +101,7 @@
99
101
  "QuotaLimitReached": "很抱歉,當前 Token 用量或請求次數已達該金鑰的配額上限,請增加該金鑰的配額或稍後再試",
100
102
  "StreamChunkError": "流式請求的消息塊解析錯誤,請檢查當前 API 介面是否符合標準規範,或聯繫你的 API 供應商諮詢",
101
103
  "SubscriptionPlanLimit": "您的訂閱額度已用盡,無法使用該功能,請升級到更高的計劃,或購買資源包後繼續使用",
104
+ "SystemTimeNotMatchError": "很抱歉,您的系統時間與伺服器不匹配,請檢查您的系統時間後重試",
102
105
  "UnknownChatFetchError": "很抱歉,遇到未知請求錯誤,請根據以下資訊排查或重試"
103
106
  },
104
107
  "stt": {
@@ -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.9",
3
+ "version": "1.61.1",
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",
@@ -48,6 +48,20 @@ export const checkAuth =
48
48
  nextAuthAuthorized: oauthAuthorized,
49
49
  });
50
50
  } catch (e) {
51
+ const params = await options.params;
52
+
53
+ // if the error is not a ChatCompletionErrorPayload, it means the application error
54
+ if (!(e as ChatCompletionErrorPayload).errorType) {
55
+ if ((e as any).code === 'ERR_JWT_EXPIRED')
56
+ return createErrorResponse(ChatErrorType.SystemTimeNotMatchError, e);
57
+
58
+ // other issue will be internal server error
59
+ return createErrorResponse(ChatErrorType.InternalServerError, {
60
+ error: e,
61
+ provider: params?.provider,
62
+ });
63
+ }
64
+
51
65
  const {
52
66
  errorType = ChatErrorType.InternalServerError,
53
67
  error: errorContent,
@@ -56,7 +70,6 @@ export const checkAuth =
56
70
 
57
71
  const error = errorContent || e;
58
72
 
59
- const params = await options.params;
60
73
  return createErrorResponse(errorType, { error, ...res, provider: params?.provider });
61
74
  }
62
75
 
@@ -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;