@lobehub/chat 0.136.0 → 0.138.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 (112) hide show
  1. package/.env.example +11 -5
  2. package/CHANGELOG.md +50 -0
  3. package/README.md +8 -8
  4. package/README.zh-CN.md +8 -8
  5. package/docs/self-hosting/advanced/authentication.mdx +6 -7
  6. package/docs/self-hosting/advanced/authentication.zh-CN.mdx +6 -7
  7. package/docs/self-hosting/advanced/sso-providers/auth0.mdx +13 -14
  8. package/docs/self-hosting/advanced/sso-providers/auth0.zh-CN.mdx +13 -13
  9. package/docs/self-hosting/advanced/sso-providers/microsoft-entra-id.mdx +16 -21
  10. package/docs/self-hosting/advanced/sso-providers/microsoft-entra-id.zh-CN.mdx +39 -40
  11. package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +1 -1
  12. package/docs/self-hosting/environment-variables/model-provider.mdx +9 -4
  13. package/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx +9 -3
  14. package/docs/self-hosting/start.mdx +1 -9
  15. package/docs/usage/features/agent-market.mdx +1 -1
  16. package/docs/usage/features/tts.mdx +0 -3
  17. package/docs/usage/features/vision.mdx +0 -1
  18. package/docs/usage/providers/ollama/gemma.mdx +0 -1
  19. package/docs/usage/providers/ollama.mdx +0 -3
  20. package/docs/usage/start.mdx +1 -1
  21. package/docs/usage/start.zh-CN.mdx +1 -1
  22. package/locales/ar/common.json +1 -0
  23. package/locales/ar/error.json +14 -0
  24. package/locales/ar/setting.json +17 -1
  25. package/locales/de-DE/common.json +1 -0
  26. package/locales/de-DE/error.json +14 -0
  27. package/locales/de-DE/setting.json +17 -1
  28. package/locales/en-US/common.json +1 -0
  29. package/locales/en-US/error.json +14 -0
  30. package/locales/en-US/setting.json +17 -1
  31. package/locales/es-ES/common.json +1 -0
  32. package/locales/es-ES/error.json +14 -0
  33. package/locales/es-ES/setting.json +17 -1
  34. package/locales/fr-FR/common.json +1 -0
  35. package/locales/fr-FR/error.json +14 -0
  36. package/locales/fr-FR/setting.json +17 -1
  37. package/locales/it-IT/common.json +1 -0
  38. package/locales/it-IT/error.json +14 -0
  39. package/locales/it-IT/setting.json +17 -1
  40. package/locales/ja-JP/common.json +1 -0
  41. package/locales/ja-JP/error.json +14 -0
  42. package/locales/ja-JP/setting.json +17 -1
  43. package/locales/ko-KR/common.json +1 -0
  44. package/locales/ko-KR/error.json +14 -0
  45. package/locales/ko-KR/setting.json +17 -1
  46. package/locales/nl-NL/common.json +1 -0
  47. package/locales/nl-NL/error.json +14 -0
  48. package/locales/nl-NL/setting.json +17 -1
  49. package/locales/pl-PL/common.json +1 -0
  50. package/locales/pl-PL/error.json +14 -0
  51. package/locales/pl-PL/setting.json +17 -1
  52. package/locales/pt-BR/common.json +1 -0
  53. package/locales/pt-BR/error.json +14 -0
  54. package/locales/pt-BR/setting.json +17 -1
  55. package/locales/ru-RU/common.json +1 -0
  56. package/locales/ru-RU/error.json +14 -0
  57. package/locales/ru-RU/setting.json +17 -1
  58. package/locales/tr-TR/common.json +1 -0
  59. package/locales/tr-TR/error.json +14 -0
  60. package/locales/tr-TR/setting.json +17 -1
  61. package/locales/vi-VN/common.json +1 -0
  62. package/locales/vi-VN/error.json +14 -0
  63. package/locales/vi-VN/setting.json +17 -1
  64. package/locales/zh-CN/common.json +1 -0
  65. package/locales/zh-CN/error.json +14 -0
  66. package/locales/zh-CN/setting.json +17 -1
  67. package/locales/zh-TW/common.json +1 -0
  68. package/locales/zh-TW/error.json +14 -0
  69. package/locales/zh-TW/setting.json +17 -1
  70. package/package.json +2 -1
  71. package/src/app/api/chat/[provider]/agentRuntime.ts +15 -2
  72. package/src/app/api/config/route.ts +5 -2
  73. package/src/app/api/errorResponse.ts +5 -1
  74. package/src/app/settings/llm/Groq/index.tsx +47 -0
  75. package/src/app/settings/llm/Ollama/Checker.tsx +73 -0
  76. package/src/app/settings/llm/Ollama/index.tsx +2 -4
  77. package/src/app/settings/llm/components/Checker.tsx +23 -17
  78. package/src/app/settings/llm/index.tsx +2 -0
  79. package/src/components/ModelIcon/index.tsx +2 -0
  80. package/src/components/ModelProviderIcon/index.tsx +5 -0
  81. package/src/components/ModelTag/ModelIcon.tsx +2 -0
  82. package/src/config/modelProviders/groq.ts +24 -0
  83. package/src/config/modelProviders/index.ts +3 -0
  84. package/src/config/modelProviders/ollama.ts +14 -0
  85. package/src/config/server/provider.ts +13 -3
  86. package/src/const/settings.ts +4 -0
  87. package/src/features/Conversation/Error/APIKeyForm/Groq.tsx +60 -0
  88. package/src/features/Conversation/Error/APIKeyForm/index.tsx +5 -0
  89. package/src/features/Conversation/Error/InvalidOllamaModel/index.tsx +138 -0
  90. package/src/features/Conversation/Error/InvalidOllamaModel/useDownloadMonitor.ts +48 -0
  91. package/src/features/Conversation/Error/OllamaBizError.tsx +34 -0
  92. package/src/features/Conversation/Error/index.tsx +6 -0
  93. package/src/features/Conversation/Error/style.tsx +2 -2
  94. package/src/features/Conversation/components/ChatItem/index.tsx +2 -1
  95. package/src/libs/agent-runtime/error.ts +3 -0
  96. package/src/libs/agent-runtime/groq/index.ts +78 -0
  97. package/src/libs/agent-runtime/index.ts +1 -0
  98. package/src/libs/agent-runtime/types/type.ts +1 -0
  99. package/src/locales/default/common.ts +1 -0
  100. package/src/locales/default/error.ts +15 -0
  101. package/src/locales/default/setting.ts +17 -1
  102. package/src/services/__tests__/ollama.test.ts +26 -0
  103. package/src/services/_auth.ts +5 -1
  104. package/src/services/ollama.ts +64 -0
  105. package/src/store/global/slices/settings/selectors/modelProvider.ts +25 -15
  106. package/src/store/middleware/createHyperStorage/index.ts +1 -2
  107. package/src/store/middleware/createHyperStorage/indexedDB.ts +1 -1
  108. package/src/store/middleware/createHyperStorage/localStorage.ts +1 -1
  109. package/src/store/middleware/createHyperStorage/urlStorage.ts +1 -1
  110. package/src/types/fetch.ts +1 -0
  111. package/src/types/settings/modelProvider.ts +6 -0
  112. package/tsconfig.json +1 -1
