diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000000..d2c6fc9bb15 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,232 @@ +name: Deploy NextChat to Cloudflare Pages + +# このファイルを NextChat (フォーク後の) リポジトリの .github/workflows/deploy.yml +# として配置してください。main への push で自動デプロイされます。 + +on: + push: + branches: [main] + workflow_dispatch: {} # 手動実行用 + +# 同時実行を1つに制限(Pages側の競合デプロイ防止) +concurrency: + group: cloudflare-pages-deploy + cancel-in-progress: true + +env: + NODE_VERSION: "20.1" + # Cloudflare Pages のプロジェクト名。Terraform の cloudflare_pages_project.name と一致させること + CF_PAGES_PROJECT_NAME: ${{ vars.CF_PAGES_PROJECT_NAME || 'nextchat' }} + # next-on-pages のPages Functionsを動かすのに必須。Terraform側の設定と揃えること + CF_COMPATIBILITY_DATE: "2025-03-07" + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + + # NextChat はバージョンによって yarn / pnpm いずれかを使用しているため + # ロックファイルを見て自動判定する + - name: Detect package manager + id: pm + run: | + if [ -f pnpm-lock.yaml ]; then + echo "manager=pnpm" >> "$GITHUB_OUTPUT" + elif [ -f yarn.lock ]; then + echo "manager=yarn" >> "$GITHUB_OUTPUT" + else + echo "manager=npm" >> "$GITHUB_OUTPUT" + fi + + - name: Enable Corepack (pnpm/yarn) + if: steps.pm.outputs.manager != 'npm' + run: corepack enable + + # NextChat のロックファイルは中国国内ミラー(華為クラウド/淘宝/騰訊等)を + # 参照していることがあり、GitHub Actionsのランナー(中国国外)からは + # 到達性が悪く "Socket connection timeout" で失敗する。 + # ロックファイルに記録された解決済みURLと、レジストリ設定の両方を + # 公式npmレジストリへ強制的に書き換える。 + - name: Normalize registry to official npm (avoid CN mirror timeouts) + run: | + set -e + MIRROR_RE='https://(mirrors\.huaweicloud\.com/repository/npm|repo\.huaweicloud\.com/repository/npm|registry\.npmmirror\.com|registry\.npm\.taobao\.org|mirrors\.cloud\.tencent\.com/npm|mirrors\.tencent\.com/npm|r\.cnpmjs\.org)/?' + + for f in yarn.lock package-lock.json npm-shrinkwrap.json; do + if [ -f "$f" ] && grep -qE "$MIRROR_RE" "$f"; then + echo "Rewriting mirror URLs found in $f" + sed -i -E "s#${MIRROR_RE}#https://registry.npmjs.org/#g" "$f" + fi + done + + # 既存の .yarnrc / .npmrc に registry 指定があれば取り除き、公式レジストリと + # 長めの network-timeout を追記する(新規解決分・再解決分の保険) + if [ -f .yarnrc ]; then + grep -v '^registry ' .yarnrc > .yarnrc.tmp || true + mv .yarnrc.tmp .yarnrc + fi + { + echo 'registry "https://registry.npmjs.org/"' + echo 'network-timeout 300000' + } >> .yarnrc + + if [ -f .npmrc ]; then + grep -v '^registry' .npmrc > .npmrc.tmp || true + mv .npmrc.tmp .npmrc + fi + echo 'registry=https://registry.npmjs.org/' >> .npmrc + + - name: Install dependencies + run: | + set -e + install_cmd() { + case "${{ steps.pm.outputs.manager }}" in + pnpm) pnpm install --frozen-lockfile ;; + yarn) yarn install --frozen-lockfile --network-timeout 300000 ;; + npm) npm ci ;; + esac + } + # 一時的なネットワーク断にも耐えられるよう3回までリトライ + for attempt in 1 2 3; do + if install_cmd; then + exit 0 + fi + echo "Install attempt $attempt failed, retrying in 10s..." + sleep 10 + done + exit 1 + + # NextChat 公式ドキュメント推奨のビルドコマンド。 + # 通常の `next build` は node:buffer 関連の既知バグで Pages 上で動作しないため使用しない。 + - name: Build for Cloudflare Pages (next-on-pages) + run: npx @cloudflare/next-on-pages --experimental-minify + env: + NEXT_TELEMETRY_DISABLE: "1" + # --- NextChat 実行時設定(必要に応じて GitHub Secrets/Variables を追加) --- + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }} + CODE: ${{ secrets.NEXTCHAT_ACCESS_CODE }} + HIDE_USER_API_KEY: ${{ vars.HIDE_USER_API_KEY }} + DISABLE_GPT4: ${{ vars.DISABLE_GPT4 }} + ENABLE_BALANCE_QUERY: ${{ vars.ENABLE_BALANCE_QUERY }} + DISABLE_FAST_LINK: ${{ vars.DISABLE_FAST_LINK }} + + # wrangler pages deploy は対象プロジェクトが存在しないと + # "Project not found [code: 8000007]" で失敗する。CI(非対話環境)では + # 自動作成の確認プロンプトを出せないため、事前に明示的に作成しておく。 + # 既に存在する場合はエラーになるが、それは想定内なのでジョブは継続する + # (本当に認証情報などに問題がある場合は、直後の deploy ステップで + # 同じくエラーになるので気づける)。 + - name: Ensure Cloudflare Pages project exists + continue-on-error: true + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages project create ${{ env.CF_PAGES_PROJECT_NAME }} --production-branch=main --compatibility-date=${{ env.CF_COMPATIBILITY_DATE }} --compatibility-flags=nodejs_compat + + # 【今回のエラーが直らなかった本当の原因】 + # このステップは元々 deploy の"後"に置いていたが、それが間違いだった。 + # Cloudflare Pages は「compatibility flags 等のプロジェクト設定を変更しても、 + # 既に存在するデプロイには遡って適用されない。設定変更後に新しくデプロイし直して + # 初めて反映される」という仕様(公式・非公式の複数の情報源で確認済み。 + # dashboardで設定を変えた場合も同様に "redeploy" が必要と案内されている)。 + # つまり deploy → patch の順序だと、patchで直した内容は「次回以降のデプロイ」 + # にしか効かず、その回に公開されたデプロイ自体は直らないまま残っていた。 + # なので patch を deploy より前に移動し、この設定が反映された状態で + # 新しいデプロイが作られるようにする。 + # + # (方式としては、wrangler.jsonc をデプロイ時に読ませる案も試したが、 + # Cloudflare Pages は設定ファイルを使うとダッシュボード/API側と + # ソースオブトゥルースが競合する仕様があり、next-on-pagesが生成する + # _worker.js 側の設定と衝突して無視される事例が複数報告されていたため、 + # 採用せず Cloudflare API を直接叩く方式にしている) + - name: Enforce nodejs_compat via Cloudflare API + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + run: | + set -e + API="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/${{ env.CF_PAGES_PROJECT_NAME }}" + AUTH_HEADER="Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" + + # 1. 現在のプロジェクト設定を取得する + # (Terraformで設定した環境変数などを上書きで消さないため) + get_code=$(curl -sS -o /tmp/pages-project-current.json -w '%{http_code}' \ + "$API" -H "$AUTH_HEADER") + if [ "$get_code" -ge 300 ]; then + cat /tmp/pages-project-current.json + echo "::error::Cloudflare Pages プロジェクト情報の取得に失敗しました (HTTP $get_code)。CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID を確認してください。" + exit 1 + fi + + # 2. compatibility_date / compatibility_flags だけを上書きしたJSONを作る + # (他の既存項目=環境変数やbinding等はそのまま保持する) + jq --arg date "${{ env.CF_COMPATIBILITY_DATE }}" ' + .result.deployment_configs.production.compatibility_date = $date + | .result.deployment_configs.production.compatibility_flags = ["nodejs_compat"] + | .result.deployment_configs.preview.compatibility_date = $date + | .result.deployment_configs.preview.compatibility_flags = ["nodejs_compat"] + | {deployment_configs: .result.deployment_configs} + ' /tmp/pages-project-current.json > /tmp/pages-compat-patch.json + + # 3. PATCHで反映(これが完了してから、この後のステップでdeployする) + patch_code=$(curl -sS -o /tmp/pages-compat-response.json -w '%{http_code}' -X PATCH \ + "$API" -H "$AUTH_HEADER" -H "Content-Type: application/json" \ + --data @/tmp/pages-compat-patch.json) + + cat /tmp/pages-compat-response.json + echo + success=$(jq -r '.success' /tmp/pages-compat-response.json) + if [ "$patch_code" -ge 300 ] || [ "$success" != "true" ]; then + echo "::error::Cloudflare Pages への compatibility flags 設定(PATCH)に失敗しました (HTTP $patch_code)" + exit 1 + fi + echo "✅ nodejs_compat を production/preview 両方に設定しました(この後デプロイします)" + + # ここで初めてデプロイする。上のステップで nodejs_compat 設定済みのプロジェクトに + # 対して新しいデプロイを作るので、今回のデプロイから正しく反映される。 + - name: Deploy to Cloudflare Pages + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy .vercel/output/static --project-name=${{ env.CF_PAGES_PROJECT_NAME }} --branch=main + + # OPENAI_API_KEY等はビルド成果物に含めず、Pages Functionsの実行時 + # シークレットとして直接登録する(Terraformのstateにも残らない) + # + # 注: GitHub Actionsの仕様上 `secrets` コンテキストは if: 条件式では使えない + # ("Unrecognized named-value: 'secrets'" エラーの原因)。そのためステップ自体は + # 常に実行し、各シークレットの有無はステップ内のシェルスクリプトでチェックする。 + - name: Sync runtime secrets to Cloudflare Pages + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + OPENAI_ORG_ID: ${{ secrets.OPENAI_ORG_ID }} + NEXTCHAT_ACCESS_CODE: ${{ secrets.NEXTCHAT_ACCESS_CODE }} + run: | + set -e + if [ -n "$OPENAI_API_KEY" ]; then + printf '%s' "$OPENAI_API_KEY" | npx wrangler pages secret put OPENAI_API_KEY \ + --project-name="${{ env.CF_PAGES_PROJECT_NAME }}" + fi + if [ -n "$OPENAI_ORG_ID" ]; then + printf '%s' "$OPENAI_ORG_ID" | npx wrangler pages secret put OPENAI_ORG_ID \ + --project-name="${{ env.CF_PAGES_PROJECT_NAME }}" + fi + if [ -n "$NEXTCHAT_ACCESS_CODE" ]; then + printf '%s' "$NEXTCHAT_ACCESS_CODE" | npx wrangler pages secret put CODE \ + --project-name="${{ env.CF_PAGES_PROJECT_NAME }}" + fi diff --git a/.gitignore b/.gitignore index b1c2bfefad3..3846dd5e26d 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,10 @@ masks.json # mcp config app/mcp/mcp_config.json + +terraform.tfvars +*.tfstate +*.tfstate.* +.terraform/ +.terraform.lock.hcl +crash.log diff --git a/README (1).md b/README (1).md new file mode 100644 index 00000000000..75cd74d25b3 --- /dev/null +++ b/README (1).md @@ -0,0 +1,79 @@ +# NextChat → Cloudflare Pages CI/CD 一式 + +NextChat (ChatGPTNextWeb) を Cloudflare Pages に、GitHub Actions + Terraform で +デプロイ/運用するための構成一式です。 + +## 構成 + +``` +.github/workflows/deploy.yml # main push で build → deploy を自動実行 +terraform/ + providers.tf # cloudflare / github プロバイダ + variables.tf # 入力変数 + main.tf # Cloudflare Pagesプロジェクト(Direct Upload) + github_secrets.tf # ★ GitHub Secrets / Variables を自動投入 + outputs.tf + terraform.tfvars.example +``` + +## できること・できないこと(重要) + +- Terraform を **1回 `apply`** すれば、Cloudflare Pages プロジェクトの作成と、 + GitHub Actions が必要とする Secrets(`CLOUDFLARE_API_TOKEN` など)・Variables の + 登録まで自動化されます。ダッシュボードで手動コピペする作業は不要です。 +- ただし **その `terraform apply` を実行する最初の1回だけ**、あなた自身が + Cloudflare API Token と GitHub の Personal Access Token(PAT)を用意する必要が + あります。この「最初の鍵」はどこかの人間が持たなければならず、完全に人手ゼロには + できません(これはTerraform/CI全般に共通する制約です)。 +- OpenAI の API キーのような実行時シークレットは、Terraform の state に残さない + ため、`cloudflare_pages_project` には含めず GitHub Actions の中で + `wrangler pages secret put` により都度同期する設計にしています。 + +## セットアップ手順 + +### 1. 事前準備(あなたが1回だけ行う) + +1. [GitHub](https://github.com/ChatGPTNextWeb/NextChat) の NextChat を Fork する +2. 本一式(`.github/workflows/deploy.yml` と `terraform/`)をForkしたリポジトリに追加してpush +3. Cloudflare API Token を発行([dash.cloudflare.com](https://dash.cloudflare.com/profile/api-tokens) → 「Pages 編集」権限を持つカスタムトークン) +4. GitHub の Fine-grained PAT を発行 + (対象リポジトリに対して **Secrets: Read & write** / **Variables: Read & write** / **Administration: Read & write** 権限) + +### 2. Terraform 実行 + +```bash +cd terraform +cp terraform.tfvars.example terraform.tfvars +# terraform.tfvars を編集して各値を埋める(絶対にコミットしない) + +terraform init +terraform plan +terraform apply +``` + +これで以下が自動的に行われます。 + +- Cloudflare Pages プロジェクト `nextchat` の作成(compatibility flag: `nodejs_compat` 設定済み) +- GitHub Secrets 登録: `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, + `OPENAI_API_KEY`(指定時), `OPENAI_ORG_ID`(指定時), `NEXTCHAT_ACCESS_CODE`(指定時) +- GitHub Variables 登録: `CF_PAGES_PROJECT_NAME`, `HIDE_USER_API_KEY`, + `DISABLE_GPT4`, `ENABLE_BALANCE_QUERY`, `DISABLE_FAST_LINK` + +### 3. デプロイ確認 + +`main` ブランチに push するか、GitHub上で Actions → `Deploy NextChat to Cloudflare Pages` → +`Run workflow` を実行すると、ビルドとデプロイが走ります。 +完了後、Terraformの出力 `pages_default_domain`(`https://.pages.dev`)でアクセスできます。 + +## 補足 + +- Node.js は `20.1`、ビルドコマンドは NextChat 公式ドキュメント推奨の + `npx @cloudflare/next-on-pages --experimental-minify` を使用しています + (通常の `next build` は既知の `node:buffer` バグでPages上では動きません)。 +- ロックファイル(`pnpm-lock.yaml` / `yarn.lock`)を見てパッケージマネージャを + 自動判定するようにしているので、Fork元のバージョン差異に強くしてあります。 +- 独自ドメインを使う場合は `terraform.tfvars` の `custom_domain` を設定してください + (対象ドメインが同じCloudflareアカウントにゾーンとして存在している必要があります)。 +- `terraform.tfstate` には機密値を含む可能性があるため、ローカル保管ではなく + リモートバックエンド(Terraform Cloud等)+アクセス制御を推奨します + (`providers.tf` にコメントアウトの雛形あり)。 diff --git a/README.md b/README.md index 2e45c7120fa..75cd74d25b3 100644 --- a/README.md +++ b/README.md @@ -1,482 +1,79 @@ -
+# NextChat → Cloudflare Pages CI/CD 一式 - - icon - +NextChat (ChatGPTNextWeb) を Cloudflare Pages に、GitHub Actions + Terraform で +デプロイ/運用するための構成一式です。 -

