Skip to content

Commit

Permalink
✨ feat: support Google / Zhipu / AWS Bedrock model providers (lobehu…
Browse files Browse the repository at this point in the history
…b#1173)

* ✨ feat: support claude

* ✨ feat: support google vision

* ✨ feat: add proxy to provider

* ✨ feat: add google config

* ✨ feat: fix google error handle

* ✨ feat: support bedrock error handle

* ♻️ refactor: refactor the auth with jwt

* ✅ test: fix the openai  runtime test

* ♻️ refactor: refactor the settings config

* ✨ feat: refactor the model select in agent setting

* 🎨 chore: improve model list

* ✨ feat: support custom api Key form

* 🎨 chore: improve code

* ♻️ refactor: refactor the custom models

* 💄 style: improve model icon

* ✨ feat: add google handle

* 🌐 style: add i18n

* 📝 docs: add env document about new providers

* 💄 style: improve plugin tag and model options
  • Loading branch information
arvinxx authored Feb 5, 2024
1 parent 81f3ad1 commit d5929f6
Show file tree
Hide file tree
Showing 225 changed files with 6,991 additions and 1,761 deletions.
24 changes: 22 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# add a access code to lock your lobe-chat application, it should be a six length string
ACCESS_CODE=lobe66
# add a access code to lock your lobe-chat application, you can set a long password to avoid leaking. If this value contains a comma, it is a password array.
#ACCESS_CODE=lobe66

# add your custom model name, multi model separate by comma. for example gpt-3.5-1106,gpt-4-1106
# CUSTOM_MODELS=model1,model2,model3
Expand Down Expand Up @@ -33,6 +33,26 @@ OPENAI_API_KEY=sk-xxxxxxxxx
# Azure's API version, follows the YYYY-MM-DD format
# AZURE_API_VERSION=2023-08-01-preview

########################################
############ ZhiPu AI Service ##########
########################################

#ZHIPU_API_KEY=xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxx

########################################
############ Google AI Service ##########
########################################

#GOOGLE_API_KEY=xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxx

########################################
############ AWS Bedrock Service ##########
########################################

#AWS_REGION=us-east-1
#AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxx
#AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

########################################
############ Market Service ############
########################################
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ config.rules['unicorn/no-useless-undefined'] = 0;
config.rules['react/no-unknown-property'] = 0;
config.rules['unicorn/prefer-ternary'] = 0;
config.rules['unicorn/prefer-spread'] = 0;
config.rules['unicorn/catch-error-name'] = 0;

module.exports = config;
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ next-env.d.ts
.next
.env
public/*.js
bun.lockb
bun.lockb
88 changes: 65 additions & 23 deletions docs/Deployment/Environment-Variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ LobeChat provides additional configuration options during deployment, which can

- [General Variables](#general-variables)
- [`ACCESS_CODE`](#access_code)
- [Model Service Providers](#model-service-providers)
- [OpenAI](#openai)
- [`CUSTOM_MODELS`](#custom_models)
- [OpenAI](#openai)
- [`OPENAI_API_KEY`](#openai_api_key)
- [`OPENAI_PROXY_URL`](#openai_proxy_url)
- [Azure OpenAI](#azure-openai)
- [`USE_AZURE_OPENAI`](#use_azure_openai)
- [`AZURE_API_KEY`](#azure_api_key)
- [`AZURE_API_VERSION`](#azure_api_version)
- [Azure OpenAI](#azure-openai)
- [Zhipu AI](#zhipu-ai)
- [Google AI](#google-ai)
- [AWS Bedrock](#aws-bedrock)
- [Plugin Service](#plugin-service)
- [`PLUGINS_INDEX_URL`](#plugins_index_url)
- [`PLUGIN_SETTINGS`](#plugin_settings)
Expand All @@ -28,29 +27,22 @@ LobeChat provides additional configuration options during deployment, which can
### `ACCESS_CODE`

- Type: Optional
- Description: Add a password to access the LobeChat service, ; you can set a long password to avoid leaking. If this value contains a comma, it is a password array.
- Description: Add a password to access the LobeChat service; you can set a long password to avoid leaking. If this value contains a comma, it is a password array.
- Default: `-`
- Example: `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3`

### `CUSTOM_MODELS`
## Model Service Providers

- Type: Optional
- Description: Used to control the model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model, separated by commas.
- Default: `-`
- Example: `+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`
### OpenAI

The above example adds `qwen-7b-chat` and `glm-6b` to the model list, removes `gpt-3.5-turbo` from the list, and displays the model name `gpt-4-0125-preview` as `gpt-4-turbo`. If you want to disable all models first and then enable specific models, you can use `-all,+gpt-3.5-turbo`, which means only `gpt-3.5-turbo` will be enabled.

## OpenAI

### `OPENAI_API_KEY`
#### `OPENAI_API_KEY`

- Type: Required
- Description: This is the API key you apply for on the OpenAI account page, you can go [here][openai-api-page] to view
- Default: `-`
- Example: `sk-xxxxxx...xxxxxx`

### `OPENAI_PROXY_URL`
#### `OPENAI_PROXY_URL`

- Type: Optional
- Description: If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL
Expand All @@ -70,25 +62,34 @@ Related discussions:
- [Reasons for errors when using third-party interfaces](https://github.com/lobehub/lobe-chat/discussions/734)
- [No response when filling in the proxy server address for chatting](https://github.com/lobehub/lobe-chat/discussions/1065)

## Azure OpenAI
### `CUSTOM_MODELS`

- Type: Optional
- Description: Used to control the model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model, separated by commas.
- Default: `-`
- Example: `+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`

The above example adds `qwen-7b-chat` and `glm-6b` to the model list, removes `gpt-3.5-turbo` from the list, and displays the model name `gpt-4-0125-preview` as `gpt-4-turbo`. If you want to disable all models first and then enable specific models, you can use `-all,+gpt-3.5-turbo`, which means only `gpt-3.5-turbo` will be enabled.

### Azure OpenAI

If you need to use Azure OpenAI to provide model services, you can refer to the [Deploy with Azure OpenAI](Deploy-with-Azure-OpenAI.zh-CN.md) section for detailed steps. Here are the environment variables related to Azure OpenAI.

### `USE_AZURE_OPENAI`
#### `USE_AZURE_OPENAI`

- Type: Optional
- Description: Set this value to `1` to enable Azure OpenAI configuration
- Default: `-`
- Example: `1`

### `AZURE_API_KEY`
#### `AZURE_API_KEY`

- Type: Optional
- Description: This is the API key you apply for on the Azure OpenAI account page
- Default: `-`
- Example: `c55168be3874490ef0565d9779ecd5a6`

### `AZURE_API_VERSION`
#### `AZURE_API_VERSION`

- Type: Optional
- Description: Azure's API version, following the YYYY-MM-DD format
Expand All @@ -97,6 +98,47 @@ If you need to use Azure OpenAI to provide model services, you can refer to the

<br/>

### Zhipu AI

#### `ZHIPU_API_KEY`

- Type: Required
- Description: This is the API key you applied for in the Zhipu AI service
- Default Value: -
- Example: `4582d332441a313f5c2ed9824d1798ca.rC8EcTAhgbOuAuVT`

### Google AI

#### `GOOGLE_API_KEY`

- Type: Required
- Description: This is the API key you applied for on Google Cloud Platform, used to access Google AI services
- Default Value: -
- Example: `AIraDyDwcw254kwJaGjI9wwaHcdDCS__Vt3xQE`

### AWS Bedrock

#### `AWS_ACCESS_KEY_ID`

- Type: Required
- Description: The access key ID for AWS service authentication
- Default Value: -
- Example: `AKIA5STVRLFSB4S9HWBR`

#### `AWS_SECRET_ACCESS_KEY`

- Type: Required
- Description: The secret key for AWS service authentication
- Default Value: -
- Example: `Th3vXxLYpuKcv2BARktPSTPxx+jbSiFT6/0w7oEC`

#### `AWS_REGION`

- Type: Optional
- Description: The region setting for AWS services
- Default Value: `us-east-1`
- Example: `us-east-1`

## Plugin Service

### `PLUGINS_INDEX_URL`
Expand Down
86 changes: 64 additions & 22 deletions docs/Deployment/Environment-Variable.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进

- [通用变量](#通用变量)
- [`ACCESS_CODE`](#access_code)
- [模型服务商](#模型服务商)
- [OpenAI](#openai)
- [`CUSTOM_MODELS`](#custom_models)
- [OpenAI](#openai)
- [`OPENAI_API_KEY`](#openai_api_key)
- [`OPENAI_PROXY_URL`](#openai_proxy_url)
- [Azure OpenAI](#azure-openai)
- [`USE_AZURE_OPENAI`](#use_azure_openai)
- [`AZURE_API_KEY`](#azure_api_key)
- [`AZURE_API_VERSION`](#azure_api_version)
- [Azure OpenAI](#azure-openai)
- [智谱 AI](#智谱-ai)
- [Google AI](#google-ai)
- [AWS Bedrock](#aws-bedrock)
- [插件服务](#插件服务)
- [`PLUGINS_INDEX_URL`](#plugins_index_url)
- [`PLUGIN_SETTINGS`](#plugin_settings)
Expand All @@ -32,25 +31,18 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
- 默认值:-
- 示例:`awCTe)re_r74` or `rtrt_ewee3@09!`

### `CUSTOM_MODELS`

- 类型:可选
- 描述:用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。
- 默认值:`-`
- 示例:`+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`

上面示例表示增加 `qwen-7b-chat``glm-6b` 到模型列表,而从列表中删除 `gpt-3.5-turbo`,并将 `gpt-4-0125-preview` 模型名字展示为 `gpt-4-turbo`。如果你想先禁用所有模型,再启用指定模型,可以使用 `-all,+gpt-3.5-turbo`,则表示仅启用 `gpt-3.5-turbo`
## 模型服务商

## OpenAI
### OpenAI

### `OPENAI_API_KEY`
#### `OPENAI_API_KEY`

- 类型:必选
- 描述:这是你在 OpenAI 账户页面申请的 API 密钥,可以前往[这里][openai-api-page]查看
- 默认值:-
- 示例:`sk-xxxxxx...xxxxxx`

### `OPENAI_PROXY_URL`
#### `OPENAI_PROXY_URL`

- 类型:可选
- 描述:如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL
Expand All @@ -70,31 +62,81 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
- [使用第三方接口报错的原因](https://github.com/lobehub/lobe-chat/discussions/734)
- [代理服务器地址填了聊天没任何反应](https://github.com/lobehub/lobe-chat/discussions/1065)

## Azure OpenAI
### `CUSTOM_MODELS`

- 类型:可选
- 描述:用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。
- 默认值:`-`
- 示例:`+qwen-7b-chat,+glm-6b,-gpt-3.5-turbo,gpt-4-0125-preview=gpt-4-turbo`

上面示例表示增加 `qwen-7b-chat``glm-6b` 到模型列表,而从列表中删除 `gpt-3.5-turbo`,并将 `gpt-4-0125-preview` 模型名字展示为 `gpt-4-turbo`。如果你想先禁用所有模型,再启用指定模型,可以使用 `-all,+gpt-3.5-turbo`,则表示仅启用 `gpt-3.5-turbo`

### Azure OpenAI

如果你需要使用 Azure OpenAI 来提供模型服务,可以查阅 [使用 Azure OpenAI 部署](Deploy-with-Azure-OpenAI.zh-CN.md) 章节查看详细步骤,这里将列举和 Azure OpenAI 相关的环境变量。

### `USE_AZURE_OPENAI`
#### `USE_AZURE_OPENAI`

- 类型:可选
- 描述:设置该值为 `1` 开启 Azure OpenAI 配置
- 默认值:-
- 示例:`1`

### `AZURE_API_KEY`
#### `AZURE_API_KEY`

- 类型:可选
- 描述:这是你在 Azure OpenAI 账户页面申请的 API 密钥
- 默认值:-
- 示例:`c55168be3874490ef0565d9779ecd5a6`

### `AZURE_API_VERSION`
#### `AZURE_API_VERSION`

- 类型:可选
- 描述:Azure 的 API 版本,遵循 YYYY-MM-DD 格式
- 默认值:`2023-08-01-preview`
- 示例:`2023-05-15`,查阅[最新版本][azure-api-verion-url]

### 智谱 AI

#### `ZHIPU_API_KEY`

- 类型:必选
- 描述:这是你在 智谱 AI 服务中申请的 API 密钥
- 默认值:-
- 示例:`4582d332441a313f5c2ed9824d1798ca.rC8EcTAhgbOuAuVT`

### Google AI

#### `GOOGLE_API_KEY`

- 类型:必选
- 描述:这是你在 Google AI Platform 申请的 API 密钥,用于访问 Google AI 服务
- 默认值:-
- 示例:`AIraDyDwcw254kwJaGjI9wwaHcdDCS__Vt3xQE`

### AWS Bedrock

#### `AWS_ACCESS_KEY_ID`

- 类型:必选
- 描述:用于 AWS 服务认证的访问键 ID
- 默认值:-
- 示例:`AKIA5STVRLFSB4S9HWBR`

#### `AWS_SECRET_ACCESS_KEY`

- 类型:必选
- 描述:用于 AWS 服务认证的密钥
- 默认值:-
- 示例:`Th3vXxLYpuKcv2BARktPSTPxx+jbSiFT6/0w7oEC`

#### `AWS_REGION`

- 类型:可选
- 描述:AWS 服务的区域设置
- 默认值:`us-east-1`
- 示例:`us-east-1`

## 插件服务

### `PLUGINS_INDEX_URL`
Expand Down
13 changes: 12 additions & 1 deletion locales/ar/chat.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"ModelSwitch": {
"title": "النموذج"
},
"agentDefaultMessage": "مرحبًا، أنا **{{name}}**، يمكنك البدء في الدردشة معي على الفور، أو يمكنك الانتقال إلى [إعدادات المساعد](/chat/settings#session={{id}}) لتحسين معلوماتي.",
"agentDefaultMessageWithSystemRole": "مرحبًا، أنا **{{name}}**، {{systemRole}}، دعنا نبدأ الدردشة!",
"backToBottom": "العودة إلى الأسفل",
Expand Down Expand Up @@ -64,7 +67,14 @@
"prettifying": "جارٍ التجميل..."
},
"temp": "مؤقت",
"tokenDetail": "إعداد الدور: {{systemRoleToken}} · رسائل الجلسة: {{chatsToken}} · إعداد الأدوات: {{toolsToken}}",
"tokenDetails": {
"chats": "رسائل المحادثة",
"rest": "المتبقي",
"systemRole": "تعيين الدور",
"tools": "تعيين الإضافات",
"total": "الإجمالي",
"used": "المستخدم"
},
"tokenTag": {
"overload": "تجاوز الحد",
"remained": "متبقي",
Expand Down Expand Up @@ -102,6 +112,7 @@
"updateAgent": "تحديث معلومات المساعد",
"upload": {
"actionTooltip": "تحميل الصورة",
"disabled": "النموذج الحالي لا يدعم التعرف على الرؤية، يرجى تغيير النموذج المستخدم",
"dragDesc": "اسحب الملفات إلى هنا، يدعم تحميل عدة صور. اضغط على Shift لإرسال الصور مباشرة",
"dragTitle": "تحميل الصورة"
}
Expand Down
16 changes: 16 additions & 0 deletions locales/ar/common.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"ModelSelect": {
"featureTag": {
"custom": "نموذج مخصص، يدعم الوظائف والتعرف على الرؤية، يرجى التحقق من قدرة النموذج على القيام بذلك وفقًا للحالة الفعلية",
"functionCall": "يدعم هذا النموذج استدعاء الوظائف",
"tokens": "هذا النموذج يدعم حتى {{tokens}} رموز في جلسة واحدة",
"vision": "يدعم هذا النموذج التعرف على الرؤية"
}
},
"about": "حول",
"advanceSettings": "إعدادات متقدمة",
"agentMaxToken": "أقصى طول للجلسة",
Expand Down Expand Up @@ -89,6 +97,14 @@
"zh-TW": "الصينية التقليدية"
},
"layoutInitializing": "جاري تحميل التخطيط...",
"modelProvider": {
"azure": "أزور",
"bedrock": "بيدروك لأمازون ويب سيرفيس",
"google": "جوجل",
"oneapi": "وان آبي آي",
"openai": "أوبن إيه آي",
"zhipu": "زهيبو"
},
"noDescription": "لا توجد وصف",
"ok": "موافق",
"password": "كلمة المرور",
Expand Down
Loading

0 comments on commit d5929f6

Please sign in to comment.