@@ -99,6 +99,14 @@
99
99
  "title": "API Anahtarı"
100
100
  }
101
101
  },
102
+ "Groq": {
103
+ "title": "Groq",
104
+ "token": {
105
+ "desc": "Groq'dan alınan API Anahtarını girin",
106
+ "placeholder": "Groq API Anahtarı",
107
+ "title": "API Anahtarı"
108
+ }
109
+ },
102
110
  "Mistral": {
103
111
  "title": "Mistral AI",
104
112
  "token": {
@@ -193,6 +201,14 @@
193
201
  },
194
202
  "waitingForMore": "Daha fazla model eklenmesi planlanıyor ✨"
195
203
  },
204
+ "ollama": {
205
+ "download": {
206
+ "desc": "Ollama bu modeli indiriyor, lütfen bu sayfayı kapatmamaya çalışın. Yeniden indirme durumunda kaldığı yerden devam edecektir.",
207
+ "remainingTime": "Kalan Zaman",
208
+ "speed": "İndirme Hızı",
209
+ "title": "{{model}} Modeli İndiriliyor"
210
+ }
211
+ },
196
212
  "plugin": {
197
213
  "addTooltip": "Eklenti Ekle",
198
214
  "clearDeprecated": "Kullanım Dışı Eklentileri Kaldır",
@@ -428,4 +444,4 @@
428
444
  },
429
445
  "title": "Uzantı Araçları"
430
446
  }
431
- }
447
+ }
@@ -104,6 +104,7 @@
104
104
  "azure": "Azure",
105
105
  "bedrock": "AWS Bedrock",
106
106
  "google": "Google",
107
+ "groq": "Groq",
107
108
  "mistral": "Mistral AI",
108
109
  "moonshot": "Moonshot AI",
109
110
  "ollama": "Ollama",
@@ -38,11 +38,13 @@
38
38
  "AzureBizError": "Yêu cầu dịch vụ Azure AI gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
39
39
  "BedrockBizError": "Yêu cầu dịch vụ Bedrock gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
40
40
  "GoogleBizError": "Yêu cầu dịch vụ Google gặp lỗi, vui lòng kiểm tra và thử lại dựa trên thông tin dưới đây",
41
+ "GroqBizError": "Yêu cầu dịch vụ Groq gặp sự cố, vui lòng kiểm tra thông tin bên dưới hoặc thử lại",
41
42
  "InvalidAccessCode": "Mật khẩu truy cập không hợp lệ hoặc trống, vui lòng nhập mật khẩu truy cập đúng hoặc thêm Khóa API tùy chỉnh",