NextChat

+## 構成 -English / [简体中文](./README_CN.md) - -ChatGPTNextWeb%2FChatGPT-Next-Web | Trendshift - -✨ Light and Fast AI Assistant,with Claude, DeepSeek, GPT4 & Gemini Pro support. - -[![Saas][Saas-image]][saas-url] -[![Web][Web-image]][web-url] -[![Windows][Windows-image]][download-url] -[![MacOS][MacOS-image]][download-url] -[![Linux][Linux-image]][download-url] - -[NextChatAI](https://nextchat.club?utm_source=readme) / [iOS APP](https://apps.apple.com/us/app/nextchat-ai/id6743085599) / [Web App Demo](https://app.nextchat.club) / [Desktop App](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) / [Enterprise Edition](#enterprise-edition) - -[saas-url]: https://nextchat.club?utm_source=readme -[saas-image]: https://img.shields.io/badge/NextChat-Saas-green?logo=microsoftedge -[web-url]: https://app.nextchat.club/ -[download-url]: https://github.com/Yidadaa/ChatGPT-Next-Web/releases -[Web-image]: https://img.shields.io/badge/Web-PWA-orange?logo=microsoftedge -[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows -[MacOS-image]: https://img.shields.io/badge/-MacOS-black?logo=apple -[Linux-image]: https://img.shields.io/badge/-Linux-333?logo=ubuntu - -[Deploy on Zeabur](https://zeabur.com/templates/ZBUEFA) [Deploy on Vercel](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FChatGPTNextWeb%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=nextchat&repository-name=NextChat) [Open in Gitpod](https://gitpod.io/#https://github.com/ChatGPTNextWeb/NextChat) [Deploy with your agent](https://opendeploy.dev/github/ChatGPTNextWeb/NextChat) - -[](https://monica.im/?utm=nxcrp) - -
- -## ❤️ Sponsor AI API - - - icon - - -[302.AI](https://302.ai/) is a pay-as-you-go AI application platform that offers the most comprehensive AI APIs and online applications available. - -## 🥳 Cheer for NextChat iOS Version Online! - -> [👉 Click Here to Install Now](https://apps.apple.com/us/app/nextchat-ai/id6743085599) - -> [❤️ Source Code Coming Soon](https://github.com/ChatGPTNextWeb/NextChat-iOS) - -![Github iOS Image](https://github.com/user-attachments/assets/e0aa334f-4c13-4dc9-8310-e3b09fa4b9f3) - -## 🫣 NextChat Support MCP ! - -> Before build, please set env ENABLE_MCP=true - - - -## Enterprise Edition - -Meeting Your Company's Privatization and Customization Deployment Requirements: - -- **Brand Customization**: Tailored VI/UI to seamlessly align with your corporate brand image. -- **Resource Integration**: Unified configuration and management of dozens of AI resources by company administrators, ready for use by team members. -- **Permission Control**: Clearly defined member permissions, resource permissions, and knowledge base permissions, all controlled via a corporate-grade Admin Panel. -- **Knowledge Integration**: Combining your internal knowledge base with AI capabilities, making it more relevant to your company's specific business needs compared to general AI. -- **Security Auditing**: Automatically intercept sensitive inquiries and trace all historical conversation records, ensuring AI adherence to corporate information security standards. -- **Private Deployment**: Enterprise-level private deployment supporting various mainstream private cloud solutions, ensuring data security and privacy protection. -- **Continuous Updates**: Ongoing updates and upgrades in cutting-edge capabilities like multimodal AI, ensuring consistent innovation and advancement. - -For enterprise inquiries, please contact: **business@nextchat.dev** - -## Screenshots - -![Settings](./docs/images/settings.png) - -![More](./docs/images/more.png) - -## Features - -- **Deploy for free with one-click** on Vercel in under 1 minute -- Compact client (~5MB) on Linux/Windows/MacOS, [download it now](https://github.com/Yidadaa/ChatGPT-Next-Web/releases) -- Fully compatible with self-deployed LLMs, recommended for use with [RWKV-Runner](https://github.com/josStorer/RWKV-Runner) or [LocalAI](https://github.com/go-skynet/LocalAI) -- Privacy first, all data is stored locally in the browser -- Markdown support: LaTex, mermaid, code highlight, etc. -- Responsive design, dark mode and PWA -- Fast first screen loading speed (~100kb), support streaming response -- New in v2: create, share and debug your chat tools with prompt templates (mask) -- Awesome prompts powered by [awesome-chatgpt-prompts-zh](https://github.com/PlexPt/awesome-chatgpt-prompts-zh) and [awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-prompts) -- Automatically compresses chat history to support long conversations while also saving your tokens -- I18n: English, 简体中文, 繁体中文, 日本語, Français, Español, Italiano, Türkçe, Deutsch, Tiếng Việt, Русский, Čeština, 한국어, Indonesia - -
- -![主界面](./docs/images/cover.png) - -
- -## Roadmap - -- [x] System Prompt: pin a user defined prompt as system prompt [#138](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/138) -- [x] User Prompt: user can edit and save custom prompts to prompt list -- [x] Prompt Template: create a new chat with pre-defined in-context prompts [#993](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/993) -- [x] Share as image, share to ShareGPT [#1741](https://github.com/Yidadaa/ChatGPT-Next-Web/pull/1741) -- [x] Desktop App with tauri -- [x] Self-host Model: Fully compatible with [RWKV-Runner](https://github.com/josStorer/RWKV-Runner), as well as server deployment of [LocalAI](https://github.com/go-skynet/LocalAI): llama/gpt4all/rwkv/vicuna/koala/gpt4all-j/cerebras/falcon/dolly etc. -- [x] Artifacts: Easily preview, copy and share generated content/webpages through a separate window [#5092](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/pull/5092) -- [x] Plugins: support network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353) - - [x] network search, calculator, any other apis etc. [#165](https://github.com/Yidadaa/ChatGPT-Next-Web/issues/165) [#5353](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5353) -- [x] Supports Realtime Chat [#5672](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5672) -- [ ] local knowledge base - -## What's New - -- 🚀 v2.15.8 Now supports Realtime Chat [#5672](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5672) -- 🚀 v2.15.4 The Application supports using Tauri fetch LLM API, MORE SECURITY! [#5379](https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/issues/5379) -- 🚀 v2.15.0 Now supports Plugins! Read this: [NextChat-Awesome-Plugins](https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins) -- 🚀 v2.14.0 Now supports Artifacts & SD -- 🚀 v2.10.1 support Google Gemini Pro model. -- 🚀 v2.9.11 you can use azure endpoint now. -- 🚀 v2.8 now we have a client that runs across all platforms! -- 🚀 v2.7 let's share conversations as image, or share to ShareGPT! -- 🚀 v2.0 is released, now you can create prompt templates, turn your ideas into reality! Read this: [ChatGPT Prompt Engineering Tips: Zero, One and Few Shot Prompting](https://www.allabtai.com/prompt-engineering-tips-zero-one-and-few-shot-prompting/). - -## Get Started - -1. Get [OpenAI API Key](https://platform.openai.com/account/api-keys); -2. Click - [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FYidadaa%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=chatgpt-next-web&repository-name=ChatGPT-Next-Web), remember that `CODE` is your page password; -3. Enjoy :) - -## FAQ - -[English > FAQ](./docs/faq-en.md) - -## Keep Updated - -If you have deployed your own project with just one click following the steps above, you may encounter the issue of "Updates Available" constantly showing up. This is because Vercel will create a new project for you by default instead of forking this project, resulting in the inability to detect updates correctly. - -We recommend that you follow the steps below to re-deploy: - -- Delete the original repository; -- Use the fork button in the upper right corner of the page to fork this project; -- Choose and deploy in Vercel again, [please see the detailed tutorial](./docs/vercel-cn.md). - -### Enable Automatic Updates - -> If you encounter a failure of Upstream Sync execution, please [manually update code](./README.md#manually-updating-code). - -After forking the project, due to the limitations imposed by GitHub, you need to manually enable Workflows and Upstream Sync Action on the Actions page of the forked project. Once enabled, automatic updates will be scheduled every hour: - -![Automatic Updates](./docs/images/enable-actions.jpg) - -![Enable Automatic Updates](./docs/images/enable-actions-sync.jpg) - -### Manually Updating Code - -If you want to update instantly, you can check out the [GitHub documentation](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) to learn how to synchronize a forked project with upstream code. - -You can star or watch this project or follow author to get release notifications in time. - -## Access Password - -This project provides limited access control. Please add an environment variable named `CODE` on the vercel environment variables page. The value should be passwords separated by comma like this: - -``` -code1,code2,code3 -``` - -After adding or modifying this environment variable, please redeploy the project for the changes to take effect. - -## Environment Variables - -### `CODE` (optional) - -Access password, separated by comma. - -### `OPENAI_API_KEY` (required) - -Your openai api key, join multiple api keys with comma. - -### `BASE_URL` (optional) - -> Default: `https://api.openai.com` - -> Examples: `http://your-openai-proxy.com` - -Override openai api request base url. - -### `OPENAI_ORG_ID` (optional) - -Specify OpenAI organization ID. - -### `AZURE_URL` (optional) - -> Example: https://{azure-resource-url}/openai - -Azure deploy url. - -### `AZURE_API_KEY` (optional) - -Azure Api Key. - -### `AZURE_API_VERSION` (optional) - -Azure Api Version, find it at [Azure Documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions). - -### `GOOGLE_API_KEY` (optional) - -Google Gemini Pro Api Key. - -### `GOOGLE_URL` (optional) - -Google Gemini Pro Api Url. - -### `ANTHROPIC_API_KEY` (optional) - -anthropic claude Api Key. - -### `ANTHROPIC_API_VERSION` (optional) - -anthropic claude Api version. - -### `ANTHROPIC_URL` (optional) - -anthropic claude Api Url. - -### `BAIDU_API_KEY` (optional) - -Baidu Api Key. - -### `BAIDU_SECRET_KEY` (optional) - -Baidu Secret Key. - -### `BAIDU_URL` (optional) - -Baidu Api Url. - -### `BYTEDANCE_API_KEY` (optional) - -ByteDance Api Key. - -### `BYTEDANCE_URL` (optional) - -ByteDance Api Url. - -### `ALIBABA_API_KEY` (optional) - -Alibaba Cloud Api Key. - -### `ALIBABA_URL` (optional) - -Alibaba Cloud Api Url. - -### `IFLYTEK_URL` (Optional) - -iflytek Api Url. - -### `IFLYTEK_API_KEY` (Optional) - -iflytek Api Key. - -### `IFLYTEK_API_SECRET` (Optional) - -iflytek Api Secret. - -### `CHATGLM_API_KEY` (optional) - -ChatGLM Api Key. - -### `CHATGLM_URL` (optional) - -ChatGLM Api Url. - -### `DEEPSEEK_API_KEY` (optional) - -DeepSeek Api Key. - -### `DEEPSEEK_URL` (optional) - -DeepSeek Api Url. - -### `HIDE_USER_API_KEY` (optional) - -> Default: Empty - -If you do not want users to input their own API key, set this value to 1. - -### `DISABLE_GPT4` (optional) - -> Default: Empty - -If you do not want users to use GPT-4, set this value to 1. - -### `ENABLE_BALANCE_QUERY` (optional) - -> Default: Empty - -If you do want users to query balance, set this value to 1. - -### `DISABLE_FAST_LINK` (optional) - -> Default: Empty - -If you want to disable parse settings from url, set this to 1. - -### `CUSTOM_MODELS` (optional) - -> Default: Empty -> Example: `+llama,+claude-2,-gpt-3.5-turbo,gpt-4-1106-preview=gpt-4-turbo` means add `llama, claude-2` to model list, and remove `gpt-3.5-turbo` from list, and display `gpt-4-1106-preview` as `gpt-4-turbo`. - -To control custom models, use `+` to add a custom model, use `-` to hide a model, use `name=displayName` to customize model name, separated by comma. - -User `-all` to disable all default models, `+all` to enable all default models. - -For Azure: use `modelName@Azure=deploymentName` to customize model name and deployment name. - -> Example: `+gpt-3.5-turbo@Azure=gpt35` will show option `gpt35(Azure)` in model list. -> If you only can use Azure model, `-all,+gpt-3.5-turbo@Azure=gpt35` will `gpt35(Azure)` the only option in model list. - -For ByteDance: use `modelName@bytedance=deploymentName` to customize model name and deployment name. - -> Example: `+Doubao-lite-4k@bytedance=ep-xxxxx-xxx` will show option `Doubao-lite-4k(ByteDance)` in model list. - -### `DEFAULT_MODEL` (optional) - -Change default model - -### `VISION_MODELS` (optional) - -> Default: Empty -> Example: `gpt-4-vision,claude-3-opus,my-custom-model` means add vision capabilities to these models in addition to the default pattern matches (which detect models containing keywords like "vision", "claude-3", "gemini-1.5", etc). - -Add additional models to have vision capabilities, beyond the default pattern matching. Multiple models should be separated by commas. - -### `WHITE_WEBDAV_ENDPOINTS` (optional) - -You can use this option if you want to increase the number of webdav service addresses you are allowed to access, as required by the format: - -- Each address must be a complete endpoint - > `https://xxxx/yyy` -- Multiple addresses are connected by ', ' - -### `DEFAULT_INPUT_TEMPLATE` (optional) - -Customize the default template used to initialize the User Input Preprocessing configuration item in Settings. - -### `STABILITY_API_KEY` (optional) - -Stability API key. - -### `STABILITY_URL` (optional) - -Customize Stability API url. - -### `ENABLE_MCP` (optional) - -Enable MCP(Model Context Protocol)Feature - -### `SILICONFLOW_API_KEY` (optional) - -SiliconFlow API Key. - -### `SILICONFLOW_URL` (optional) - -SiliconFlow API URL. - -### `AI302_API_KEY` (optional) - -302.AI API Key. - -### `AI302_URL` (optional) - -302.AI API URL. - -## Requirements - -NodeJS >= 18, Docker >= 20 - -## Development - -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/Yidadaa/ChatGPT-Next-Web) - -Before starting development, you must create a new `.env.local` file at project root, and place your api key into it: - -``` -OPENAI_API_KEY= - -# if you are not able to access openai service, use this BASE_URL -BASE_URL=https://chatgpt1.nextweb.fun/api/proxy ``` - -### Local Development - -```shell -# 1. install nodejs and yarn first -# 2. config local env vars in `.env.local` -# 3. run -yarn install -yarn dev +.github/workflows/deploy.yml # main push で build → deploy を自動実行 +terraform/ + providers.tf # cloudflare / github プロバイダ + variables.tf # 入力変数 + main.tf # Cloudflare Pagesプロジェクト(Direct Upload) + github_secrets.tf # ★ GitHub Secrets / Variables を自動投入 + outputs.tf + terraform.tfvars.example ``` -## Deployment - -### Docker (Recommended) +## できること・できないこと(重要) -```shell -docker pull yidadaa/chatgpt-next-web - -docker run -d -p 3000:3000 \ - -e OPENAI_API_KEY=sk-xxxx \ - -e CODE=your-password \ - yidadaa/chatgpt-next-web -``` - -You can start service behind a proxy: - -```shell -docker run -d -p 3000:3000 \ - -e OPENAI_API_KEY=sk-xxxx \ - -e CODE=your-password \ - -e PROXY_URL=http://localhost:7890 \ - yidadaa/chatgpt-next-web -``` +- Terraform を **1回 `apply`** すれば、Cloudflare Pages プロジェクトの作成と、 + GitHub Actions が必要とする Secrets(`CLOUDFLARE_API_TOKEN` など)・Variables の + 登録まで自動化されます。ダッシュボードで手動コピペする作業は不要です。 +- ただし **その `terraform apply` を実行する最初の1回だけ**、あなた自身が + Cloudflare API Token と GitHub の Personal Access Token(PAT)を用意する必要が + あります。この「最初の鍵」はどこかの人間が持たなければならず、完全に人手ゼロには + できません(これはTerraform/CI全般に共通する制約です)。 +- OpenAI の API キーのような実行時シークレットは、Terraform の state に残さない + ため、`cloudflare_pages_project` には含めず GitHub Actions の中で + `wrangler pages secret put` により都度同期する設計にしています。 -If your proxy needs password, use: +## セットアップ手順 -```shell --e PROXY_URL="http://127.0.0.1:7890 user pass" -``` +### 1. 事前準備(あなたが1回だけ行う) -If enable MCP, use: +1. [GitHub](https://github.com/ChatGPTNextWeb/NextChat) の NextChat を Fork する +2. 本一式(`.github/workflows/deploy.yml` と `terraform/`)をForkしたリポジトリに追加してpush +3. Cloudflare API Token を発行([dash.cloudflare.com](https://dash.cloudflare.com/profile/api-tokens) → 「Pages 編集」権限を持つカスタムトークン) +4. GitHub の Fine-grained PAT を発行 + (対象リポジトリに対して **Secrets: Read & write** / **Variables: Read & write** / **Administration: Read & write** 権限) -``` -docker run -d -p 3000:3000 \ - -e OPENAI_API_KEY=sk-xxxx \ - -e CODE=your-password \ - -e ENABLE_MCP=true \ - yidadaa/chatgpt-next-web -``` +### 2. Terraform 実行 -### Shell +```bash +cd terraform +cp terraform.tfvars.example terraform.tfvars +# terraform.tfvars を編集して各値を埋める(絶対にコミットしない) -```shell -bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/scripts/setup.sh) +terraform init +terraform plan +terraform apply ``` -## Synchronizing Chat Records (UpStash) - -| [简体中文](./docs/synchronise-chat-logs-cn.md) | [English](./docs/synchronise-chat-logs-en.md) | [Italiano](./docs/synchronise-chat-logs-es.md) | [日本語](./docs/synchronise-chat-logs-ja.md) | [한국어](./docs/synchronise-chat-logs-ko.md) - -## Documentation - -> Please go to the [docs][./docs] directory for more documentation instructions. - -- [Deploy with cloudflare (Deprecated)](./docs/cloudflare-pages-en.md) -- [Frequent Ask Questions](./docs/faq-en.md) -- [How to add a new translation](./docs/translation.md) -- [How to use Vercel (No English)](./docs/vercel-cn.md) -- [User Manual (Only Chinese, WIP)](./docs/user-manual-cn.md) - -## Translation - -If you want to add a new translation, read this [document](./docs/translation.md). - -## Donation - -[Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) +これで以下が自動的に行われます。 -## Special Thanks +- Cloudflare Pages プロジェクト `nextchat` の作成(compatibility flag: `nodejs_compat` 設定済み) +- GitHub Secrets 登録: `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, + `OPENAI_API_KEY`(指定時), `OPENAI_ORG_ID`(指定時), `NEXTCHAT_ACCESS_CODE`(指定時) +- GitHub Variables 登録: `CF_PAGES_PROJECT_NAME`, `HIDE_USER_API_KEY`, + `DISABLE_GPT4`, `ENABLE_BALANCE_QUERY`, `DISABLE_FAST_LINK` -### Contributors +### 3. デプロイ確認 - - - +`main` ブランチに push するか、GitHub上で Actions → `Deploy NextChat to Cloudflare Pages` → +`Run workflow` を実行すると、ビルドとデプロイが走ります。 +完了後、Terraformの出力 `pages_default_domain`(`https://.pages.dev`)でアクセスできます。 -## LICENSE +## 補足 -[MIT](https://opensource.org/license/mit/) +- Node.js は `20.1`、ビルドコマンドは NextChat 公式ドキュメント推奨の + `npx @cloudflare/next-on-pages --experimental-minify` を使用しています + (通常の `next build` は既知の `node:buffer` バグでPages上では動きません)。 +- ロックファイル(`pnpm-lock.yaml` / `yarn.lock`)を見てパッケージマネージャを + 自動判定するようにしているので、Fork元のバージョン差異に強くしてあります。 +- 独自ドメインを使う場合は `terraform.tfvars` の `custom_domain` を設定してください + (対象ドメインが同じCloudflareアカウントにゾーンとして存在している必要があります)。 +- `terraform.tfstate` には機密値を含む可能性があるため、ローカル保管ではなく + リモートバックエンド(Terraform Cloud等)+アクセス制御を推奨します + (`providers.tf` にコメントアウトの雛形あり)。 diff --git a/terraform/.gitignore b/terraform/.gitignore new file mode 100644 index 00000000000..056b4faf098 --- /dev/null +++ b/terraform/.gitignore @@ -0,0 +1,6 @@ +terraform.tfvars +*.tfstate +*.tfstate.* +.terraform/ +.terraform.lock.hcl +crash.log diff --git a/terraform/github_secrets.tf b/terraform/github_secrets.tf new file mode 100644 index 00000000000..879bec0ab43 --- /dev/null +++ b/terraform/github_secrets.tf @@ -0,0 +1,74 @@ +############################################ +# GitHub Actions Secrets(暗号化されリポジトリに保存される) +# +# ここが今回の「シークレット設定の自動化」の本体。 +# `terraform apply` を1回実行するだけで、GitHub Actionsの +# deploy.yml が参照する secrets.* が全て設定される。 +############################################ + +resource "github_actions_secret" "cloudflare_api_token" { + repository = var.github_repo + secret_name = "CLOUDFLARE_API_TOKEN" + plaintext_value = var.cloudflare_api_token +} + +resource "github_actions_secret" "cloudflare_account_id" { + repository = var.github_repo + secret_name = "CLOUDFLARE_ACCOUNT_ID" + plaintext_value = var.cloudflare_account_id +} + +resource "github_actions_secret" "openai_api_key" { + count = var.openai_api_key != "" ? 1 : 0 + repository = var.github_repo + secret_name = "OPENAI_API_KEY" + plaintext_value = var.openai_api_key +} + +resource "github_actions_secret" "openai_org_id" { + count = var.openai_org_id != "" ? 1 : 0 + repository = var.github_repo + secret_name = "OPENAI_ORG_ID" + plaintext_value = var.openai_org_id +} + +resource "github_actions_secret" "nextchat_access_code" { + count = var.nextchat_access_code != "" ? 1 : 0 + repository = var.github_repo + secret_name = "NEXTCHAT_ACCESS_CODE" + plaintext_value = var.nextchat_access_code +} + +############################################ +# GitHub Actions Variables(平文でよい設定値。Actionsのvars.*で参照) +############################################ + +resource "github_actions_variable" "cf_pages_project_name" { + repository = var.github_repo + variable_name = "CF_PAGES_PROJECT_NAME" + value = var.project_name +} + +resource "github_actions_variable" "hide_user_api_key" { + repository = var.github_repo + variable_name = "HIDE_USER_API_KEY" + value = var.hide_user_api_key +} + +resource "github_actions_variable" "disable_gpt4" { + repository = var.github_repo + variable_name = "DISABLE_GPT4" + value = var.disable_gpt4 +} + +resource "github_actions_variable" "enable_balance_query" { + repository = var.github_repo + variable_name = "ENABLE_BALANCE_QUERY" + value = var.enable_balance_query +} + +resource "github_actions_variable" "disable_fast_link" { + repository = var.github_repo + variable_name = "DISABLE_FAST_LINK" + value = var.disable_fast_link +} diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 00000000000..c30a88d68fa --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,57 @@ +############################################ +# Cloudflare Pages プロジェクト(Direct Upload方式) +# +# GitHub Actions 側で `next-on-pages` によるビルドと +# `wrangler pages deploy` を行う構成のため、ここでは +# Git連携(source ブロック)は張らず、箱(プロジェクト)と +# ランタイム設定(環境変数・互換フラグ)だけを Terraform で管理する。 +############################################ + +resource "cloudflare_pages_project" "nextchat" { + account_id = var.cloudflare_account_id + name = var.project_name + production_branch = var.production_branch + + deployment_configs { + production { + compatibility_date = "2025-03-07" + compatibility_flags = ["nodejs_compat"] + + environment_variables = { + NODE_VERSION = "20.1" + NEXT_TELEMETRY_DISABLE = "1" + HIDE_USER_API_KEY = var.hide_user_api_key + DISABLE_GPT4 = var.disable_gpt4 + ENABLE_BALANCE_QUERY = var.enable_balance_query + DISABLE_FAST_LINK = var.disable_fast_link + } + } + + preview { + compatibility_date = "2025-03-07" + compatibility_flags = ["nodejs_compat"] + + environment_variables = { + NODE_VERSION = "20.1" + NEXT_TELEMETRY_DISABLE = "1" + } + } + } + + lifecycle { + # OPENAI_API_KEY 等の秘匿値は Terraform では管理しない + # (README参照: `wrangler pages secret put` で登録する) + ignore_changes = [] + } +} + +############################################ +# 独自ドメイン(任意) +############################################ + +resource "cloudflare_pages_domain" "custom_domain" { + count = var.custom_domain != "" ? 1 : 0 + account_id = var.cloudflare_account_id + project_name = cloudflare_pages_project.nextchat.name + domain = var.custom_domain +} diff --git a/terraform/outputs.tf b/terraform/outputs.tf new file mode 100644 index 00000000000..5a3d6a9b00b --- /dev/null +++ b/terraform/outputs.tf @@ -0,0 +1,23 @@ +output "pages_project_name" { + value = cloudflare_pages_project.nextchat.name +} + +output "pages_default_domain" { + description = "*.pages.dev のデフォルトURL" + value = "https://${cloudflare_pages_project.nextchat.name}.pages.dev" +} + +output "pages_custom_domain" { + value = var.custom_domain != "" ? var.custom_domain : "未設定" +} + +output "github_secrets_configured" { + description = "自動投入されたGitHub Actions Secretsの一覧" + value = compact([ + "CLOUDFLARE_API_TOKEN", + "CLOUDFLARE_ACCOUNT_ID", + var.openai_api_key != "" ? "OPENAI_API_KEY" : "", + var.openai_org_id != "" ? "OPENAI_ORG_ID" : "", + var.nextchat_access_code != "" ? "NEXTCHAT_ACCESS_CODE" : "", + ]) +} diff --git a/terraform/providers.tf b/terraform/providers.tf new file mode 100644 index 00000000000..97f5368a75f --- /dev/null +++ b/terraform/providers.tf @@ -0,0 +1,31 @@ +terraform { + required_version = ">= 1.6.0" + + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + version = "~> 4.40" + } + github = { + source = "integrations/github" + version = "~> 6.3" + } + } + + # 状態ファイルをローカルに残したくない場合はリモートバックエンドを推奨 + # (例: Cloudflare R2 を backend "s3" 互換で使う、または Terraform Cloud) + # backend "s3" { + # bucket = "your-tfstate-bucket" + # key = "nextchat/terraform.tfstate" + # ... + # } +} + +provider "cloudflare" { + api_token = var.cloudflare_api_token +} + +provider "github" { + token = var.github_token + owner = var.github_owner +} diff --git a/terraform/terraform.tfvars.example b/terraform/terraform.tfvars.example new file mode 100644 index 00000000000..0c6fe160136 --- /dev/null +++ b/terraform/terraform.tfvars.example @@ -0,0 +1,23 @@ +# このファイルを terraform.tfvars にコピーして値を埋め、 +# 【絶対にgitにコミットしない】こと(.gitignore済み)。 +# CIで実行する場合は TF_VAR_xxx 環境変数として渡す方法を推奨。 + +cloudflare_api_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +cloudflare_account_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + +github_token = "github_pat_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +github_owner = "your-github-user-or-org" +github_repo = "NextChat" # フォークしたリポジトリ名 + +project_name = "nextchat" +production_branch = "main" +custom_domain = "" # 例: "chat.example.com"(Cloudflareにゾーンがある場合のみ) + +openai_api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +openai_org_id = "" +nextchat_access_code = "" # 例: "pass1,pass2" + +hide_user_api_key = "0" +disable_gpt4 = "0" +enable_balance_query = "0" +disable_fast_link = "0" diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 00000000000..1481960e981 --- /dev/null +++ b/terraform/variables.tf @@ -0,0 +1,101 @@ +############################################ +# ブートストラップ用クレデンシャル +# (terraform apply を実行するあなたの手元/CI にのみ必要。リポジトリにはコミットしない) +############################################ + +variable "cloudflare_api_token" { + description = "Cloudflare API Token (Pages:Edit, Account:Read 権限が必要)" + type = string + sensitive = true +} + +variable "cloudflare_account_id" { + description = "Cloudflare Account ID" + type = string +} + +variable "github_token" { + description = "GitHub Personal Access Token (Fine-grained PAT: repo administration + secrets 書き込み権限)" + type = string + sensitive = true +} + +variable "github_owner" { + description = "GitHubのユーザー名 or Organization名" + type = string +} + +variable "github_repo" { + description = "NextChatをフォークしたリポジトリ名" + type = string +} + +############################################ +# Cloudflare Pages プロジェクト設定 +############################################ + +variable "project_name" { + description = "Cloudflare Pages のプロジェクト名(deploy.ymlのCF_PAGES_PROJECT_NAMEと一致させる)" + type = string + default = "nextchat" +} + +variable "production_branch" { + description = "本番デプロイ対象のGitブランチ" + type = string + default = "main" +} + +variable "custom_domain" { + description = "独自ドメインを割り当てる場合に指定(未指定なら *.pages.dev のみ)" + type = string + default = "" +} + +############################################ +# NextChat アプリケーション設定(Secretsとして GitHub に登録される) +############################################ + +variable "openai_api_key" { + description = "NextChatが使用するOpenAI APIキー" + type = string + sensitive = true + default = "" +} + +variable "openai_org_id" { + description = "OpenAI Organization ID(任意)" + type = string + default = "" +} + +variable "nextchat_access_code" { + description = "NextChatのアクセスパスワード(CODE環境変数、カンマ区切りで複数可・任意)" + type = string + sensitive = true + default = "" +} + +variable "hide_user_api_key" { + description = "1にするとユーザーが自分のAPIキーを入力できなくなる(任意)" + type = string + default = "0" +} + +variable "disable_gpt4" { + description = "1にするとGPT-4の利用を禁止する(任意)" + type = string + default = "0" +} + +variable "enable_balance_query" { + description = "1にすると残高照会を許可する(任意)" + type = string + default = "0" +} + +variable "disable_fast_link" { + description = "1にするとURL経由の設定読み込みを無効化する(任意)" + type = string + default = "0" +}