From adebf0a92167faad48581b0b0780cf8faeba362f Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Wed, 5 Jun 2024 11:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20docs:=20update=20url-share=20doc?= =?UTF-8?q?s=20(#2791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📝 docs: update docs * update docs --- .../advanced/settings-url-share.mdx | 146 +++++++++++------- .../advanced/settings-url-share.zh-CN.mdx | 143 ++++++++++------- package.json | 1 - 3 files changed, 176 insertions(+), 114 deletions(-) diff --git a/docs/self-hosting/advanced/settings-url-share.mdx b/docs/self-hosting/advanced/settings-url-share.mdx index 179cdb516a2b..22b8a43d2b68 100644 --- a/docs/self-hosting/advanced/settings-url-share.mdx +++ b/docs/self-hosting/advanced/settings-url-share.mdx @@ -1,9 +1,10 @@ -# Share settings via URL +# Share settings via URL LobeChat support import settings from external URL to quickly set up LobeChat configuration. The currently supported settings are: +- `keyVaults`: provider api key and baseURL settings - `languageModel`: Language model settings ## Import from URL @@ -12,18 +13,18 @@ Use the following URL format to import settings parameters from an external URL: ```plaintext https://lobehub.com/?settings= -https://lobehub.com/?settings={"languageModel":{"openai":{"apiKey":"user-key","endpoint":"https://lobehub.com/v1"}}} +https://lobehub.com/?settings={"keyVaults":{"openai":{"apiKey":"user-key","baseURL":"https://your-proxy.com/v1"}}} ``` Example of settings in JSON format: ```json { - "languageModel": { - "openai": { - "apiKey": "user-key" - } + "keyVaults": { + "openai": { + "apiKey": "user-key" } + } } ``` @@ -32,69 +33,100 @@ Example of settings in JSON format: ```ts // Generate settings to export to URL const settings = { - languageModel: { + keyVaults: { openai: { - apiKey: 'user-key', - endpoint: 'https://lobehub.com/v1' + apiKey: 'user-key', + baseURL: 'https://your-proxy.com/v1', }, -}}; + }, +}; // Convert settings to a JSON formatted string const url = `/?settings=${JSON.stringify(settings)}`; -console.log(url); -// /?settings={"languageModel":{"openai":{"apiKey":"user-key","endpoint":"https://lobehub.com/v1"}}} +console.log(url); +// /?settings={"keyVaults":{"openai":{"apiKey":"user-key","baseURL":"https://your-proxy.com/v1"}}} ``` - LobeChat does not verify the correctness of the settings parameters in the URL, nor provide encryption or decryption methods. Please use with caution. + LobeChat does not verify the correctness of the settings parameters in the URL, nor provide + encryption or decryption methods. Please use with caution. ## Parameter schema -### languageModel +### keyVaults - Property name and type -| Property name | Type | -|---------------|--------------------------------| -| anthropic | GeneralModelProviderConfig | -| azure | AzureOpenAIConfig | -| bedrock | AWSBedrockConfig | -| google | GeneralModelProviderConfig | -| groq | GeneralModelProviderConfig | -| minimax | GeneralModelProviderConfig | -| mistral | GeneralModelProviderConfig | -| moonshot | GeneralModelProviderConfig | -| ollama | GeneralModelProviderConfig | -| openai | GeneralModelProviderConfig | -| openrouter | GeneralModelProviderConfig | -| perplexity | GeneralModelProviderConfig | -| togetherai | GeneralModelProviderConfig | -| zeroone | GeneralModelProviderConfig | -| zhipu | GeneralModelProviderConfig | - -- Type `GeneralModelProviderConfig` - -| Property name | Type | Description | -|-----------------------|--------------------------|-----------------------------------------------------------------------------| -| apiKey | string | The API key for the model provider. | -| autoFetchModelLists | boolean | Whether to automatically fetch model lists. | -| enabled | boolean | Whether the model provider is enabled. | -| enabledModels | string[] | null | The IDs of the enabled models. | -| endpoint | string | The endpoint for the model provider. | -| fetchOnClient | boolean | Whether to fetch on the client. | - -- Type `AzureOpenAIConfig` -> Inherits the fields from `GeneralModelProviderConfig` - -| Property name | Type | Description | -|-----------------------|--------------------------|-----------------------------------------------------------------------------| -| apiVersion | string | The API version for Azure OpenAI. | - -- Type `AWSBedrockConfig` -> Inherits all fields from `GeneralModelProviderConfig` except `apiKey, endpoint` - -| Property name | Type | Description | -| accessKeyId | string | The access key ID for AWS Bedrock. | -| region | string | The region for AWS Bedrock. | -| secretAccessKey | string | The secret access key for AWS Bedrock. | +| Property name | Type | +| ------------- | ------------------------ | +| anthropic | `OpenAICompatibleKeyVault` | +| azure | `AzureOpenAIKeyVault` | +| bedrock | `AWSBedrockKeyVault` | +| google | `OpenAICompatibleKeyVault` | +| groq | `OpenAICompatibleKeyVault` | +| minimax | `OpenAICompatibleKeyVault` | +| mistral | `OpenAICompatibleKeyVault` | +| moonshot | `OpenAICompatibleKeyVault` | +| ollama | `OpenAICompatibleKeyVault` | +| openai | `OpenAICompatibleKeyVault` | +| openrouter | `OpenAICompatibleKeyVault` | +| perplexity | `OpenAICompatibleKeyVault` | +| togetherai | `OpenAICompatibleKeyVault` | +| zeroone | `OpenAICompatibleKeyVault` | +| zhipu | `OpenAICompatibleKeyVault` | + +- Type `OpenAICompatibleKeyVault` + +| Property name | Type | Description | +| ------------- | ------ | ------------------------------------ | +| apiKey | string | The API key for the model provider. | +| baseURL | string | The endpoint for the model provider. | + +- Type `AzureOpenAIKeyVault` + +| Property name | Type | Description | +| ------------- | ------ | ------------------------------------ | +| apiVersion | string | The API version for Azure OpenAI. | +| apiKey | string | The API key for the model provider. | +| endpoint | string | The endpoint for the model provider. | + +- Type `AWSBedrockKeyVault` + +| Property name | Type | Description | +| --------------- | ------ | -------------------------------------- | +| accessKeyId | string | The access key ID for AWS Bedrock. | +| region | string | The region for AWS Bedrock. | +| secretAccessKey | string | The secret access key for AWS Bedrock. | + +### languageModel + +```ts +export type UserModelProviderConfig = Record; +``` +| Property name | Type | +| ------------- | -------------- | +| anthropic | `ProviderConfig` | +| azure | `ProviderConfig` | +| bedrock | `ProviderConfig` | +| google | `ProviderConfig` | +| groq | `ProviderConfig` | +| minimax | `ProviderConfig` | +| mistral | `ProviderConfig` | +| moonshot | `ProviderConfig` | +| ollama | `ProviderConfig` | +| openai | `ProviderConfig` | +| openrouter | `ProviderConfig` | +| perplexity | `ProviderConfig` | +| togetherai | `ProviderConfig` | +| zeroone | `ProviderConfig` | +| zhipu | `ProviderConfig` | + +- Type `ProviderConfig` + +| Property name | Type | Description | +| ------------------- | -------- | ------------------------------------------- | ------------------------------ | +| autoFetchModelLists | boolean | Whether to automatically fetch model lists. | +| enabled | boolean | Whether the model provider is enabled. | +| enabledModels | string[] | null | The IDs of the enabled models. | +| fetchOnClient | boolean | Whether to fetch on the client. | diff --git a/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx b/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx index 269c687cbc65..a9ceccc2503a 100644 --- a/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx +++ b/docs/self-hosting/advanced/settings-url-share.zh-CN.mdx @@ -4,7 +4,8 @@ LobeChat 支持从外部 URL 导入设置参数,以便于快速设置 LobeChat 目前支持的设置项有: -- `languageModel`:语言模型设置 +- `keyVaults`: 模型供应商相关秘钥设置 +- `languageModel`:语言模型设置 ## 从 URL 中导入 @@ -12,18 +13,18 @@ LobeChat 支持从外部 URL 导入设置参数,以便于快速设置 LobeChat ```plaintext https://lobehub.com/?settings= -https://lobehub.com/?settings={"languageModel":{"openai":{"apiKey":"user-key","endpoint":"https://lobehub.com/v1"}}} +https://lobehub.com/?settings={"keyVaults":{"openai":{"apiKey":"user-key","baseURL":"https://your-proxy.com/v1"}}} ``` JSON格式的设置示例: ```json { - "languageModel": { - "openai": { - "apiKey": "user-key" - } + "keyVaults": { + "openai": { + "apiKey": "user-key" } + } } ``` @@ -32,69 +33,99 @@ JSON格式的设置示例: ```ts // 生成要导出到 URL 的设置 const settings = { - languageModel: { + keyVaults: { openai: { - apiKey: 'user-key', - endpoint: 'https://lobehub.com/v1' + apiKey: 'user-key', + baseURL: 'https://your-proxy.com/v1', }, -}}; -// 将设置转为 JSON 格式的字符串 + }, +}; +// Convert settings to a JSON formatted string const url = `/?settings=${JSON.stringify(settings)}`; -console.log(url); -// /?settings={"languageModel":{"openai":{"apiKey":"user-key","endpoint":"https://lobehub.com/v1"}}} +console.log(url); +// /?settings={"keyVaults":{"openai":{"apiKey":"user-key","baseURL":"https://your-proxy.com/v1"}}} ``` - LobeChat 不对 URL 中的设置参数进行正确性校验,也不提供加密、解密方法,请谨慎使用。 + LobeChat 不对 URL 中的设置参数进行正确性校验,也不提供 URL 的加密、解密方法,请谨慎使用。 ## 参数格式 -### languageModel +### keyVaults - 参数及其类型 -| 参数名称 | 类型 | -|---------------|--------------------------------| -| anthropic | GeneralModelProviderConfig | -| azure | AzureOpenAIConfig | -| bedrock | AWSBedrockConfig | -| google | GeneralModelProviderConfig | -| groq | GeneralModelProviderConfig | -| minimax | GeneralModelProviderConfig | -| mistral | GeneralModelProviderConfig | -| moonshot | GeneralModelProviderConfig | -| ollama | GeneralModelProviderConfig | -| openai | GeneralModelProviderConfig | -| openrouter | GeneralModelProviderConfig | -| perplexity | GeneralModelProviderConfig | -| togetherai | GeneralModelProviderConfig | -| zeroone | GeneralModelProviderConfig | -| zhipu | GeneralModelProviderConfig | - -- 类型 `GeneralModelProviderConfig` - -| 参数 | TS 类型 | 描述 | -|-----------------------|--------------------------|-----------------------------------------------------------------------------| -| apiKey | string | 模型的 API 密钥。 | -| autoFetchModelLists | boolean | 是否自动获取模型列表。 | -| enabled | boolean | 是否启用该模型。 | -| enabledModels | string[] | 启用的模型的 ID。 | -| endpoint | string | 模型API端点。 | -| fetchOnClient | boolean | 是否在客户端发起请求,默认在服务端发起请求。 | - -- 类型 `AzureOpenAIConfig` -> 继承 `GeneralModelProviderConfig` 中的字段 - -| 参数 | TS 类型 | 描述 | -|-----------------------|--------------------------|-----------------------------------------------------------------------------| +| 参数名称 | 类型 | +| ---------- | ------------------------ | +| anthropic | `OpenAICompatibleKeyVault` | +| azure | `AzureOpenAIKeyVault` | +| bedrock | `AWSBedrockKeyVault` | +| google | `OpenAICompatibleKeyVault` | +| groq | `OpenAICompatibleKeyVault` | +| minimax | `OpenAICompatibleKeyVault` | +| mistral | `OpenAICompatibleKeyVault` | +| moonshot | `OpenAICompatibleKeyVault` | +| ollama | `OpenAICompatibleKeyVault` | +| openai | `OpenAICompatibleKeyVault` | +| openrouter | `OpenAICompatibleKeyVault` | +| perplexity | `OpenAICompatibleKeyVault` | +| togetherai | `OpenAICompatibleKeyVault` | +| zeroone | `OpenAICompatibleKeyVault` | +| zhipu | `OpenAICompatibleKeyVault` | + +- Type `OpenAICompatibleKeyVault` + +| 参数 | 类型 | 描述 | +| ------- | ------ | ----------------- | +| apiKey | string | 模型的 API 密钥。 | +| baseURL | string | 模型API端点。 | + +- Type `AzureOpenAIKeyVault` + +| 参数 | 类型 | 描述 | +| ---------- | ------ | -------------------------- | | apiVersion | string | Azure OpenAI 的 API 版本。 | +| apiKey | string | 模型的 API 密钥。 | +| baseURL | string | 模型API端点。 | + +- Type `AWSBedrockKeyVault` -- 类型 `AWSBedrockConfig` -> 继承 `GeneralModelProviderConfig` 中除 `apiKey, endpoint` 外的所有字段 +| 参数 | 类型 | 描述 | +| --------------- | ------ | --------------------------- | +| accessKeyId | string | AWS Bedrock 的访问密钥 ID。 | +| region | string | AWS Bedrock 的区域。 | +| secretAccessKey | string | AWS Bedrock 的访问密钥。 | + +### languageModel + +```ts +export type UserModelProviderConfig = Record; +``` -| 参数 | TS 类型 | 描述 | -|-----------------------|--------------------------|-----------------------------------------------------------------------------| -| accessKeyId | string | AWS Bedrock 的访问密钥 ID。 | -| region | string | AWS Bedrock 的区域。 | -| secretAccessKey | string | AWS Bedrock 的访问密钥。 | +| 参数名称 | 类型 | +| ---------- | -------------- | +| anthropic | `ProviderConfig` | +| azure | `ProviderConfig` | +| bedrock | `ProviderConfig` | +| google | `ProviderConfig` | +| groq | `ProviderConfig` | +| minimax | `ProviderConfig` | +| mistral | `ProviderConfig` | +| moonshot | `ProviderConfig` | +| ollama | `ProviderConfig` | +| openai | `ProviderConfig` | +| openrouter | `ProviderConfig` | +| perplexity | `ProviderConfig` | +| togetherai | `ProviderConfig` | +| zeroone | `ProviderConfig` | +| zhipu | `ProviderConfig` | + +- 类型 `ProviderConfig` + +| 参数 | TS 类型 | 描述 | +| ------------------- | -------- | -------------------------------------------- | +| autoFetchModelLists | boolean | 是否自动获取模型列表。 | +| enabled | boolean | 是否启用该模型。 | +| enabledModels | string[] | 启用的模型的 ID。 | +| fetchOnClient | boolean | 是否在客户端发起请求,默认在服务端发起请求。 | diff --git a/package.json b/package.json index c3e67b45280e..26f62751da2a 100644 --- a/package.json +++ b/package.json @@ -209,7 +209,6 @@ "@types/uuid": "^9.0.8", "@umijs/lint": "^4.2.5", "@vitest/coverage-v8": "~1.2.2", - "ajv": "8.14.0", "ajv-keywords": "^5.1.0", "commitlint": "^19.3.0", "consola": "^3.2.3",