42
43
  "InvalidAnthropicAPIKey": "Khóa API Anthropic không hợp lệ hoặc trống, vui lòng kiểm tra lại và thử lại",
43
44
  "InvalidAzureAPIKey": "Khóa API Azure không chính xác hoặc trống, vui lòng kiểm tra lại Khóa API Azure và thử lại",
44
45
  "InvalidBedrockCredentials": "Xác thực Bedrock không thành công, vui lòng kiểm tra AccessKeyId/SecretAccessKey và thử lại",
45
46
  "InvalidGoogleAPIKey": "Khóa API Google không chính xác hoặc trống, vui lòng kiểm tra lại Khóa API Google và thử lại",
47
+ "InvalidGroqAPIKey": "Khóa API Groq không hợp lệ hoặc trống, vui lòng kiểm tra lại Khóa API Groq và thử lại",
46
48
  "InvalidMistralAPIKey": "Mistral AI API Key không hợp lệ hoặc trống, vui lòng kiểm tra lại Mistral API Key và thử lại",
47
49
  "InvalidMoonshotAPIKey": "Khóa API Moonshot AI không hợp lệ hoặc trống, vui lòng kiểm tra lại Khóa API Moonshot và thử lại",
48
50
  "InvalidOllamaArgs": "Cấu hình Ollama không hợp lệ, vui lòng kiểm tra lại cấu hình Ollama và thử lại",
@@ -53,6 +55,7 @@
53
55
  "MoonshotBizError": "Yêu cầu dịch vụ Mặt Trăng Tối gặp sự cố, vui lòng kiểm tra thông tin dưới đây hoặc thử lại",
54
56
  "NoOpenAIAPIKey": "Khóa API OpenAI trống, vui lòng thêm Khóa API OpenAI tùy chỉnh",
55
57
  "OllamaBizError": "Yêu cầu dịch vụ Ollama gặp lỗi, vui lòng kiểm tra thông tin dưới đây hoặc thử lại",
58
+ "OllamaServiceUnavailable": "Dịch vụ Ollama không khả dụng, vui lòng kiểm tra xem nó đã được khởi động chưa",
56
59
  "OpenAIBizError": "Yêu cầu dịch vụ OpenAI gặp lỗi, vui lòng xác minh hoặc thử lại dựa trên thông tin dưới đây",
57
60
  "PerplexityBizError": "Yêu cầu dịch vụ AI Perplexity gặp lỗi, vui lòng kiểm tra thông tin dưới đây hoặc thử lại sau",
58
61
  "PluginApiNotFound": "Xin lỗi, không có API nào trong tệp mô tả plugin, vui lòng kiểm tra phương thức yêu cầu của bạn có khớp với API mô tả plugin không",
@@ -90,6 +93,10 @@
90
93
  "description": "Nhập Google API Key của bạn để bắt đầu phiên làm việc. Ứng dụng sẽ không lưu trữ API Key của bạn",
91
94
  "title": "Sử dụng thông tin xác thực tùy chỉnh của Google"
92
95
  },
96
+ "Groq": {
97
+ "description": "Nhập Groq API Key của bạn để bắt đầu phiên làm việc. Ứng dụng sẽ không lưu trữ API Key của bạn",
98
+ "title": "Sử dụng Groq API Key tùy chỉnh"
99
+ },
93
100
  "Mistral": {
94
101
  "description": "Nhập Mistral AI API Key của bạn để bắt đầu phiên làm việc. Ứng dụng sẽ không lưu trữ API Key của bạn",
95
102
  "title": "Sử dụng Mistral AI API Key tùy chỉnh"
@@ -114,6 +121,13 @@
114
121
  },
115
122
  "closeMessage": "Đóng thông báo",
116
123
  "confirm": "Xác nhận và thử lại",
124
+ "model": {
125
+ "Ollama": {
126
+ "confirm": "Tải xuống",
127
+ "description": "Nhập nhãn mô hình Ollama của bạn để tiếp tục cuộc trò chuyện",
128
+ "title": "Tải xuống mô hình Ollama cụ thể"
129
+ }
130
+ },
117
131
  "oauth": {
118
132
  "description": "Quản trị viên đã mở tính năng xác thực đăng nhập thống nhất. Nhấn vào nút bên dưới để đăng nhập và mở khóa ứng dụng",
119
133
  "success": "Đăng nhập thành công",
@@ -99,6 +99,14 @@
99
99
  "title": "API Key"
100
100
  }
101
101
  },
102
+ "Groq": {
103
+ "title": "Groq",
104
+ "token": {
105
+ "desc": "Nhập API Key từ Groq",
106
+ "placeholder": "Groq API Key",
107
+ "title": "API Key"
108
+ }
109
+ },
102
110
  "Mistral": {
103
111
  "title": "Mistral AI",
104
112
  "token": {
@@ -193,6 +201,14 @@
193
201
  },
194
202
  "waitingForMore": "Có thêm mô hình đang <1>được lên kế hoạch tích hợp</1>, hãy chờ đợi ✨"
195
203
  },
