diff --git a/README.es-ES.md b/README.es-ES.md index cd15af9..25518c2 100644 --- a/README.es-ES.md +++ b/README.es-ES.md @@ -51,6 +51,8 @@ docker run --name sqlchat --platform linux/amd64 -env NEXTAUTH_SECRET=xxx -p 300 ### Variables relacionadas con OpenAI: +- `NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY`: Establezca en "verdadero" para permitir a los usuarios traer su propia clave API de OpenAI. + - `OPENAI_API_KEY`: Clave API de OpenAI. Puedes conseguir una [aquí](https://beta.openai.com/docs/developer-quickstart/api-keys). - `OPENAI_API_ENDPOINT`: Endpoint de la API de OpenAI. El predeterminado es `https://api.openai.com`. diff --git a/README.md b/README.md index beb1ab3..2308056 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ docker run --name sqlchat --platform linux/amd64 -env NEXTAUTH_SECRET=xxx -p 300 ### OpenAI related variables: +- `NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY`: Set to `true` to allow users to bring their own OpenAI API key. - `OPENAI_API_KEY`: OpenAI API key. You can get one from [here](https://beta.openai.com/docs/developer-quickstart/api-keys). - `OPENAI_API_ENDPOINT`: OpenAI API endpoint. Defaults to `https://api.openai.com`. diff --git a/README.zh-CN.md b/README.zh-CN.md index f3252e6..9e187e1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -51,6 +51,7 @@ docker run --name sqlchat --platform linux/amd64 -env NEXTAUTH_SECRET=xxx -p 300 ### OpenAI 相关变量: +- `NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY`: 设置为 `true` 如果你允许用户提供自己的 OpenAI API key. - `OPENAI_API_KEY`: OpenAI API Key,通过[这里](https://beta.openai.com/docs/developer-quickstart/api-keys)申请。 - `OPENAI_API_ENDPOINT`: OpenAI API 端点,默认为 `https://api.openai.com`。 diff --git a/process.d.ts b/process.d.ts index ad5d652..4b7cf5a 100644 --- a/process.d.ts +++ b/process.d.ts @@ -6,6 +6,8 @@ declare namespace NodeJS { // We can't prefix DATABASE_URL with NEXT_PUBLIC_ because it contains sensitive information that // should not be exposed to the client. NEXT_PUBLIC_DATABASE_LESS: string; + // Optional. Set to "true" to allow users to bring their own OpenAI API key. + NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY: string; // Required if NEXT_PUBLIC_DATABASE_LESS is false. Postgres database connection string to store // the data. e.g. postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat DATABASE_URL: string; diff --git a/src/components/OpenAIApiConfigView.tsx b/src/components/OpenAIApiConfigView.tsx index 56334f6..a9e00cd 100644 --- a/src/components/OpenAIApiConfigView.tsx +++ b/src/components/OpenAIApiConfigView.tsx @@ -3,9 +3,11 @@ import { useTranslation } from "react-i18next"; import { useDebounce } from "react-use"; import { useSettingStore } from "@/store"; import { OpenAIApiConfig } from "@/types"; +import { allowSelfOpenAIKey } from "@/utils"; import Radio from "./kit/Radio"; import TextField from "./kit/TextField"; import Tooltip from "./kit/Tooltip"; + const OpenAIApiConfigView = () => { const { t } = useTranslation(); const settingStore = useSettingStore(); @@ -75,7 +77,7 @@ const OpenAIApiConfigView = () => {
{t("setting.openai-api-configuration.model-description")}
+ {allowSelfOpenAIKey() &&{t("setting.openai-api-configuration.model-description")}
}{t("setting.openai-api-configuration.key-description")}
-{t("setting.openai-api-configuration.endpoint-description")}
- - {t("setting.openai-api-configuration.find-my-key")} - -{t("setting.openai-api-configuration.key-description")}
+{t("setting.openai-api-configuration.endpoint-description")}
+ + {t("setting.openai-api-configuration.find-my-key")} + +