204
+ "ollama": {
205
+ "download": {
206
+ "desc": "Ollama đang tải xuống mô hình này, vui lòng không đóng trang này. Quá trình tải xuống sẽ tiếp tục từ nơi đã bị gián đoạn khi tải lại",
207
+ "remainingTime": "Thời gian còn lại",
208
+ "speed": "Tốc độ tải xuống",
209
+ "title": "Đang tải xuống mô hình {{model}}"
210
+ }
211
+ },
196
212
  "plugin": {
197
213
  "addTooltip": "Thêm tiện ích",
198
214
  "clearDeprecated": "Xóa tiện ích không còn hỗ trợ",
@@ -428,4 +444,4 @@
428
444
  },
429
445
  "title": "Công cụ mở rộng"
430
446
  }
431
- }
447
+ }
@@ -104,6 +104,7 @@
104
104
  "azure": "Azure",
105
105
  "bedrock": "AWS Bedrock",
106
106
  "google": "Google",
107
+ "groq": "Groq",
107
108
  "mistral": "Mistral AI",
108
109
  "moonshot": "Moonshot AI",
109
110
  "ollama": "Ollama",
@@ -65,8 +65,11 @@
65
65
  "PerplexityBizError": "请求 Perplexity AI 服务出错,请根据以下信息排查或重试",
66
66
  "InvalidAnthropicAPIKey": "Anthropic API Key 不正确或为空,请检查 Anthropic API Key 后重试",
67
67
  "AnthropicBizError": "请求 Anthropic AI 服务出错,请根据以下信息排查或重试",
68
+ "InvalidGroqAPIKey": "Groq API Key 不正确或为空,请检查 Groq API Key 后重试",
69
+ "GroqBizError": "请求 Groq 服务出错,请根据以下信息排查或重试",
68
70
  "InvalidOllamaArgs": "Ollama 配置不正确,请检查 Ollama 配置后重试",
69
71
  "OllamaBizError": "请求 Ollama 服务出错,请根据以下信息排查或重试",
72
+ "OllamaServiceUnavailable": "未检测到 Ollama 服务,请检查是否正常启动",
70
73
  "AgentRuntimeError": "Lobe 语言模型运行时执行出错,请根据以下信息排查或重试"
71
74
  },
72
75
  "stt": {
@@ -90,6 +93,10 @@
90
93
  "description": "输入你的 Google API Key 即可开始会话。应用不会记录你的 API Key",
91
94
  "title": "使用自定义 Google API Key"
92
95
  },
96
+ "Groq": {
97
+ "description": "输入你的 Groq API Key 即可开始会话。应用不会记录你的 API Key",
98
+ "title": "使用自定义 Groq API Key"
99
+ },
93
100
  "Mistral": {
94
101
  "description": "输入你的 Mistral AI API Key 即可开始会话。应用不会记录你的 API Key",
95
102
  "title": "使用自定义 Mistral AI API Key"
@@ -114,6 +121,13 @@
114
121
  },
115
122
  "closeMessage": "关闭提示",
116
123
  "confirm": "确认并重试",
124
+ "model": {
125
+ "Ollama": {
126
+ "confirm": "下载",
127
+ "description": "输入你的 Ollama 模型标签,完成即可继续会话",
128
+ "title": "下载指定的 Ollama 模型"
129
+ }
130
+ },
117
131
  "oauth": {
118
132
  "description": "管理员已开启统一登录认证,点击下方按钮登录,即可解锁应用",
119
133
  "success": "登录成功",
@@ -99,6 +99,14 @@
99
99
  "title": "API Key"
100
100
  }
101
101
  },
102
+ "Groq": {
103
+ "title": "Groq",
104
+ "token": {
105
+ "desc": "填入来自 Groq 的 API Key",
106
+ "placeholder": "Groq API Key",
107
+ "title": "API Key"
108
+ }
109
+ },
102
110
  "Mistral": {
103
111
  "title": "Mistral AI",
104
112
  "token": {
@@ -193,6 +201,14 @@
193
201
  },
194
202
  "waitingForMore": "更多模型正在 <1>计划接入</1> 中,敬请期待 ✨"
195
203
  },
204
+ "ollama": {
205
+ "download": {
206
+ "desc": "Ollama 正在下载该模型,请尽量不要关闭本页面。重新下载时将会中断处继续",
207
+ "remainingTime": "剩余时间",
208
+ "speed": "下载速度",
209
+ "title": "正在下载模型 {{model}} "
210
+ }
211
+ },
196
212
  "plugin": {
197
213
  "addTooltip": "自定义插件",
198
214
  "clearDeprecated": "移除无效插件",
@@ -428,4 +444,4 @@
428
444
  },
429
445
  "title": "扩展插件"
430
446
  }
431
- }
447
+ }
@@ -104,6 +104,7 @@
104
104
  "azure": "Azure",
105
105
  "bedrock": "AWS Bedrock",
106
106
  "google": "Google",
107
+ "groq": "Groq",
107
108
  "mistral": "Mistral AI",
108
109
  "moonshot": "Moonshot AI",
109
110
  "ollama": "奧拉馬",
@@ -38,11 +38,13 @@
38
38
  "AzureBizError": "請求 Azure AI 服務出錯,請根據以下信息排查或重試",
39
39
  "BedrockBizError": "請求 Bedrock 服務出錯,請根據以下信息排查或重試",
40
40
  "GoogleBizError": "請求 Google 服務出錯,請根據以下信息排查或重試",
41
+ "GroqBizError": "請求 Groq 服務出錯,請根據以下信息排查或重試",
41
42
  "InvalidAccessCode": "密碼不正確或為空,請輸入正確的訪問密碼,或添加自定義 API 金鑰",
42
43
  "InvalidAnthropicAPIKey": "Anthropic API 金鑰不正確或為空,請檢查 Anthropic API 金鑰後重試",
43
44
  "InvalidAzureAPIKey": "Azure API Key 不正確或為空,請檢查 Azure API Key 後重試",
44
45
  "InvalidBedrockCredentials": "Bedrock 驗證未通過,請檢查 AccessKeyId/SecretAccessKey 後重試",
45
46
  "InvalidGoogleAPIKey": "Google API Key 不正確或為空,請檢查 Google API Key 後重試",
47
+ "InvalidGroqAPIKey": "Groq API 金鑰不正確或為空,請檢查 Groq API 金鑰後重試",
46
48
  "InvalidMistralAPIKey": "Mistral AI API Key 不正確或為空,請檢查 Mistral API Key 後重試",
47
49
  "InvalidMoonshotAPIKey": "Moonshot AI API 金鑰不正確或為空,請檢查 Moonshot API 金鑰後重試",
48
50
  "InvalidOllamaArgs": "Ollama 配置不正確,請檢查 Ollama 配置後重試",
@@ -53,6 +55,7 @@
53
55
  "MoonshotBizError": "請求月球背面服務出錯,請根據以下信息排查或重試",
54
56
  "NoOpenAIAPIKey": "OpenAI API 金鑰為空,請添加自訂 OpenAI API 金鑰",
55
57
  "OllamaBizError": "請求 Ollama 服務出錯,請根據以下資訊排查或重試",
58
+ "OllamaServiceUnavailable": "未偵測到 Ollama 服務,請檢查是否正常啟動",
56
59
  "OpenAIBizError": "請求 OpenAI 服務出錯。請根據以下資訊進行排查或重試。",
57
60
  "PerplexityBizError": "請求 Perplexity AI 服務出錯,請根據以下信息排查或重試",
58
61
  "PluginApiNotFound": "抱歉,外掛描述檔案中不存在該 API。請檢查您的請求方法與外掛清單 API 是否相符",
@@ -90,6 +93,10 @@
90
93
  "description": "輸入你的 Google API Key 即可開始會話。應用不會記錄你的 API Key",
91
94
  "title": "使用自定義 Google API Key"
92
95
  },
96
+ "Groq": {
97
+ "description": "輸入你的 Groq API 金鑰即可開始會話。應用不會記錄你的 API 金鑰",
98
+ "title": "使用自定義 Groq API 金鑰"
99
+ },
93
100
  "Mistral": {
94
101
  "description": "輸入你的 Mistral AI API Key 即可開始會話。應用不會記錄你的 API Key",
95
102
  "title": "使用自定義 Mistral AI API Key"
@@ -114,6 +121,13 @@
114
121
  },
115
122
  "closeMessage": "關閉提示",
116
123
  "confirm": "確認並重試",
124
+ "model": {
125
+ "Ollama": {
126
+ "confirm": "下載",
127
+ "description": "輸入你的 Ollama 模型標籤,完成即可繼續會話",
128
+ "title": "下載指定的 Ollama 模型"
129
+ }
130
+ },
117
131
  "oauth": {
118
132
  "description": "管理員已開啟統一登錄認證,點擊下方按鈕登錄,即可解鎖應用",
119
133
  "success": "登錄成功",
@@ -99,6 +99,14 @@
99
99
  "title": "API 金鑰"
100
100
  }
101
101
  },
102
+ "Groq": {
103
+ "title": "Groq",
104
+ "token": {
105
+ "desc": "填入來自 Groq 的 API 金鑰",
106
+ "placeholder": "Groq API 金鑰",
107
+ "title": "API 金鑰"
108
+ }
109
+ },
102
110
  "Mistral": {
103
111
  "title": "Mistral AI",
104
112
  "token": {
@@ -193,6 +201,14 @@
193
201
  },
194
202
  "waitingForMore": "更多模型正在 <1>計劃接入</1> 中,敬請期待 ✨"
195
203
  },
204
+ "ollama": {
205
+ "download": {
206
+ "desc": "Ollama 正在下載該模型,請儘量不要關閉本頁面。重新下載時將會中斷處繼續",
207
+ "remainingTime": "剩餘時間",
208
+ "speed": "下載速度",
209
+ "title": "正在下載模型 {{model}}"
210
+ }
211
+ },
196
212
  "plugin": {
197
213
  "addTooltip": "新增自訂外掛程式",
198
214
  "clearDeprecated": "清除已棄用的外掛",
@@ -428,4 +444,4 @@
428
444
  },
429
445
  "title": "擴展工具"
430
446
  }
431
- }
447
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/chat",
3
- "version": "0.136.0",
3
+ "version": "0.138.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",
@@ -120,6 +120,7 @@
120
120
  "next-sitemap": "^4",
121
121
  "numeral": "^2",
122
122
  "nuqs": "^1",
123
+ "ollama": "^0.5.0",
123
124
  "openai": "^4.22",
124
125
  "polished": "^4",
125
126
  "posthog-js": "^1",
@@ -13,6 +13,7 @@ import {
13
13
  LobeAzureOpenAI,
14
14
  LobeBedrockAI,
15
15
  LobeGoogleAI,
16
+ LobeGroq,
16
17
  LobeMistralAI,
17
18
  LobeMoonshotAI,
18
19
  LobeOllamaAI,
@@ -162,11 +163,16 @@ class AgentRuntime {
162
163
  runtimeModel = this.initAnthropic(payload);
163
164
  break;
164
165
  }
165
-
166
+
166
167
  case ModelProvider.Mistral: {
167
168
  runtimeModel = this.initMistral(payload);
168
169
  break;
169
170
  }
171
+
172
+ case ModelProvider.Groq: {
173
+ runtimeModel = this.initGroq(payload);
174
+ break;
175
+ }
170
176
  }
171
177
 
172
178
  return new AgentRuntime(runtimeModel);
@@ -261,13 +267,20 @@ class AgentRuntime {
261
267
  const baseURL = payload?.endpoint || ANTHROPIC_PROXY_URL;
262
268
  return new LobeAnthropicAI({ apiKey, baseURL });
263
269
  }
264
-
270
+
265
271
  private static initMistral(payload: JWTPayload) {
266
272
  const { MISTRAL_API_KEY } = getServerConfig();
267
273
  const apiKey = apiKeyManager.pick(payload?.apiKey || MISTRAL_API_KEY);
268
274
 
269
275
  return new LobeMistralAI({ apiKey });
270
276
  }
277
+
278
+ private static initGroq(payload: JWTPayload) {
279
+ const { GROQ_API_KEY } = getServerConfig();
280
+ const apiKey = apiKeyManager.pick(payload?.apiKey || GROQ_API_KEY);
281
+
282
+ return new LobeGroq({ apiKey });
283
+ }
271
284
  }
272
285
 
273
286
  export default AgentRuntime;
@@ -10,18 +10,20 @@ export const runtime = 'edge';
10
10
  */
11
11
  export const GET = async () => {
12
12
  const {
13
+ ENABLE_LANGFUSE,
13
14
  CUSTOM_MODELS,
14
15
  ENABLED_MOONSHOT,
15
16
  ENABLED_ZHIPU,
16
17
  ENABLED_AWS_BEDROCK,
17
18
  ENABLED_GOOGLE,
19
+ ENABLED_GROQ,
18
20
  ENABLE_OAUTH_SSO,
19
21
  ENABLE_OLLAMA,
20
22
  ENABLED_PERPLEXITY,
21
23
  ENABLED_ANTHROPIC,
22
24
  ENABLED_MISTRAL,
23
25
  DEFAULT_AGENT_CONFIG,
24
- ENABLE_LANGFUSE,
26
+ OLLAMA_CUSTOM_MODELS,
25
27
  } = getServerConfig();
26
28
 
27
29
  const config: GlobalServerConfig = {
@@ -35,9 +37,10 @@ export const GET = async () => {
35
37
  anthropic: { enabled: ENABLED_ANTHROPIC },
36
38
  bedrock: { enabled: ENABLED_AWS_BEDROCK },
37
39
  google: { enabled: ENABLED_GOOGLE },
40
+ groq: { enabled: ENABLED_GROQ },
38
41
  mistral: { enabled: ENABLED_MISTRAL },
39
42
  moonshot: { enabled: ENABLED_MOONSHOT },
40
- ollama: { enabled: ENABLE_OLLAMA },
43
+ ollama: { customModelName: OLLAMA_CUSTOM_MODELS, enabled: ENABLE_OLLAMA },
41
44
  perplexity: { enabled: ENABLED_PERPLEXITY },
42
45
  zhipu: { enabled: ENABLED_ZHIPU },
43
46
  },
@@ -1,5 +1,5 @@
1
1
  import { AgentRuntimeErrorType, ILobeAgentRuntimeErrorType } from '@/libs/agent-runtime';
2
- import { ErrorResponse, ErrorType } from '@/types/fetch';
2
+ import { ChatErrorType, ErrorResponse, ErrorType } from '@/types/fetch';
3
3
 
4
4
  const getStatus = (errorType: ILobeAgentRuntimeErrorType | ErrorType) => {
5
5
  // InvalidAccessCode / InvalidAzureAPIKey / InvalidOpenAIAPIKey / InvalidZhipuAPIKey ....
@@ -37,6 +37,7 @@ const getStatus = (errorType: ILobeAgentRuntimeErrorType | ErrorType) => {
37
37
  case AgentRuntimeErrorType.MoonshotBizError: {
38
38
  return 476;
39
39
  }
40
+ case ChatErrorType.OllamaServiceUnavailable:
40
41
  case AgentRuntimeErrorType.OllamaBizError: {
41
42
  return 478;
42
43
  }
@@ -49,6 +50,9 @@ const getStatus = (errorType: ILobeAgentRuntimeErrorType | ErrorType) => {
49
50
  case AgentRuntimeErrorType.MistralBizError: {
50
51
  return 481;
51
52
  }
53
+ case AgentRuntimeErrorType.GroqBizError: {
54
+ return 482;
55
+ }
52
56
  }
53
57
  return errorType as number;
54
58
  };
@@ -0,0 +1,47 @@
1
+ import { Groq } from '@lobehub/icons';
2
+ import { Input } from 'antd';
3
+ import { useTheme } from 'antd-style';
4
+ import { memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+
7
+ import { ModelProvider } from '@/libs/agent-runtime';
8
+
9
+ import Checker from '../components/Checker';
10
+ import ProviderConfig from '../components/ProviderConfig';
11
+ import { LLMProviderApiTokenKey, LLMProviderConfigKey } from '../const';
12
+
13
+ const providerKey = 'groq';
14
+
15
+ const GroqProvider = memo(() => {
16
+ const { t } = useTranslation('setting');
17
+
18
+ const theme = useTheme();
19
+
20
+ return (
21
+ <ProviderConfig
22
+ configItems={[
23
+ {
24
+ children: (
25
+ <Input.Password
26
+ autoComplete={'new-password'}
27
+ placeholder={t('llm.Groq.token.placeholder')}
28
+ />
29
+ ),
30
+ desc: t('llm.Groq.token.desc'),
31
+ label: t('llm.Groq.token.title'),
32
+ name: [LLMProviderConfigKey, providerKey, LLMProviderApiTokenKey],
33
+ },
34
+ {
35
+ children: <Checker model={'gemma-7b-it'} provider={ModelProvider.Groq} />,
36
+ desc: t('llm.checker.desc'),
37
+ label: t('llm.checker.title'),
38
+ minWidth: '100%',
39
+ },
40
+ ]}
41
+ provider={providerKey}
42
+ title={<Groq.Text color={theme.isDarkMode ? theme.colorText : Groq.colorPrimary} size={24} />}
43
+ />
44
+ );
45
+ });
46
+
47
+ export default GroqProvider;
@@ -0,0 +1,73 @@
1
+ import { CheckCircleFilled } from '@ant-design/icons';
2
+ import { Alert, Highlighter } from '@lobehub/ui';
3
+ import { Button } from 'antd';
4
+ import { useTheme } from 'antd-style';
5
+ import { ListResponse } from 'ollama/browser';
6
+ import { memo } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { Flexbox } from 'react-layout-kit';
9
+ import useSWR from 'swr';
10
+
11
+ import { useIsMobile } from '@/hooks/useIsMobile';
12
+ import { ollamaService } from '@/services/ollama';
13
+
14
+ const OllamaChecker = memo(() => {
15
+ const { t } = useTranslation('setting');
16
+
17
+ const theme = useTheme();
18
+
19
+ const { data, error, isLoading, mutate } = useSWR<ListResponse>(
20
+ 'ollama.list',
21
+ ollamaService.getModels,
22
+ {
23
+ revalidateOnFocus: false,
24
+ revalidateOnMount: false,
25
+ revalidateOnReconnect: false,
26
+ },
27
+ );
28
+
29
+ const checkConnection = () => {
30
+ mutate();
31
+ };
32
+
33
+ const isMobile = useIsMobile();
34
+
35
+ return (
36
+ <Flexbox align={isMobile ? 'flex-start' : 'flex-end'} gap={8}>
37
+ <Flexbox align={'center'} direction={isMobile ? 'horizontal-reverse' : 'horizontal'} gap={12}>
38
+ {!error && data?.models && (
39
+ <Flexbox gap={4} horizontal>
40
+ <CheckCircleFilled
41
+ style={{
42
+ color: theme.colorSuccess,
43
+ }}
44
+ />
45
+ {t('llm.checker.pass')}
46
+ </Flexbox>
47
+ )}
48
+ <Button loading={isLoading} onClick={checkConnection}>
49
+ {t('llm.checker.button')}
50
+ </Button>
51
+ </Flexbox>
52
+ {error && (
53
+ <Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
54
+ <Alert
55
+ banner
56
+ extra={
57
+ <Flexbox>
58
+ <Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
59
+ {JSON.stringify(error.body || error, null, 2)}
60
+ </Highlighter>
61
+ </Flexbox>
62
+ }
63
+ message={t(`response.${error.type}` as any, { ns: 'error' })}
64
+ showIcon
65
+ type={'error'}
66
+ />
67
+ </Flexbox>
68
+ )}
69
+ </Flexbox>
70
+ );
71
+ });
72
+
73
+ export default OllamaChecker;
@@ -4,9 +4,7 @@ import { useTheme } from 'antd-style';
4
4
  import { memo } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
 
7
- import { ModelProvider } from '@/libs/agent-runtime';
8
-
9
- import Checker from '../components/Checker';
7
+ import Checker from './Checker';
10
8
  import ProviderConfig from '../components/ProviderConfig';
11
9
  import { LLMProviderBaseUrlKey, LLMProviderConfigKey } from '../const';
12
10
 
@@ -38,7 +36,7 @@ const OllamaProvider = memo(() => {
38
36
  name: [LLMProviderConfigKey, providerKey, 'customModelName'],
39
37
  },
40
38
  {
41
- children: <Checker model={'llama2'} provider={ModelProvider.Ollama} />,
39
+ children: <Checker />,
42
40
  desc: t('llm.Ollama.checker.desc'),
43
41
  label: t('llm.checker.title'),
44
42
  minWidth: undefined,
@@ -16,6 +16,28 @@ interface ConnectionCheckerProps {
16
16
  provider: string;
17
17
  }
18
18
 
19
+ const Error = memo<{ error: ChatMessageError }>(({ error }) => {
20
+ const { t } = useTranslation('error');
21
+
22
+ return (
23
+ <Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
24
+ <Alert
25
+ banner
26
+ extra={
27
+ <Flexbox>
28
+ <Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
29
+ {JSON.stringify(error.body || error, null, 2)}
30
+ </Highlighter>
31
+ </Flexbox>
32
+ }
33
+ message={t(`response.${error.type}` as any)}
34
+ showIcon
35
+ type={'error'}
36
+ />
37
+ </Flexbox>
38
+ );
39
+ });
40
+
19
41
  const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
20
42
  const { t } = useTranslation('setting');
21
43
 
@@ -75,23 +97,7 @@ const Checker = memo<ConnectionCheckerProps>(({ model, provider }) => {
75
97
  {t('llm.checker.button')}
76
98
  </Button>
77
99
  </Flexbox>
78
- {error && (
79
- <Flexbox gap={8} style={{ maxWidth: '600px', width: '100%' }}>
80
- <Alert
81
- banner
82
- extra={
83
- <Flexbox>
84
- <Highlighter copyButtonSize={'small'} language={'json'} type={'pure'}>
85
- {JSON.stringify(error.body || error, null, 2)}
86
- </Highlighter>
87
- </Flexbox>
88
- }
89
- message={t(`response.${error.type}` as any, { ns: 'error' })}
90
- showIcon
91
- type={'error'}
92
- />
93
- </Flexbox>
94
- )}
100
+ {error && <Error error={error} />}
95
101
  </Flexbox>
96
102
  );
97
103
  });
@@ -11,6 +11,7 @@ import Footer from '../features/Footer';
11
11
  import Anthropic from './Anthropic';
12
12
  import Bedrock from './Bedrock';
13
13
  import Google from './Google';
14
+ import Groq from './Groq';
14
15
  import Mistral from './Mistral';
15
16
  import Moonshot from './Moonshot';
16
17
  import Ollama from './Ollama';
@@ -29,6 +30,7 @@ export default memo<{ showOllama: boolean }>(({ showOllama }) => {
29
30
  {showOllama && <Ollama />}
30
31
  <Anthropic />
31
32
  <Google />
33
+ <Groq />
32
34
  <Bedrock />
33
35
  <Perplexity />
34
36
  <Mistral />
@@ -5,6 +5,7 @@ import {
5
5
  Claude,
6
6
  Gemini,
7
7
  Gemma,
8
+ LLaVA,
8
9
  Meta,
9
10
  Minimax,
10
11
  Mistral,
@@ -29,6 +30,7 @@ const ModelIcon = memo<ModelProviderIconProps>(({ model, size = 12 }) => {
29
30
  if (model.includes('claude')) return <Claude.Avatar size={size} />;
30
31
  if (model.includes('titan')) return <Aws.Avatar size={size} />;
31
32
  if (model.includes('llama')) return <Meta.Avatar size={size} />;
33
+ if (model.includes('llava')) return <LLaVA.Avatar size={size} />;
32
34
  if (model.includes('gemini')) return <Gemini.Avatar size={size} />;
33
35
  if (model.includes('gemma')) return <Gemma.Avatar size={size} />;
34
36
  if (model.includes('qwen')) return <Tongyi.Avatar background={Tongyi.colorPrimary} size={size} />;