├── .eslintignore ├── scripts ├── .gitignore ├── proxychains.template.conf ├── init-proxy.sh ├── setup.sh └── fetch-prompts.mjs ├── public ├── robots.txt ├── logo.png ├── macos.png ├── favicon.ico ├── thumbnail.png ├── favicon-16x16.png ├── favicon-32x32.png ├── apple-touch-icon.png ├── favicons │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── mstile-150x150.png │ ├── apple-touch-icon.png │ ├── android-chrome-192x192.png │ ├── android-chrome-256x256.png │ └── browserconfig.xml ├── android-chrome-1x1.png ├── android-chrome-2x2.png ├── android-chrome-4x4.png ├── android-chrome-8x8.png ├── prompts-2128x2128.png ├── android-chrome-16x16.png ├── android-chrome-32x32.png ├── android-chrome-64x64.png ├── android-chrome-114x114.png ├── android-chrome-128x128.png ├── android-chrome-192x192.png ├── android-chrome-256x256.png ├── android-chrome-512x512.png ├── android-chrome-1024x1024.png ├── android-chrome-2048x2048.png ├── android-chrome-3120x3120.png ├── serviceWorkerRegister.js ├── serviceWorker.js └── site.webmanifest ├── src-tauri ├── build.rs ├── .gitignore ├── icons │ ├── icon.ico │ ├── icon.png │ ├── 128x128.png │ ├── 32x32.png │ ├── icon.icns │ ├── StoreLogo.png │ ├── 128x128@2x.png │ ├── Square107x107Logo.png │ ├── Square142x142Logo.png │ ├── Square150x150Logo.png │ ├── Square284x284Logo.png │ ├── Square30x30Logo.png │ ├── Square310x310Logo.png │ ├── Square44x44Logo.png │ ├── Square71x71Logo.png │ └── Square89x89Logo.png ├── src │ └── main.rs ├── Cargo.toml └── tauri.conf.json ├── app ├── typing.ts ├── icons │ ├── bot.png │ ├── mask.png │ ├── chatgpt.png │ ├── black-bot.png │ ├── down.svg │ ├── left.svg │ ├── share.svg │ ├── bottom.svg │ ├── dark.svg │ ├── rename.svg │ ├── copy.svg │ ├── menu.svg │ ├── close.svg │ ├── send-white.svg │ ├── pause.svg │ ├── return.svg │ ├── add.svg │ ├── three-dots.svg │ ├── export.svg │ ├── settings.svg │ ├── prompt.svg │ ├── clear.svg │ ├── auto.svg │ ├── eye.svg │ ├── reload.svg │ ├── edit.svg │ ├── mask.svg │ ├── chat.svg │ ├── download.svg │ ├── brain.svg │ ├── github.svg │ ├── eye-off.svg │ ├── max.svg │ ├── min.svg │ ├── confirm.svg │ ├── light.svg │ ├── plugin.svg │ ├── lightning.svg │ ├── cancel.svg │ ├── chatgpt.svg │ ├── black-bot.svg │ └── bot.svg ├── store │ ├── index.ts │ ├── sync.ts │ ├── access.ts │ ├── mask.ts │ └── update.ts ├── masks │ ├── typing.ts │ └── index.ts ├── utils │ ├── merge.ts │ ├── format.ts │ └── token.ts ├── components │ ├── input-range.module.scss │ ├── auth.module.scss │ ├── input-range.tsx │ ├── button.tsx │ ├── auth.tsx.bak │ ├── auth.tsx-30.bak │ ├── settings.module.scss │ ├── message-selector.module.scss │ ├── auth.tsx │ ├── emoji.tsx │ ├── button.module.scss │ ├── error.tsx │ ├── mask.module.scss │ └── new-chat.module.scss ├── page.tsx ├── global.d.ts ├── styles │ ├── animation.scss │ ├── window.scss │ └── highlight.scss ├── config │ ├── client.ts │ ├── build.ts │ └── server.ts ├── polyfill.ts ├── api │ ├── config │ │ └── route.ts │ ├── auth.ts.bak │ ├── auth.ts │ ├── auth.ts-30.bak │ ├── auth.ts.bak.def │ ├── openai │ │ └── [...path] │ │ │ └── route.ts │ └── common.ts ├── client │ ├── controller.ts │ ├── api.ts │ └── api.ts.bak ├── command.ts ├── locales │ └── index.ts ├── layout.tsx ├── constant.ts └── layout.tsx.bak ├── .eslintrc.json ├── .husky └── pre-commit ├── docs ├── images │ ├── cover.png │ ├── icon.png │ ├── more.png │ ├── ch-tr-pr.jpg │ ├── settings.png │ ├── enable-actions.jpg │ ├── enable-actions-sync.jpg │ ├── vercel │ │ ├── vercel-create-1.jpg │ │ ├── vercel-create-2.jpg │ │ ├── vercel-create-3.jpg │ │ ├── vercel-env-edit.jpg │ │ └── vercel-redeploy.jpg │ └── icon.svg ├── vercel-cn.md ├── cloudflare-pages-cn.md ├── cloudflare-pages-en.md ├── cloudflare-pages-es.md └── vercel-es.md ├── .lintstagedrc.json ├── .prettierrc.js ├── .gitpod.yml ├── .github ├── ISSUE_TEMPLATE │ ├── 功能建议.md │ ├── feature_request.md │ ├── bug_report.md │ └── 反馈问题.md ├── dependabot.yml └── FUNDING.yml ├── vercel.json ├── .gitignore ├── tsconfig.json ├── docker-compose.yml ├── .env.template ├── Dockerfile ├── package.json ├── next.config.mjs ├── next.config.mjs.bak └── LICENSE /.eslintignore: -------------------------------------------------------------------------------- 1 | public/serviceWorker.js -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | proxychains.conf 2 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /src-tauri/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | tauri_build::build() 3 | } 4 | -------------------------------------------------------------------------------- /app/typing.ts: -------------------------------------------------------------------------------- 1 | export type Updater = (updater: (value: T) => void) => void; 2 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals", 3 | "plugins": ["prettier"] 4 | } 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx lint-staged -------------------------------------------------------------------------------- /app/icons/bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/app/icons/bot.png -------------------------------------------------------------------------------- /public/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/logo.png -------------------------------------------------------------------------------- /public/macos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/macos.png -------------------------------------------------------------------------------- /app/icons/mask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/app/icons/mask.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src-tauri/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | -------------------------------------------------------------------------------- /app/icons/chatgpt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/app/icons/chatgpt.png -------------------------------------------------------------------------------- /docs/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/cover.png -------------------------------------------------------------------------------- /docs/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/icon.png -------------------------------------------------------------------------------- /docs/images/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/more.png -------------------------------------------------------------------------------- /public/thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/thumbnail.png -------------------------------------------------------------------------------- /app/icons/black-bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/app/icons/black-bot.png -------------------------------------------------------------------------------- /docs/images/ch-tr-pr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/ch-tr-pr.jpg -------------------------------------------------------------------------------- /docs/images/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/settings.png -------------------------------------------------------------------------------- /public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicon-32x32.png -------------------------------------------------------------------------------- /src-tauri/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/icon.ico -------------------------------------------------------------------------------- /src-tauri/icons/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/icon.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/favicon.ico -------------------------------------------------------------------------------- /src-tauri/icons/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/128x128.png -------------------------------------------------------------------------------- /src-tauri/icons/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/32x32.png -------------------------------------------------------------------------------- /src-tauri/icons/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/icon.icns -------------------------------------------------------------------------------- /public/android-chrome-1x1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-1x1.png -------------------------------------------------------------------------------- /public/android-chrome-2x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-2x2.png -------------------------------------------------------------------------------- /public/android-chrome-4x4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-4x4.png -------------------------------------------------------------------------------- /public/android-chrome-8x8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-8x8.png -------------------------------------------------------------------------------- /public/prompts-2128x2128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/prompts-2128x2128.png -------------------------------------------------------------------------------- /src-tauri/icons/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/StoreLogo.png -------------------------------------------------------------------------------- /docs/images/enable-actions.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/enable-actions.jpg -------------------------------------------------------------------------------- /public/android-chrome-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-16x16.png -------------------------------------------------------------------------------- /public/android-chrome-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-32x32.png -------------------------------------------------------------------------------- /public/android-chrome-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-64x64.png -------------------------------------------------------------------------------- /src-tauri/icons/128x128@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/128x128@2x.png -------------------------------------------------------------------------------- /app/store/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./chat"; 2 | export * from "./update"; 3 | export * from "./access"; 4 | export * from "./config"; 5 | -------------------------------------------------------------------------------- /public/android-chrome-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-114x114.png -------------------------------------------------------------------------------- /public/android-chrome-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-128x128.png -------------------------------------------------------------------------------- /public/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/android-chrome-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-256x256.png -------------------------------------------------------------------------------- /public/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-512x512.png -------------------------------------------------------------------------------- /public/favicons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/favicon-32x32.png -------------------------------------------------------------------------------- /public/favicons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/mstile-150x150.png -------------------------------------------------------------------------------- /docs/images/enable-actions-sync.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/enable-actions-sync.jpg -------------------------------------------------------------------------------- /public/android-chrome-1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-1024x1024.png -------------------------------------------------------------------------------- /public/android-chrome-2048x2048.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-2048x2048.png -------------------------------------------------------------------------------- /public/android-chrome-3120x3120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/android-chrome-3120x3120.png -------------------------------------------------------------------------------- /public/favicons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/apple-touch-icon.png -------------------------------------------------------------------------------- /src-tauri/icons/Square107x107Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square107x107Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square142x142Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square142x142Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square150x150Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square150x150Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square284x284Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square284x284Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square30x30Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square30x30Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square310x310Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square310x310Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square44x44Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square44x44Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square71x71Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square71x71Logo.png -------------------------------------------------------------------------------- /src-tauri/icons/Square89x89Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/src-tauri/icons/Square89x89Logo.png -------------------------------------------------------------------------------- /.lintstagedrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "./app/**/*.{js,ts,jsx,tsx,json,html,css,md}": [ 3 | "eslint --fix", 4 | "prettier --write" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /docs/images/vercel/vercel-create-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/vercel/vercel-create-1.jpg -------------------------------------------------------------------------------- /docs/images/vercel/vercel-create-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/vercel/vercel-create-2.jpg -------------------------------------------------------------------------------- /docs/images/vercel/vercel-create-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/vercel/vercel-create-3.jpg -------------------------------------------------------------------------------- /docs/images/vercel/vercel-env-edit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/vercel/vercel-env-edit.jpg -------------------------------------------------------------------------------- /docs/images/vercel/vercel-redeploy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/docs/images/vercel/vercel-redeploy.jpg -------------------------------------------------------------------------------- /public/favicons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/favicons/android-chrome-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imabutahersiddik/Ultimate-ChatGPT/HEAD/public/favicons/android-chrome-256x256.png -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 80, 3 | tabWidth: 2, 4 | useTabs: false, 5 | semi: true, 6 | singleQuote: false, 7 | trailingComma: 'all', 8 | bracketSpacing: true, 9 | arrowParens: 'always', 10 | }; 11 | -------------------------------------------------------------------------------- /app/masks/typing.ts: -------------------------------------------------------------------------------- 1 | import { ModelConfig } from "../store"; 2 | import { type Mask } from "../store/mask"; 3 | 4 | export type BuiltinMask = Omit & { 5 | builtin: Boolean; 6 | modelConfig: Partial; 7 | }; 8 | -------------------------------------------------------------------------------- /scripts/proxychains.template.conf: -------------------------------------------------------------------------------- 1 | strict_chain 2 | proxy_dns 3 | 4 | remote_dns_subnet 224 5 | 6 | tcp_read_time_out 15000 7 | tcp_connect_time_out 8000 8 | 9 | localnet 127.0.0.0/255.0.0.0 10 | 11 | [ProxyList] 12 | socks4 127.0.0.1 9050 13 | -------------------------------------------------------------------------------- /scripts/init-proxy.sh: -------------------------------------------------------------------------------- 1 | dir="$(dirname "$0")" 2 | config=$dir/proxychains.conf 3 | host_ip=$(grep nameserver /etc/resolv.conf | sed 's/nameserver //') 4 | echo "proxying to $host_ip" 5 | cp $dir/proxychains.template.conf $config 6 | sed -i "\$s/.*/http $host_ip 7890/" $config 7 | -------------------------------------------------------------------------------- /public/favicons/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/utils/merge.ts: -------------------------------------------------------------------------------- 1 | export function merge(target: any, source: any) { 2 | Object.keys(source).forEach(function (key) { 3 | if (source[key] && typeof source[key] === "object") { 4 | merge((target[key] = target[key] || {}), source[key]); 5 | return; 6 | } 7 | target[key] = source[key]; 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /app/components/input-range.module.scss: -------------------------------------------------------------------------------- 1 | .input-range { 2 | border: var(--border-in-light); 3 | border-radius: 10px; 4 | padding: 5px 10px 5px 10px; 5 | font-size: 12px; 6 | display: flex; 7 | justify-content: space-between; 8 | max-width: 40%; 9 | 10 | input[type="range"] { 11 | max-width: calc(100% - 34px); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/utils/format.ts: -------------------------------------------------------------------------------- 1 | export function prettyObject(msg: any) { 2 | const obj = msg; 3 | if (typeof msg !== "string") { 4 | msg = JSON.stringify(msg, null, " "); 5 | } 6 | if (msg === "{}") { 7 | return obj.toString(); 8 | } 9 | if (msg.startsWith("```json")) { 10 | return msg; 11 | } 12 | return ["```json", msg, "```"].join("\n"); 13 | } 14 | -------------------------------------------------------------------------------- /src-tauri/src/main.rs: -------------------------------------------------------------------------------- 1 | // Prevents additional console window on Windows in release, DO NOT REMOVE!! 2 | #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] 3 | 4 | fn main() { 5 | tauri::Builder::default() 6 | .plugin(tauri_plugin_window_state::Builder::default().build()) 7 | .run(tauri::generate_context!()) 8 | .expect("error while running tauri application"); 9 | } 10 | -------------------------------------------------------------------------------- /app/page.tsx: -------------------------------------------------------------------------------- 1 | import { Analytics } from "@vercel/analytics/react"; 2 | 3 | import { Home } from "./components/home"; 4 | 5 | import { getServerSideConfig } from "./config/server"; 6 | 7 | const serverConfig = getServerSideConfig(); 8 | 9 | export default async function App() { 10 | return ( 11 | <> 12 | 13 | {serverConfig?.isVercel && } 14 | 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /public/serviceWorkerRegister.js: -------------------------------------------------------------------------------- 1 | if ('serviceWorker' in navigator) { 2 | window.addEventListener('load', function () { 3 | navigator.serviceWorker.register('/serviceWorker.js').then(function (registration) { 4 | console.log('ServiceWorker registration successful with scope: ', registration.scope); 5 | }, function (err) { 6 | console.error('ServiceWorker registration failed: ', err); 7 | }); 8 | }); 9 | } -------------------------------------------------------------------------------- /app/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.jpg"; 2 | declare module "*.png"; 3 | declare module "*.woff2"; 4 | declare module "*.woff"; 5 | declare module "*.ttf"; 6 | declare module "*.scss" { 7 | const content: Record; 8 | export default content; 9 | } 10 | 11 | declare module "*.svg"; 12 | 13 | declare interface Window { 14 | __TAURI__?: { 15 | writeText(text: string): Promise; 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /app/styles/animation.scss: -------------------------------------------------------------------------------- 1 | @keyframes slide-in { 2 | from { 3 | opacity: 0; 4 | transform: translateY(20px); 5 | } 6 | 7 | to { 8 | opacity: 1; 9 | transform: translateY(0px); 10 | } 11 | } 12 | 13 | @keyframes slide-in-from-top { 14 | from { 15 | opacity: 0; 16 | transform: translateY(-20px); 17 | } 18 | 19 | to { 20 | opacity: 1; 21 | transform: translateY(0px); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /public/serviceWorker.js: -------------------------------------------------------------------------------- 1 | const CHATGPT_CACHE = "chatgpt-cache"; 2 | 3 | self.addEventListener("activate", function (event) { 4 | console.log("ServiceWorker activated."); 5 | }); 6 | 7 | self.addEventListener("install", function (event) { 8 | event.waitUntil( 9 | caches.open(CHATGPT_CACHE).then(function (cache) { 10 | return cache.addAll([]); 11 | }), 12 | ); 13 | }); 14 | 15 | self.addEventListener("fetch", (e) => {}); 16 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | # This configuration file was automatically generated by Gitpod. 2 | # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) 3 | # and commit this file to your remote git repository to share the goodness with others. 4 | 5 | # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart 6 | 7 | tasks: 8 | - init: yarn install && yarn run dev 9 | command: yarn run dev 10 | 11 | 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/功能建议.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 功能建议 3 | about: 请告诉我们你的灵光一闪 4 | title: "[Feature] " 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | > 为了提高交流效率,我们设立了官方 QQ 群和 QQ 频道,如果你在使用或者搭建过程中遇到了任何问题,请先第一时间加群或者频道咨询解决,除非是可以稳定复现的 Bug 或者较为有创意的功能建议,否则请不要随意往 Issue 区发送低质无意义帖子。 11 | 12 | > [点击加入官方群聊](https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/1724) 13 | 14 | **这个功能与现有的问题有关吗?** 15 | 如果有关,请在此列出链接或者描述问题。 16 | 17 | **你想要什么功能或者有什么建议?** 18 | 尽管告诉我们。 19 | 20 | **有没有可以参考的同类竞品?** 21 | 可以给出参考产品的链接或者截图。 22 | 23 | **其他信息** 24 | 可以说说你的其他考虑。 25 | -------------------------------------------------------------------------------- /app/icons/down.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/left.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /app/utils/token.ts: -------------------------------------------------------------------------------- 1 | export function estimateTokenLength(input: string): number { 2 | let tokenLength = 0; 3 | 4 | for (let i = 0; i < input.length; i++) { 5 | const charCode = input.charCodeAt(i); 6 | 7 | if (charCode < 128) { 8 | // ASCII character 9 | if (charCode <= 122 && charCode >= 65) { 10 | // a-Z 11 | tokenLength += 0.25; 12 | } else { 13 | tokenLength += 0.5; 14 | } 15 | } else { 16 | // Unicode character 17 | tokenLength += 1.5; 18 | } 19 | } 20 | 21 | return tokenLength; 22 | } 23 | -------------------------------------------------------------------------------- /app/icons/share.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vercel.json: -------------------------------------------------------------------------------- 1 | { 2 | "github": { 3 | "silent": true 4 | }, 5 | "headers": [ 6 | { 7 | "source": "/(.*)", 8 | "headers": [ 9 | { 10 | "key": "X-Real-IP", 11 | "value": "$remote_addr" 12 | }, 13 | { 14 | "key": "X-Forwarded-For", 15 | "value": "$proxy_add_x_forwarded_for" 16 | }, 17 | { 18 | "key": "Host", 19 | "value": "$http_host" 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | dev 38 | 39 | .vscode 40 | .idea 41 | 42 | # docker-compose env files 43 | .env 44 | 45 | *.key 46 | *.key.pub -------------------------------------------------------------------------------- /app/components/auth.module.scss: -------------------------------------------------------------------------------- 1 | .auth-page { 2 | display: flex; 3 | justify-content: center; 4 | align-items: center; 5 | height: 100%; 6 | width: 100%; 7 | flex-direction: column; 8 | 9 | .auth-logo { 10 | transform: scale(1.4); 11 | } 12 | 13 | .auth-title { 14 | font-size: 24px; 15 | font-weight: bold; 16 | line-height: 2; 17 | } 18 | 19 | .auth-tips { 20 | font-size: 14px; 21 | } 22 | 23 | .auth-input { 24 | margin: 3vh 0; 25 | } 26 | 27 | .auth-actions { 28 | display: flex; 29 | justify-content: center; 30 | flex-direction: column; 31 | 32 | button:not(:last-child) { 33 | margin-bottom: 10px; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/icons/bottom.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature] " 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /app/config/client.ts: -------------------------------------------------------------------------------- 1 | import { BuildConfig, getBuildConfig } from "./build"; 2 | 3 | export function getClientConfig() { 4 | if (typeof document !== "undefined") { 5 | // client side 6 | return JSON.parse(queryMeta("config")) as BuildConfig; 7 | } 8 | 9 | if (typeof process !== "undefined") { 10 | // server side 11 | return getBuildConfig(); 12 | } 13 | } 14 | 15 | function queryMeta(key: string, defaultValue?: string): string { 16 | let ret: string; 17 | if (document) { 18 | const meta = document.head.querySelector( 19 | `meta[name='${key}']`, 20 | ) as HTMLMetaElement; 21 | ret = meta?.content ?? ""; 22 | } else { 23 | ret = defaultValue ?? ""; 24 | } 25 | 26 | return ret; 27 | } 28 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # 4 | patreon: kiask 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /app/polyfill.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | interface Array { 3 | at(index: number): T | undefined; 4 | } 5 | } 6 | 7 | if (!Array.prototype.at) { 8 | Array.prototype.at = function (index: number) { 9 | // Get the length of the array 10 | const length = this.length; 11 | 12 | // Convert negative index to a positive index 13 | if (index < 0) { 14 | index = length + index; 15 | } 16 | 17 | // Return undefined if the index is out of range 18 | if (index < 0 || index >= length) { 19 | return undefined; 20 | } 21 | 22 | // Use Array.prototype.slice method to get value at the specified index 23 | return Array.prototype.slice.call(this, index, index + 1)[0]; 24 | }; 25 | } 26 | 27 | export {}; 28 | -------------------------------------------------------------------------------- /app/api/config/route.ts: -------------------------------------------------------------------------------- 1 | import { NextResponse } from "next/server"; 2 | 3 | import { getServerSideConfig } from "../../config/server"; 4 | 5 | const serverConfig = getServerSideConfig(); 6 | 7 | // Danger! Don not write any secret value here! 8 | // 警告!不要在这里写入任何敏感信息! 9 | const DANGER_CONFIG = { 10 | needCode: serverConfig.needCode, 11 | hideUserApiKey: serverConfig.hideUserApiKey, 12 | disableGPT4: serverConfig.disableGPT4, 13 | hideBalanceQuery: serverConfig.hideBalanceQuery, 14 | }; 15 | 16 | declare global { 17 | type DangerConfig = typeof DANGER_CONFIG; 18 | } 19 | 20 | async function handle() { 21 | return NextResponse.json(DANGER_CONFIG); 22 | } 23 | 24 | export const GET = handle; 25 | export const POST = handle; 26 | 27 | export const runtime = "edge"; 28 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2015", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "plugins": [ 18 | { 19 | "name": "next" 20 | } 21 | ], 22 | "paths": { 23 | "@/*": ["./*"] 24 | } 25 | }, 26 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "app/calcTextareaHeight.ts"], 27 | "exclude": ["node_modules"] 28 | } 29 | -------------------------------------------------------------------------------- /app/styles/window.scss: -------------------------------------------------------------------------------- 1 | .window-header { 2 | padding: 14px 20px; 3 | border-bottom: rgba(0, 0, 0, 0.1) 1px solid; 4 | position: relative; 5 | 6 | display: flex; 7 | justify-content: space-between; 8 | align-items: center; 9 | } 10 | 11 | .window-header-title { 12 | max-width: calc(100% - 100px); 13 | overflow: hidden; 14 | 15 | .window-header-main-title { 16 | font-size: 20px; 17 | font-weight: bolder; 18 | overflow: hidden; 19 | text-overflow: ellipsis; 20 | white-space: nowrap; 21 | display: block; 22 | max-width: 50vw; 23 | } 24 | 25 | .window-header-sub-title { 26 | font-size: 14px; 27 | } 28 | } 29 | 30 | .window-actions { 31 | display: inline-flex; 32 | } 33 | 34 | .window-action-button:not(:first-child) { 35 | margin-left: 10px; 36 | } 37 | -------------------------------------------------------------------------------- /app/icons/dark.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/components/input-range.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import styles from "./input-range.module.scss"; 3 | 4 | interface InputRangeProps { 5 | onChange: React.ChangeEventHandler; 6 | title?: string; 7 | value: number | string; 8 | className?: string; 9 | min: string; 10 | max: string; 11 | step: string; 12 | } 13 | 14 | export function InputRange({ 15 | onChange, 16 | title, 17 | value, 18 | className, 19 | min, 20 | max, 21 | step, 22 | }: InputRangeProps) { 23 | return ( 24 |
25 | {title || value} 26 | 35 |
36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /app/masks/index.ts: -------------------------------------------------------------------------------- 1 | import { Mask } from "../store/mask"; 2 | import { CN_MASKS } from "./cn"; 3 | import { EN_MASKS } from "./en"; 4 | import { HI_MASKS } from "./hi"; 5 | 6 | import { type BuiltinMask } from "./typing"; 7 | export { type BuiltinMask } from "./typing"; 8 | 9 | export const BUILTIN_MASK_ID = 100000; 10 | 11 | export const BUILTIN_MASK_STORE = { 12 | buildinId: BUILTIN_MASK_ID, 13 | masks: {} as Record, 14 | get(id?: number) { 15 | if (!id) return undefined; 16 | return this.masks[id] as Mask | undefined; 17 | }, 18 | add(m: BuiltinMask) { 19 | const mask = { ...m, id: this.buildinId++, builtin: true }; 20 | this.masks[mask.id] = mask; 21 | return mask; 22 | }, 23 | }; 24 | 25 | export const BUILTIN_MASKS: BuiltinMask[] = [...CN_MASKS, ...EN_MASKS, ...HI_MASKS].map( 26 | (m) => BUILTIN_MASK_STORE.add(m), 27 | ); 28 | -------------------------------------------------------------------------------- /app/icons/rename.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.9' 2 | services: 3 | chatgpt-next-web: 4 | profiles: ["no-proxy"] 5 | container_name: chatgpt-next-web 6 | image: yidadaa/chatgpt-next-web 7 | ports: 8 | - 3000:3000 9 | environment: 10 | - OPENAI_API_KEY=$OPENAI_API_KEY 11 | - CODE=$CODE 12 | - BASE_URL=$BASE_URL 13 | - OPENAI_ORG_ID=$OPENAI_ORG_ID 14 | - HIDE_USER_API_KEY=$HIDE_USER_API_KEY 15 | - DISABLE_GPT4=$DISABLE_GPT4 16 | 17 | chatgpt-next-web-proxy: 18 | profiles: ["proxy"] 19 | container_name: chatgpt-next-web-proxy 20 | image: yidadaa/chatgpt-next-web 21 | ports: 22 | - 3000:3000 23 | environment: 24 | - OPENAI_API_KEY=$OPENAI_API_KEY 25 | - CODE=$CODE 26 | - PROXY_URL=$PROXY_URL 27 | - BASE_URL=$BASE_URL 28 | - OPENAI_ORG_ID=$OPENAI_ORG_ID 29 | - HIDE_USER_API_KEY=$HIDE_USER_API_KEY 30 | - DISABLE_GPT4=$DISABLE_GPT4 31 | -------------------------------------------------------------------------------- /app/icons/copy.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.env.template: -------------------------------------------------------------------------------- 1 | 2 | # Your openai api key. (required) 3 | OPENAI_API_KEY=sk-xxxx 4 | 5 | # Access passsword, separated by comma. (optional) 6 | CODE=your-password 7 | 8 | # You can start service behind a proxy 9 | PROXY_URL=http://localhost:7890 10 | 11 | # Override openai api request base url. (optional) 12 | # Default: https://api.openai.com 13 | # Examples: http://your-openai-proxy.com 14 | BASE_URL= 15 | 16 | # Specify OpenAI organization ID.(optional) 17 | # Default: Empty 18 | # If you do not want users to input their own API key, set this value to 1. 19 | OPENAI_ORG_ID= 20 | 21 | # (optional) 22 | # Default: Empty 23 | # If you do not want users to input their own API key, set this value to 1. 24 | HIDE_USER_API_KEY= 25 | 26 | # (optional) 27 | # Default: Empty 28 | # If you do not want users to use GPT-4, set this value to 1. 29 | DISABLE_GPT4= 30 | 31 | # (optional) 32 | # Default: Empty 33 | # If you do not want users to query balance, set this value to 1. 34 | HIDE_BALANCE_QUERY= -------------------------------------------------------------------------------- /app/icons/menu.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/close.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/icons/send-white.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/icons/pause.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/icons/return.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/icons/add.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[Bug] " 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Deployment** 27 | - [ ] Docker 28 | - [ ] Vercel 29 | - [ ] Server 30 | 31 | **Desktop (please complete the following information):** 32 | - OS: [e.g. iOS] 33 | - Browser [e.g. chrome, safari] 34 | - Version [e.g. 22] 35 | 36 | **Smartphone (please complete the following information):** 37 | - Device: [e.g. iPhone6] 38 | - OS: [e.g. iOS8.1] 39 | - Browser [e.g. stock browser, safari] 40 | - Version [e.g. 22] 41 | 42 | **Additional Logs** 43 | Add any logs about the problem here. 44 | -------------------------------------------------------------------------------- /app/icons/three-dots.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/client/controller.ts: -------------------------------------------------------------------------------- 1 | // To store message streaming controller 2 | export const ChatControllerPool = { 3 | controllers: {} as Record, 4 | 5 | addController( 6 | sessionIndex: number, 7 | messageId: number, 8 | controller: AbortController, 9 | ) { 10 | const key = this.key(sessionIndex, messageId); 11 | this.controllers[key] = controller; 12 | return key; 13 | }, 14 | 15 | stop(sessionIndex: number, messageId: number) { 16 | const key = this.key(sessionIndex, messageId); 17 | const controller = this.controllers[key]; 18 | controller?.abort(); 19 | }, 20 | 21 | stopAll() { 22 | Object.values(this.controllers).forEach((v) => v.abort()); 23 | }, 24 | 25 | hasPending() { 26 | return Object.values(this.controllers).length > 0; 27 | }, 28 | 29 | remove(sessionIndex: number, messageId: number) { 30 | const key = this.key(sessionIndex, messageId); 31 | delete this.controllers[key]; 32 | }, 33 | 34 | key(sessionIndex: number, messageIndex: number) { 35 | return `${sessionIndex},${messageIndex}`; 36 | }, 37 | }; 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/反馈问题.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 反馈问题 3 | about: 请告诉我们你遇到的问题 4 | title: "[Bug] " 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | > 为了提高交流效率,我们设立了官方 QQ 群和 QQ 频道,如果你在使用或者搭建过程中遇到了任何问题,请先第一时间加群或者频道咨询解决,除非是可以稳定复现的 Bug 或者较为有创意的功能建议,否则请不要随意往 Issue 区发送低质无意义帖子。 11 | 12 | > [点击加入官方群聊](https://github.com/Yidadaa/ChatGPT-Next-Web/discussions/1724) 13 | 14 | **反馈须知** 15 | 16 | ⚠️ 注意:不遵循此模板的任何帖子都会被立即关闭,如果没有提供下方的信息,我们无法定位你的问题。 17 | 18 | 请在下方中括号内输入 x 来表示你已经知晓相关内容。 19 | - [ ] 我确认已经在 [常见问题](https://github.com/Yidadaa/ChatGPT-Next-Web/blob/main/docs/faq-cn.md) 中搜索了此次反馈的问题,没有找到解答; 20 | - [ ] 我确认已经在 [Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) 列表(包括已经 Close 的)中搜索了此次反馈的问题,没有找到解答。 21 | - [ ] 我确认已经在 [Vercel 使用教程](https://github.com/Yidadaa/ChatGPT-Next-Web/blob/main/docs/vercel-cn.md) 中搜索了此次反馈的问题,没有找到解答。 22 | 23 | **描述问题** 24 | 请在此描述你遇到了什么问题。 25 | 26 | **如何复现** 27 | 请告诉我们你是通过什么操作触发的该问题。 28 | 29 | **截图** 30 | 请在此提供控制台截图、屏幕截图或者服务端的 log 截图。 31 | 32 | **一些必要的信息** 33 | - 系统:[比如 windows 10/ macos 12/ linux / android 11 / ios 16] 34 | - 浏览器: [比如 chrome, safari] 35 | - 版本: [填写设置页面的版本号] 36 | - 部署方式:[比如 vercel、docker 或者服务器部署] 37 | -------------------------------------------------------------------------------- /docs/vercel-cn.md: -------------------------------------------------------------------------------- 1 | # Vercel 的使用说明 2 | 3 | ## 如何新建项目 4 | 当你从 Github fork 本项目之后,需要重新在 Vercel 创建一个全新的 Vercel 项目来重新部署,你需要按照下列步骤进行。 5 | 6 | ![vercel-create-1](./images/vercel/vercel-create-1.jpg) 7 | 1. 进入 Vercel 控制台首页; 8 | 2. 点击 Add New; 9 | 3. 选择 Project。 10 | 11 | ![vercel-create-2](./images/vercel/vercel-create-2.jpg) 12 | 1. 在 Import Git Repository 处,搜索 chatgpt-next-web; 13 | 2. 选中新 fork 的项目,点击 Import。 14 | 15 | ![vercel-create-3](./images/vercel/vercel-create-3.jpg) 16 | 1. 在项目配置页,点开 Environmane Variables 开始配置环境变量; 17 | 2. 依次新增名为 OPENAI_API_KEY 和 CODE 的环境变量; 18 | 3. 填入环境变量对应的值; 19 | 4. 点击 Add 确认增加环境变量; 20 | 5. 请确保你添加了 OPENAI_API_KEY,否则无法使用; 21 | 6. 点击 Deploy,创建完成,耐心等待 5 分钟左右部署完成。 22 | 23 | ## 如何增加自定义域名 24 | [TODO] 25 | 26 | ## 如何更改环境变量 27 | ![vercel-env-edit](./images/vercel/vercel-env-edit.jpg) 28 | 1. 进去 Vercel 项目内部控制台,点击顶部的 Settings 按钮; 29 | 2. 点击左侧的 Environment Variables; 30 | 3. 点击已有条目的右侧按钮; 31 | 4. 选择 Edit 进行编辑,然后保存即可。 32 | 33 | ⚠️️ 注意:每次修改完环境变量,你都需要[重新部署项目](#如何重新部署)来让改动生效! 34 | 35 | ## 如何重新部署 36 | ![vercel-redeploy](./images/vercel/vercel-redeploy.jpg) 37 | 1. 进入 Vercel 项目内部控制台,点击顶部的 Deployments 按钮; 38 | 2. 选择列表最顶部一条的右侧按钮; 39 | 3. 点击 Redeploy 即可重新部署。 -------------------------------------------------------------------------------- /app/icons/export.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/settings.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/icons/prompt.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/clear.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/auto.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/icons/eye.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/icons/reload.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 18 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/config/build.ts: -------------------------------------------------------------------------------- 1 | import tauriConfig from "../../src-tauri/tauri.conf.json"; 2 | 3 | export const getBuildConfig = () => { 4 | if (typeof process === "undefined") { 5 | throw Error( 6 | "[Server Config] you are importing a nodejs-only module outside of nodejs", 7 | ); 8 | } 9 | 10 | const buildMode = process.env.BUILD_MODE ?? "standalone"; 11 | const isApp = !!process.env.BUILD_APP; 12 | const version = "v" + tauriConfig.package.version; 13 | 14 | const commitInfo = (() => { 15 | try { 16 | const childProcess = require("child_process"); 17 | const commitDate: string = childProcess 18 | .execSync('git log -1 --format="%at000" --date=unix') 19 | .toString() 20 | .trim(); 21 | const commitHash: string = childProcess 22 | .execSync('git log --pretty=format:"%H" -n 1') 23 | .toString() 24 | .trim(); 25 | 26 | return { commitDate, commitHash }; 27 | } catch (e) { 28 | console.error("[Build Config] No git or not from git repo."); 29 | return { 30 | commitDate: "unknown", 31 | commitHash: "unknown", 32 | }; 33 | } 34 | })(); 35 | 36 | return { 37 | version, 38 | ...commitInfo, 39 | buildMode, 40 | isApp, 41 | }; 42 | }; 43 | 44 | export type BuildConfig = ReturnType; 45 | -------------------------------------------------------------------------------- /src-tauri/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "chatgpt-next-web" 3 | version = "0.1.0" 4 | description = "A cross platform app for LLM ChatBot." 5 | authors = ["Yidadaa"] 6 | license = "mit" 7 | repository = "" 8 | default-run = "chatgpt-next-web" 9 | edition = "2021" 10 | rust-version = "1.60" 11 | 12 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 13 | 14 | [build-dependencies] 15 | tauri-build = { version = "1.3.0", features = [] } 16 | 17 | [dependencies] 18 | serde_json = "1.0" 19 | serde = { version = "1.0", features = ["derive"] } 20 | tauri = { version = "1.3.0", features = ["clipboard-all", "dialog-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-set-icon", "window-set-ignore-cursor-events", "window-set-resizable", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] } 21 | tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" } 22 | 23 | [features] 24 | # this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled. 25 | # If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes. 26 | # DO NOT REMOVE!! 27 | custom-protocol = [ "tauri/custom-protocol" ] 28 | -------------------------------------------------------------------------------- /app/components/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | 3 | import styles from "./button.module.scss"; 4 | 5 | export type ButtonType = "primary" | "danger" | null; 6 | 7 | export function IconButton(props: { 8 | onClick?: () => void; 9 | icon?: JSX.Element; 10 | type?: ButtonType; 11 | text?: string; 12 | bordered?: boolean; 13 | shadow?: boolean; 14 | className?: string; 15 | title?: string; 16 | disabled?: boolean; 17 | tabIndex?: number; 18 | autoFocus?: boolean; 19 | }) { 20 | return ( 21 | 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /public/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "The Ultimate ChatGPT", 3 | "short_name": "Ultimate ChatGPT", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-32x32.png", 7 | "sizes": "32x32", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/android-chrome-64x64.png", 12 | "sizes": "64x64", 13 | "type": "image/png" 14 | }, 15 | { 16 | "src": "/android-chrome-128x128.png", 17 | "sizes": "128x128", 18 | "type": "image/png" 19 | }, 20 | { 21 | "src": "/android-chrome-192x192.png", 22 | "sizes": "192x192", 23 | "type": "image/png" 24 | }, 25 | { 26 | "src": "/android-chrome-512x512.png", 27 | "sizes": "512x512", 28 | "type": "image/png" 29 | }, 30 | { 31 | "src": "/android-chrome-1024x1024.png", 32 | "sizes": "1024x1024", 33 | "type": "image/png" 34 | }, 35 | { 36 | "src": "/android-chrome-2048x2048.png", 37 | "sizes": "2048x2048", 38 | "type": "image/png" 39 | } 40 | ], 41 | "start_url": "/", 42 | "theme_color": "#11A380", 43 | "background_color": "#ffffff", 44 | "display": "fullscreen", 45 | "display_override": [ 46 | "fullscreen", 47 | "window-controls-overlay" 48 | ], 49 | "categories": [ 50 | "productivity", 51 | "utilities" 52 | ], 53 | "dir": "auto", 54 | "lang": "en", 55 | "orientation": "any", 56 | "scope": "CHATGPT.KIASK.XYZ" 57 | } -------------------------------------------------------------------------------- /app/components/auth.tsx.bak: -------------------------------------------------------------------------------- 1 | import styles from "./auth.module.scss"; 2 | import { IconButton } from "./button"; 3 | 4 | import { useNavigate } from "react-router-dom"; 5 | import { Path } from "../constant"; 6 | import { useAccessStore } from "../store"; 7 | import Locale from "../locales"; 8 | 9 | import BotIcon from "../icons/bot.svg"; 10 | 11 | export function AuthPage() { 12 | const navigate = useNavigate(); 13 | const access = useAccessStore(); 14 | 15 | const goHome = () => navigate(Path.Home); 16 | 17 | return ( 18 |
19 |
20 | 21 |
22 | 23 |
{Locale.Auth.Title}
24 |
25 | Your access code is: "ALIF_LAM_MEEM" and "LA_ILAHA_ILLAL_LAH" 26 |
27 | 28 | { 34 | access.updateCode(e.currentTarget.value); 35 | }} 36 | /> 37 | 38 |
39 | 40 | 41 |
42 |
43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /app/components/auth.tsx-30.bak: -------------------------------------------------------------------------------- 1 | import styles from "./auth.module.scss"; 2 | import { IconButton } from "./button"; 3 | 4 | import { useNavigate } from "react-router-dom"; 5 | import { Path } from "../constant"; 6 | import { useAccessStore } from "../store"; 7 | import Locale from "../locales"; 8 | 9 | import BotIcon from "../icons/bot.svg"; 10 | 11 | export function AuthPage() { 12 | const navigate = useNavigate(); 13 | const access = useAccessStore(); 14 | 15 | const goHome = () => navigate(Path.Home); 16 | 17 | return ( 18 |
19 |
20 | 21 |
22 | 23 |
{Locale.Auth.Title}
24 |
Your access code is: "ALIF_LAM_MEEM" and "LA_ILAHA_ILLAL_LAH"
25 | 26 | { 32 | access.updateCode(e.currentTarget.value); 33 | }} 34 | /> 35 | 36 |
37 | 42 | 43 |
44 |
45 | ); 46 | } 47 | -------------------------------------------------------------------------------- /docs/cloudflare-pages-cn.md: -------------------------------------------------------------------------------- 1 | # Cloudflare Pages 部署指南 2 | 3 | ## 如何新建项目 4 | 在 Github 上 fork 本项目,然后登录到 dash.cloudflare.com 并进入 Pages。 5 | 6 | 1. 点击 "Create a project"。 7 | 2. 选择 "Connect to Git"。 8 | 3. 关联 Cloudflare Pages 和你的 GitHub 账号。 9 | 4. 选中你 fork 的此项目。 10 | 5. 点击 "Begin setup"。 11 | 6. 对于 "Project name" 和 "Production branch",可以使用默认值,也可以根据需要进行更改。 12 | 7. 在 "Build Settings" 中,选择 "Framework presets" 选项并选择 "Next.js"。 13 | 8. 由于 node:buffer 的 bug,暂时不要使用默认的 "Build command"。请使用以下命令: 14 | ``` 15 | npx https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/4930842298/npm-package-next-on-pages-230 --experimental-minify 16 | ``` 17 | 9. 对于 "Build output directory",使用默认值并且不要修改。 18 | 10. 不要修改 "Root Directory"。 19 | 11. 对于 "Environment variables",点击 ">" 然后点击 "Add variable"。按照以下信息填写: 20 | 21 | - `NODE_VERSION=20.1` 22 | - `NEXT_TELEMETRY_DISABLE=1` 23 | - `OPENAI_API_KEY=你自己的API Key` 24 | - `YARN_VERSION=1.22.19` 25 | - `PHP_VERSION=7.4` 26 | 27 | 根据实际需要,可以选择填写以下选项: 28 | 29 | - `CODE= 可选填,访问密码,可以使用逗号隔开多个密码` 30 | - `OPENAI_ORG_ID= 可选填,指定 OpenAI 中的组织 ID` 31 | - `HIDE_USER_API_KEY=1 可选,不让用户自行填入 API Key` 32 | - `DISABLE_GPT4=1 可选,不让用户使用 GPT-4` 33 | 34 | 12. 点击 "Save and Deploy"。 35 | 13. 点击 "Cancel deployment",因为需要填写 Compatibility flags。 36 | 14. 前往 "Build settings"、"Functions",找到 "Compatibility flags"。 37 | 15. 在 "Configure Production compatibility flag" 和 "Configure Preview compatibility flag" 中填写 "nodejs_compat"。 38 | 16. 前往 "Deployments",点击 "Retry deployment"。 39 | 17. Enjoy. -------------------------------------------------------------------------------- /app/components/settings.module.scss: -------------------------------------------------------------------------------- 1 | .settings { 2 | padding: 20px; 3 | overflow: auto; 4 | } 5 | 6 | .avatar { 7 | cursor: pointer; 8 | } 9 | 10 | .edit-prompt-modal { 11 | display: flex; 12 | flex-direction: column; 13 | 14 | .edit-prompt-title { 15 | max-width: unset; 16 | margin-bottom: 20px; 17 | text-align: left; 18 | } 19 | .edit-prompt-content { 20 | max-width: unset; 21 | } 22 | } 23 | 24 | .user-prompt-modal { 25 | min-height: 40vh; 26 | 27 | .user-prompt-search { 28 | width: 100%; 29 | max-width: 100%; 30 | margin-bottom: 10px; 31 | background-color: var(--gray); 32 | } 33 | 34 | .user-prompt-list { 35 | border: var(--border-in-light); 36 | border-radius: 10px; 37 | 38 | .user-prompt-item { 39 | display: flex; 40 | justify-content: space-between; 41 | padding: 10px; 42 | 43 | &:not(:last-child) { 44 | border-bottom: var(--border-in-light); 45 | } 46 | 47 | .user-prompt-header { 48 | max-width: calc(100% - 100px); 49 | 50 | .user-prompt-title { 51 | font-size: 14px; 52 | line-height: 2; 53 | font-weight: bold; 54 | } 55 | .user-prompt-content { 56 | font-size: 12px; 57 | } 58 | } 59 | 60 | .user-prompt-buttons { 61 | display: flex; 62 | align-items: center; 63 | column-gap: 2px; 64 | 65 | .user-prompt-button { 66 | //height: 100%; 67 | padding: 7px; 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/components/message-selector.module.scss: -------------------------------------------------------------------------------- 1 | .message-selector { 2 | .message-filter { 3 | display: flex; 4 | 5 | .search-bar { 6 | max-width: unset; 7 | flex-grow: 1; 8 | margin-right: 10px; 9 | } 10 | 11 | .actions { 12 | display: flex; 13 | 14 | button:not(:last-child) { 15 | margin-right: 10px; 16 | } 17 | } 18 | 19 | @media screen and (max-width: 600px) { 20 | flex-direction: column; 21 | 22 | .search-bar { 23 | margin-right: 0; 24 | } 25 | 26 | .actions { 27 | margin-top: 20px; 28 | 29 | button { 30 | flex-grow: 1; 31 | } 32 | } 33 | } 34 | } 35 | 36 | .messages { 37 | margin-top: 20px; 38 | border-radius: 10px; 39 | border: var(--border-in-light); 40 | overflow: hidden; 41 | 42 | .message { 43 | display: flex; 44 | align-items: center; 45 | padding: 8px 10px; 46 | cursor: pointer; 47 | 48 | &-selected { 49 | background-color: var(--second); 50 | } 51 | 52 | &:not(:last-child) { 53 | border-bottom: var(--border-in-light); 54 | } 55 | 56 | .avatar { 57 | margin-right: 10px; 58 | } 59 | 60 | .body { 61 | flex-grow: 1; 62 | max-width: calc(100% - 40px); 63 | 64 | .date { 65 | font-size: 12px; 66 | line-height: 1.2; 67 | opacity: 0.5; 68 | } 69 | 70 | .content { 71 | font-size: 12px; 72 | } 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/components/auth.tsx: -------------------------------------------------------------------------------- 1 | import styles from "./auth.module.scss"; 2 | import { IconButton } from "./button"; 3 | 4 | import { useNavigate } from "react-router-dom"; 5 | import { Path } from "../constant"; 6 | import { useAccessStore } from "../store"; 7 | import Locale from "../locales"; 8 | 9 | import BotIcon from "../icons/bot.svg"; 10 | 11 | export function AuthPage() { 12 | const navigate = useNavigate(); 13 | const access = useAccessStore(); 14 | 15 | const goHome = () => navigate(Path.Home); 16 | 17 | return ( 18 |
19 |
20 | 21 |
22 | 23 |
{Locale.Auth.Title}
24 |
25 | To proceed, please obtain your API key or access code from the following URL: 26 | Get API Key 27 |
28 | 29 | { 35 | access.updateCode(e.currentTarget.value); 36 | }} 37 | /> 38 | 39 |
40 | 41 | 42 |
43 |
44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /app/icons/edit.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/mask.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/components/emoji.tsx: -------------------------------------------------------------------------------- 1 | import EmojiPicker, { 2 | Emoji, 3 | EmojiStyle, 4 | Theme as EmojiTheme, 5 | } from "emoji-picker-react"; 6 | 7 | import { ModelType } from "../store"; 8 | 9 | import BotIcon from "../icons/bot.svg"; 10 | import BlackBotIcon from "../icons/black-bot.svg"; 11 | 12 | export function getEmojiUrl(unified: string, style: EmojiStyle) { 13 | return `https://cdn.staticfile.org/emoji-datasource-apple/14.0.0/img/${style}/64/${unified}.png`; 14 | } 15 | 16 | export function AvatarPicker(props: { 17 | onEmojiClick: (emojiId: string) => void; 18 | }) { 19 | return ( 20 | { 25 | props.onEmojiClick(e.unified); 26 | }} 27 | /> 28 | ); 29 | } 30 | 31 | export function Avatar(props: { model?: ModelType; avatar?: string }) { 32 | if (props.model) { 33 | return ( 34 |
35 | {props.model?.startsWith("gpt-4") ? ( 36 | 37 | ) : ( 38 | 39 | )} 40 |
41 | ); 42 | } 43 | 44 | return ( 45 |
46 | {props.avatar && } 47 |
48 | ); 49 | } 50 | 51 | export function EmojiAvatar(props: { avatar: string; size?: number }) { 52 | return ( 53 | 58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /app/icons/chat.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 18 | 21 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/icons/download.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/brain.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/config/server.ts: -------------------------------------------------------------------------------- 1 | import md5 from "spark-md5"; 2 | 3 | declare global { 4 | namespace NodeJS { 5 | interface ProcessEnv { 6 | OPENAI_API_KEY?: string; 7 | CODE?: string; 8 | BASE_URL?: string; 9 | PROXY_URL?: string; 10 | VERCEL?: string; 11 | HIDE_USER_API_KEY?: string; // disable user's api key input 12 | DISABLE_GPT4?: string; // allow user to use gpt-4 or not 13 | BUILD_MODE?: "standalone" | "export"; 14 | BUILD_APP?: string; // is building desktop app 15 | HIDE_BALANCE_QUERY?: string; // allow user to query balance or not 16 | } 17 | } 18 | } 19 | 20 | const ACCESS_CODES = (function getAccessCodes(): Set { 21 | const code = process.env.CODE; 22 | 23 | try { 24 | const codes = (code?.split(",") ?? []) 25 | .filter((v) => !!v) 26 | .map((v) => md5.hash(v.trim())); 27 | return new Set(codes); 28 | } catch (e) { 29 | return new Set(); 30 | } 31 | })(); 32 | 33 | export const getServerSideConfig = () => { 34 | if (typeof process === "undefined") { 35 | throw Error( 36 | "[Server Config] you are importing a nodejs-only module outside of nodejs", 37 | ); 38 | } 39 | 40 | return { 41 | apiKey: process.env.OPENAI_API_KEY, 42 | code: process.env.CODE, 43 | codes: ACCESS_CODES, 44 | needCode: ACCESS_CODES.size > 0, 45 | baseUrl: process.env.BASE_URL, 46 | proxyUrl: process.env.PROXY_URL, 47 | isVercel: !!process.env.VERCEL, 48 | hideUserApiKey: !!process.env.HIDE_USER_API_KEY, 49 | disableGPT4: !!process.env.DISABLE_GPT4, 50 | hideBalanceQuery: !!process.env.HIDE_BALANCE_QUERY, 51 | }; 52 | }; 53 | -------------------------------------------------------------------------------- /app/api/auth.ts.bak: -------------------------------------------------------------------------------- 1 | import { NextRequest } from "next/server"; 2 | import { getServerSideConfig } from "../config/server"; 3 | import md5 from "spark-md5"; 4 | import { ACCESS_CODE_PREFIX } from "../constant"; 5 | 6 | function getIP(req: NextRequest) { 7 | let ip = req.ip ?? req.headers.get("x-real-ip"); 8 | const forwardedFor = req.headers.get("x-forwarded-for"); 9 | 10 | if (!ip && forwardedFor) { 11 | ip = forwardedFor.split(",").at(0) ?? ""; 12 | } 13 | 14 | return ip; 15 | } 16 | 17 | function parseApiKey(bearToken: string) { 18 | const token = bearToken.trim().replaceAll("Bearer ", "").trim(); 19 | const isOpenAiKey = !token.startsWith(ACCESS_CODE_PREFIX); 20 | 21 | return { 22 | accessCode: isOpenAiKey ? "" : token.slice(ACCESS_CODE_PREFIX.length), 23 | apiKey: isOpenAiKey ? token : "", 24 | }; 25 | } 26 | 27 | export function auth(req: NextRequest) { 28 | const authToken = req.headers.get("Authorization") ?? ""; 29 | 30 | // Skip access code checking 31 | const { accessCode, apiKey: token } = parseApiKey(authToken); 32 | 33 | const hashedCode = md5.hash(accessCode ?? "").trim(); 34 | 35 | const serverConfig = getServerSideConfig(); 36 | console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]); 37 | console.log("[Auth] got access code:", accessCode); 38 | console.log("[Auth] hashed access code:", hashedCode); 39 | console.log("[User IP] ", getIP(req)); 40 | console.log("[Time] ", new Date().toLocaleString()); 41 | 42 | // Remove the check for access code requirement 43 | 44 | // Use the user-submitted access code as the API key 45 | req.headers.set("Authorization", `Bearer ${accessCode}`); 46 | 47 | return { 48 | error: false, 49 | }; 50 | } 51 | -------------------------------------------------------------------------------- /app/components/button.module.scss: -------------------------------------------------------------------------------- 1 | .icon-button { 2 | background-color: var(--white); 3 | border-radius: 10px; 4 | display: flex; 5 | align-items: center; 6 | justify-content: center; 7 | padding: 10px; 8 | 9 | cursor: pointer; 10 | transition: all 0.3s ease; 11 | overflow: hidden; 12 | user-select: none; 13 | outline: none; 14 | border: none; 15 | color: var(--black); 16 | 17 | &[disabled] { 18 | cursor: not-allowed; 19 | opacity: 0.5; 20 | } 21 | 22 | &.primary { 23 | background-color: var(--primary); 24 | color: white; 25 | 26 | path { 27 | fill: white !important; 28 | } 29 | } 30 | 31 | &.danger { 32 | color: rgba($color: red, $alpha: 0.8); 33 | border-color: rgba($color: red, $alpha: 0.5); 34 | background-color: rgba($color: red, $alpha: 0.05); 35 | 36 | &:hover { 37 | border-color: red; 38 | background-color: rgba($color: red, $alpha: 0.1); 39 | } 40 | 41 | path { 42 | fill: red !important; 43 | } 44 | } 45 | 46 | &:hover, 47 | &:focus { 48 | border-color: var(--primary); 49 | } 50 | } 51 | 52 | .shadow { 53 | box-shadow: var(--card-shadow); 54 | } 55 | 56 | .border { 57 | border: var(--border-in-light); 58 | } 59 | 60 | .icon-button-icon { 61 | width: 16px; 62 | height: 16px; 63 | display: flex; 64 | justify-content: center; 65 | align-items: center; 66 | } 67 | 68 | @media only screen and (max-width: 600px) { 69 | .icon-button { 70 | padding: 16px; 71 | } 72 | } 73 | 74 | .icon-button-text { 75 | font-size: 12px; 76 | overflow: hidden; 77 | text-overflow: ellipsis; 78 | white-space: nowrap; 79 | 80 | &:not(:first-child) { 81 | margin-left: 5px; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/icons/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-alpine AS base 2 | 3 | FROM base AS deps 4 | 5 | RUN apk add --no-cache libc6-compat 6 | 7 | WORKDIR /app 8 | 9 | COPY package.json yarn.lock ./ 10 | 11 | RUN yarn config set registry 'https://registry.npmmirror.com/' 12 | RUN yarn install 13 | 14 | FROM base AS builder 15 | 16 | RUN apk update && apk add --no-cache git 17 | 18 | ENV OPENAI_API_KEY="" 19 | ENV CODE="" 20 | 21 | WORKDIR /app 22 | COPY --from=deps /app/node_modules ./node_modules 23 | COPY . . 24 | 25 | RUN yarn build 26 | 27 | FROM base AS runner 28 | WORKDIR /app 29 | 30 | RUN apk add proxychains-ng 31 | 32 | ENV PROXY_URL="" 33 | ENV OPENAI_API_KEY="" 34 | ENV CODE="" 35 | 36 | COPY --from=builder /app/public ./public 37 | COPY --from=builder /app/.next/standalone ./ 38 | COPY --from=builder /app/.next/static ./.next/static 39 | COPY --from=builder /app/.next/server ./.next/server 40 | 41 | EXPOSE 3000 42 | 43 | CMD if [ -n "$PROXY_URL" ]; then \ 44 | export HOSTNAME="127.0.0.1"; \ 45 | protocol=$(echo $PROXY_URL | cut -d: -f1); \ 46 | host=$(echo $PROXY_URL | cut -d/ -f3 | cut -d: -f1); \ 47 | port=$(echo $PROXY_URL | cut -d: -f3); \ 48 | conf=/etc/proxychains.conf; \ 49 | echo "strict_chain" > $conf; \ 50 | echo "proxy_dns" >> $conf; \ 51 | echo "remote_dns_subnet 224" >> $conf; \ 52 | echo "tcp_read_time_out 15000" >> $conf; \ 53 | echo "tcp_connect_time_out 8000" >> $conf; \ 54 | echo "localnet 127.0.0.0/255.0.0.0" >> $conf; \ 55 | echo "localnet ::1/128" >> $conf; \ 56 | echo "[ProxyList]" >> $conf; \ 57 | echo "$protocol $host $port" >> $conf; \ 58 | cat /etc/proxychains.conf; \ 59 | proxychains -f $conf node server.js; \ 60 | else \ 61 | node server.js; \ 62 | fi 63 | -------------------------------------------------------------------------------- /app/icons/eye-off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/api/auth.ts: -------------------------------------------------------------------------------- 1 | import { NextRequest } from "next/server"; 2 | import { getServerSideConfig } from "../config/server"; 3 | import md5 from "spark-md5"; 4 | import { ACCESS_CODE_PREFIX } from "../constant"; 5 | 6 | const DEFAULT_ENDPOINT = "https://api.chatanywhere.cn"; 7 | 8 | function getIP(req: NextRequest) { 9 | let ip = req.ip ?? req.headers.get("x-real-ip"); 10 | const forwardedFor = req.headers.get("x-forwarded-for"); 11 | 12 | if (!ip && forwardedFor) { 13 | ip = forwardedFor.split(",").at(0) ?? ""; 14 | } 15 | 16 | return ip; 17 | } 18 | 19 | function parseApiKey(bearToken: string) { 20 | const token = bearToken.trim().replaceAll("Bearer ", "").trim(); 21 | const isOpenAiKey = !token.startsWith(ACCESS_CODE_PREFIX); 22 | 23 | return { 24 | accessCode: isOpenAiKey ? "" : token.slice(ACCESS_CODE_PREFIX.length), 25 | apiKey: isOpenAiKey ? token : "", 26 | }; 27 | } 28 | 29 | export function auth(req: NextRequest) { 30 | const authToken = req.headers.get("Authorization") ?? ""; 31 | 32 | // Skip access code checking 33 | const { accessCode, apiKey: token } = parseApiKey(authToken); 34 | 35 | const hashedCode = md5.hash(accessCode ?? "").trim(); 36 | 37 | const serverConfig = getServerSideConfig(); 38 | console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]); 39 | console.log("[Auth] got access code:", accessCode); 40 | console.log("[Auth] hashed access code:", hashedCode); 41 | console.log("[User IP] ", getIP(req)); 42 | console.log("[Time] ", new Date().toLocaleString()); 43 | 44 | // Remove the check for access code requirement 45 | 46 | // Use the user-submitted access code as the API key 47 | req.headers.set("Authorization", `Bearer ${accessCode}`); 48 | 49 | // Set the default endpoint 50 | req.headers.set("Endpoint", DEFAULT_ENDPOINT); 51 | 52 | return { 53 | error: false, 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /app/icons/max.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/cloudflare-pages-en.md: -------------------------------------------------------------------------------- 1 | # Cloudflare Pages Deployment Guide 2 | 3 | ## How to create a new project 4 | Fork this project on GitHub, then log in to dash.cloudflare.com and go to Pages. 5 | 6 | 1. Click "Create a project". 7 | 2. Choose "Connect to Git". 8 | 3. Connect Cloudflare Pages to your GitHub account. 9 | 4. Select the forked project. 10 | 5. Click "Begin setup". 11 | 6. For "Project name" and "Production branch", use the default values or change them as needed. 12 | 7. In "Build Settings", choose the "Framework presets" option and select "Next.js". 13 | 8. Do not use the default "Build command" due to a node:buffer bug. Instead, use the following command: 14 | ``` 15 | npx https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/4930842298/npm-package-next-on-pages-230 --experimental-minify 16 | ``` 17 | 9. For "Build output directory", use the default value and do not modify it. 18 | 10. Do not modify "Root Directory". 19 | 11. For "Environment variables", click ">" and then "Add variable". Fill in the following information: 20 | - `NODE_VERSION=20.1` 21 | - `NEXT_TELEMETRY_DISABLE=1` 22 | - `OPENAI_API_KEY=your_own_API_key` 23 | - `YARN_VERSION=1.22.19` 24 | - `PHP_VERSION=7.4` 25 | 26 | Optionally fill in the following based on your needs: 27 | 28 | - `CODE= Optional, access passwords, multiple passwords can be separated by commas` 29 | - `OPENAI_ORG_ID= Optional, specify the organization ID in OpenAI` 30 | - `HIDE_USER_API_KEY=1 Optional, do not allow users to enter their own API key` 31 | - `DISABLE_GPT4=1 Optional, do not allow users to use GPT-4` 32 | 33 | 12. Click "Save and Deploy". 34 | 13. Click "Cancel deployment" because you need to fill in Compatibility flags. 35 | 14. Go to "Build settings", "Functions", and find "Compatibility flags". 36 | 15. Fill in "nodejs_compat" for both "Configure Production compatibility flag" and "Configure Preview compatibility flag". 37 | 16. Go to "Deployments" and click "Retry deployment". 38 | 17. Enjoy. -------------------------------------------------------------------------------- /app/icons/min.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/api/auth.ts-30.bak: -------------------------------------------------------------------------------- 1 | import { NextRequest } from "next/server"; 2 | import { getServerSideConfig } from "../config/server"; 3 | import md5 from "spark-md5"; 4 | import { ACCESS_CODE_PREFIX } from "../constant"; 5 | 6 | function getIP(req: NextRequest) { 7 | let ip = req.ip ?? req.headers.get("x-real-ip"); 8 | const forwardedFor = req.headers.get("x-forwarded-for"); 9 | 10 | if (!ip && forwardedFor) { 11 | ip = forwardedFor.split(",").at(0) ?? ""; 12 | } 13 | 14 | return ip; 15 | } 16 | 17 | function parseApiKey(bearToken: string) { 18 | const token = bearToken.trim().replaceAll("Bearer ", "").trim(); 19 | const isOpenAiKey = !token.startsWith(ACCESS_CODE_PREFIX); 20 | 21 | return { 22 | accessCode: isOpenAiKey ? "" : token.slice(ACCESS_CODE_PREFIX.length), 23 | apiKey: isOpenAiKey ? token : "", 24 | }; 25 | } 26 | 27 | export function auth(req: NextRequest) { 28 | const authToken = req.headers.get("Authorization") ?? ""; 29 | 30 | // check if it is openai api key or user token 31 | const { accessCode, apiKey: token } = parseApiKey(authToken); 32 | 33 | const hashedCode = md5.hash(accessCode ?? "").trim(); 34 | 35 | const serverConfig = getServerSideConfig(); 36 | console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]); 37 | console.log("[Auth] got access code:", accessCode); 38 | console.log("[Auth] hashed access code:", hashedCode); 39 | console.log("[User IP] ", getIP(req)); 40 | console.log("[Time] ", new Date().toLocaleString()); 41 | 42 | // Remove the check for access code requirement 43 | 44 | // if user does not provide an api key, inject system api key 45 | if (!token) { 46 | const apiKey = process.env.DEFAULT_API_KEY; // Retrieve the default API key from environment variables 47 | if (apiKey) { 48 | console.log("[Auth] use system api key"); 49 | req.headers.set("Authorization", `Bearer ${apiKey}`); 50 | } else { 51 | console.log("[Auth] admin did not provide an api key"); 52 | } 53 | } else { 54 | console.log("[Auth] use user api key"); 55 | } 56 | 57 | return { 58 | error: false, 59 | }; 60 | } 61 | -------------------------------------------------------------------------------- /app/command.ts: -------------------------------------------------------------------------------- 1 | import { useEffect } from "react"; 2 | import { useSearchParams } from "react-router-dom"; 3 | import Locale from "./locales"; 4 | 5 | type Command = (param: string) => void; 6 | interface Commands { 7 | fill?: Command; 8 | submit?: Command; 9 | mask?: Command; 10 | } 11 | 12 | export function useCommand(commands: Commands = {}) { 13 | const [searchParams, setSearchParams] = useSearchParams(); 14 | 15 | useEffect(() => { 16 | let shouldUpdate = false; 17 | searchParams.forEach((param, name) => { 18 | const commandName = name as keyof Commands; 19 | if (typeof commands[commandName] === "function") { 20 | commands[commandName]!(param); 21 | searchParams.delete(name); 22 | shouldUpdate = true; 23 | } 24 | }); 25 | 26 | if (shouldUpdate) { 27 | setSearchParams(searchParams); 28 | } 29 | // eslint-disable-next-line react-hooks/exhaustive-deps 30 | }, [searchParams, commands]); 31 | } 32 | 33 | interface ChatCommands { 34 | new?: Command; 35 | newm?: Command; 36 | next?: Command; 37 | prev?: Command; 38 | clear?: Command; 39 | del?: Command; 40 | } 41 | 42 | export const ChatCommandPrefix = ":"; 43 | 44 | export function useChatCommand(commands: ChatCommands = {}) { 45 | function extract(userInput: string) { 46 | return ( 47 | userInput.startsWith(ChatCommandPrefix) ? userInput.slice(1) : userInput 48 | ) as keyof ChatCommands; 49 | } 50 | 51 | function search(userInput: string) { 52 | const input = extract(userInput); 53 | const desc = Locale.Chat.Commands; 54 | return Object.keys(commands) 55 | .filter((c) => c.startsWith(input)) 56 | .map((c) => ({ 57 | title: desc[c as keyof ChatCommands], 58 | content: ChatCommandPrefix + c, 59 | })); 60 | } 61 | 62 | function match(userInput: string) { 63 | const command = extract(userInput); 64 | const matched = typeof commands[command] === "function"; 65 | 66 | return { 67 | matched, 68 | invoke: () => matched && commands[command]!(userInput), 69 | }; 70 | } 71 | 72 | return { match, search }; 73 | } 74 | -------------------------------------------------------------------------------- /app/store/sync.ts: -------------------------------------------------------------------------------- 1 | import { Updater } from "../typing"; 2 | import { create } from "zustand"; 3 | import { persist } from "zustand/middleware"; 4 | import { StoreKey } from "../constant"; 5 | 6 | export interface WebDavConfig { 7 | server: string; 8 | username: string; 9 | password: string; 10 | } 11 | 12 | export interface SyncStore { 13 | webDavConfig: WebDavConfig; 14 | lastSyncTime: number; 15 | 16 | update: Updater; 17 | check: () => Promise; 18 | 19 | path: (path: string) => string; 20 | headers: () => { Authorization: string }; 21 | } 22 | 23 | const FILE = { 24 | root: "/chatgpt-next-web/", 25 | }; 26 | 27 | export const useSyncStore = create()( 28 | persist( 29 | (set, get) => ({ 30 | webDavConfig: { 31 | server: "", 32 | username: "", 33 | password: "", 34 | }, 35 | 36 | lastSyncTime: 0, 37 | 38 | update(updater) { 39 | const config = { ...get().webDavConfig }; 40 | updater(config); 41 | set({ webDavConfig: config }); 42 | }, 43 | 44 | async check() { 45 | try { 46 | const res = await fetch(this.path(""), { 47 | method: "PROFIND", 48 | headers: this.headers(), 49 | }); 50 | console.log(res); 51 | return res.status === 207; 52 | } catch (e) { 53 | console.error("[Sync] ", e); 54 | return false; 55 | } 56 | }, 57 | 58 | path(path: string) { 59 | let url = get().webDavConfig.server; 60 | 61 | if (!url.endsWith("/")) { 62 | url += "/"; 63 | } 64 | 65 | if (path.startsWith("/")) { 66 | path = path.slice(1); 67 | } 68 | 69 | return url + path; 70 | }, 71 | 72 | headers() { 73 | const auth = btoa( 74 | [get().webDavConfig.username, get().webDavConfig.password].join(":"), 75 | ); 76 | 77 | return { 78 | Authorization: `Basic ${auth}`, 79 | }; 80 | }, 81 | }), 82 | { 83 | name: StoreKey.Sync, 84 | version: 1, 85 | }, 86 | ), 87 | ); 88 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chatgpt-next-web", 3 | "private": false, 4 | "license": "mit", 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "cross-env BUILD_MODE=standalone next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "export": "cross-env BUILD_MODE=export BUILD_APP=1 next build", 11 | "export:dev": "cross-env BUILD_MODE=export BUILD_APP=1 next dev", 12 | "app:dev": "yarn tauri dev", 13 | "app:build": "yarn tauri build", 14 | "prompts": "node ./scripts/fetch-prompts.mjs", 15 | "prepare": "husky install", 16 | "proxy-dev": "sh ./scripts/init-proxy.sh && proxychains -f ./scripts/proxychains.conf yarn dev" 17 | }, 18 | "dependencies": { 19 | "@fortaine/fetch-event-source": "^3.0.6", 20 | "@hello-pangea/dnd": "^16.3.0", 21 | "@svgr/webpack": "^6.5.1", 22 | "@vercel/analytics": "^0.1.11", 23 | "emoji-picker-react": "^4.4.7", 24 | "fuse.js": "^6.6.2", 25 | "html-to-image": "^1.11.11", 26 | "mermaid": "^10.2.3", 27 | "next": "^13.4.6", 28 | "node-fetch": "^3.3.1", 29 | "react": "^18.2.0", 30 | "react-dom": "^18.2.0", 31 | "react-markdown": "^8.0.7", 32 | "react-router-dom": "^6.10.0", 33 | "rehype-highlight": "^6.0.0", 34 | "rehype-katex": "^6.0.3", 35 | "remark-breaks": "^3.0.2", 36 | "remark-gfm": "^3.0.1", 37 | "remark-math": "^5.1.1", 38 | "sass": "^1.59.2", 39 | "spark-md5": "^3.0.2", 40 | "use-debounce": "^9.0.4", 41 | "zustand": "^4.3.8" 42 | }, 43 | "devDependencies": { 44 | "@tauri-apps/cli": "^1.3.1", 45 | "@types/node": "^20.3.3", 46 | "@types/react": "^18.2.12", 47 | "@types/react-dom": "^18.0.11", 48 | "@types/react-katex": "^3.0.0", 49 | "@types/spark-md5": "^3.0.2", 50 | "cross-env": "^7.0.3", 51 | "eslint": "^8.36.0", 52 | "eslint-config-next": "13.2.3", 53 | "eslint-config-prettier": "^8.8.0", 54 | "eslint-plugin-prettier": "^4.2.1", 55 | "husky": "^8.0.0", 56 | "lint-staged": "^13.2.2", 57 | "prettier": "^2.8.8", 58 | "typescript": "4.9.5", 59 | "webpack": "^5.88.1" 60 | }, 61 | "resolutions": { 62 | "lint-staged/yaml": "^2.2.2" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/api/auth.ts.bak.def: -------------------------------------------------------------------------------- 1 | import { NextRequest } from "next/server"; 2 | import { getServerSideConfig } from "../config/server"; 3 | import md5 from "spark-md5"; 4 | import { ACCESS_CODE_PREFIX } from "../constant"; 5 | 6 | function getIP(req: NextRequest) { 7 | let ip = req.ip ?? req.headers.get("x-real-ip"); 8 | const forwardedFor = req.headers.get("x-forwarded-for"); 9 | 10 | if (!ip && forwardedFor) { 11 | ip = forwardedFor.split(",").at(0) ?? ""; 12 | } 13 | 14 | return ip; 15 | } 16 | 17 | function parseApiKey(bearToken: string) { 18 | const token = bearToken.trim().replaceAll("Bearer ", "").trim(); 19 | const isOpenAiKey = !token.startsWith(ACCESS_CODE_PREFIX); 20 | 21 | return { 22 | accessCode: isOpenAiKey ? "" : token.slice(ACCESS_CODE_PREFIX.length), 23 | apiKey: isOpenAiKey ? token : "", 24 | }; 25 | } 26 | 27 | export function auth(req: NextRequest) { 28 | const authToken = req.headers.get("Authorization") ?? ""; 29 | 30 | // check if it is openai api key or user token 31 | const { accessCode, apiKey: token } = parseApiKey(authToken); 32 | 33 | const hashedCode = md5.hash(accessCode ?? "").trim(); 34 | 35 | const serverConfig = getServerSideConfig(); 36 | console.log("[Auth] allowed hashed codes: ", [...serverConfig.codes]); 37 | console.log("[Auth] got access code:", accessCode); 38 | console.log("[Auth] hashed access code:", hashedCode); 39 | console.log("[User IP] ", getIP(req)); 40 | console.log("[Time] ", new Date().toLocaleString()); 41 | 42 | if (serverConfig.needCode && !serverConfig.codes.has(hashedCode) && !token) { 43 | return { 44 | error: true, 45 | msg: !accessCode ? "empty access code" : "wrong access code", 46 | }; 47 | } 48 | 49 | // if user does not provide an api key, inject system api key 50 | if (!token) { 51 | const apiKey = serverConfig.apiKey; 52 | if (apiKey) { 53 | console.log("[Auth] use system api key"); 54 | req.headers.set("Authorization", `Bearer ${apiKey}`); 55 | } else { 56 | console.log("[Auth] admin did not provide an api key"); 57 | } 58 | } else { 59 | console.log("[Auth] use user api key"); 60 | } 61 | 62 | return { 63 | error: false, 64 | }; 65 | } 66 | -------------------------------------------------------------------------------- /docs/cloudflare-pages-es.md: -------------------------------------------------------------------------------- 1 | # Guía de implementación de Cloudflare Pages 2 | 3 | ## Cómo crear un nuevo proyecto 4 | 5 | Bifurca el proyecto en Github, luego inicia sesión en dash.cloudflare.com y ve a Pages. 6 | 7 | 1. Haga clic en "Crear un proyecto". 8 | 2. Selecciona Conectar a Git. 9 | 3. Vincula páginas de Cloudflare a tu cuenta de GitHub. 10 | 4. Seleccione este proyecto que bifurcó. 11 | 5. Haga clic en "Comenzar configuración". 12 | 6. Para "Nombre del proyecto" y "Rama de producción", puede utilizar los valores predeterminados o cambiarlos según sea necesario. 13 | 7. En Configuración de compilación, seleccione la opción Ajustes preestablecidos de Framework y seleccione Siguiente.js. 14 | 8. Debido a los errores de node:buffer, no use el "comando Construir" predeterminado por ahora. Utilice el siguiente comando: 15 | npx https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/4930842298/npm-package-next-on-pages-230 --experimental-minify 16 | 9. Para "Generar directorio de salida", utilice los valores predeterminados y no los modifique. 17 | 10. No modifique el "Directorio raíz". 18 | 11. Para "Variables de entorno", haga clic en ">" y luego haga clic en "Agregar variable". Rellene la siguiente información: 19 | 20 | * `NODE_VERSION=20.1` 21 | * `NEXT_TELEMETRY_DISABLE=1` 22 | * `OPENAI_API_KEY=你自己的API Key` 23 | * `YARN_VERSION=1.22.19` 24 | * `PHP_VERSION=7.4` 25 | 26 | Dependiendo de sus necesidades reales, puede completar opcionalmente las siguientes opciones: 27 | 28 | * `CODE= 可选填,访问密码,可以使用逗号隔开多个密码` 29 | * `OPENAI_ORG_ID= 可选填,指定 OpenAI 中的组织 ID` 30 | * `HIDE_USER_API_KEY=1 可选,不让用户自行填入 API Key` 31 | * `DISABLE_GPT4=1 可选,不让用户使用 GPT-4` 32 | 12. Haga clic en "Guardar e implementar". 33 | 13. Haga clic en "Cancelar implementación" porque necesita rellenar los indicadores de compatibilidad. 34 | 14. Vaya a "Configuración de compilación", "Funciones" y busque "Indicadores de compatibilidad". 35 | 15. Rellene "nodejs_compat" en "Configurar indicador de compatibilidad de producción" y "Configurar indicador de compatibilidad de vista previa". 36 | 16. Vaya a "Implementaciones" y haga clic en "Reintentar implementación". 37 | 17. Disfrutar. 38 | -------------------------------------------------------------------------------- /app/icons/confirm.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if running on a supported system 4 | case "$(uname -s)" in 5 | Linux) 6 | if [[ -f "/etc/lsb-release" ]]; then 7 | . /etc/lsb-release 8 | if [[ "$DISTRIB_ID" != "Ubuntu" ]]; then 9 | echo "This script only works on Ubuntu, not $DISTRIB_ID." 10 | exit 1 11 | fi 12 | else 13 | if [[ ! "$(cat /etc/*-release | grep '^ID=')" =~ ^(ID=\"ubuntu\")|(ID=\"centos\")|(ID=\"arch\")$ ]]; then 14 | echo "Unsupported Linux distribution." 15 | exit 1 16 | fi 17 | fi 18 | ;; 19 | Darwin) 20 | echo "Running on MacOS." 21 | ;; 22 | *) 23 | echo "Unsupported operating system." 24 | exit 1 25 | ;; 26 | esac 27 | 28 | # Check if needed dependencies are installed and install if necessary 29 | if ! command -v node >/dev/null || ! command -v git >/dev/null || ! command -v yarn >/dev/null; then 30 | case "$(uname -s)" in 31 | Linux) 32 | if [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=ubuntu" ]]; then 33 | sudo apt-get update 34 | sudo apt-get -y install nodejs git yarn 35 | elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=centos" ]]; then 36 | sudo yum -y install epel-release 37 | sudo yum -y install nodejs git yarn 38 | elif [[ "$(cat /etc/*-release | grep '^ID=')" = "ID=arch" ]]; then 39 | sudo pacman -Syu -y 40 | sudo pacman -S -y nodejs git yarn 41 | else 42 | echo "Unsupported Linux distribution" 43 | exit 1 44 | fi 45 | ;; 46 | Darwin) 47 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 48 | brew install node git yarn 49 | ;; 50 | esac 51 | fi 52 | 53 | # Clone the repository and install dependencies 54 | git clone https://github.com/Yidadaa/ChatGPT-Next-Web 55 | cd ChatGPT-Next-Web 56 | yarn install 57 | 58 | # Prompt user for environment variables 59 | read -p "Enter OPENAI_API_KEY: " OPENAI_API_KEY 60 | read -p "Enter CODE: " CODE 61 | read -p "Enter PORT: " PORT 62 | 63 | # Build and run the project using the environment variables 64 | OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn build 65 | OPENAI_API_KEY=$OPENAI_API_KEY CODE=$CODE PORT=$PORT yarn start 66 | -------------------------------------------------------------------------------- /docs/vercel-es.md: -------------------------------------------------------------------------------- 1 | # Instrucciones de uso de Verbel 2 | 3 | ## Cómo crear un nuevo proyecto 4 | 5 | Cuando bifurca este proyecto desde Github y necesita crear un nuevo proyecto de Vercel en Vercel para volver a implementarlo, debe seguir los pasos a continuación. 6 | 7 | ![vercel-create-1](./images/vercel/vercel-create-1.jpg) 8 | 9 | 1. Vaya a la página de inicio de la consola de Vercel; 10 | 2. Haga clic en Agregar nuevo; 11 | 3. Seleccione Proyecto. 12 | 13 | ![vercel-create-2](./images/vercel/vercel-create-2.jpg) 14 | 15 | 1. En Import Git Repository, busque chatgpt-next-web; 16 | 2. Seleccione el proyecto de la nueva bifurcación y haga clic en Importar. 17 | 18 | ![vercel-create-3](./images/vercel/vercel-create-3.jpg) 19 | 20 | 1. En la página de configuración del proyecto, haga clic en Variables de entorno para configurar las variables de entorno; 21 | 2. Agregar variables de entorno denominadas OPENAI_API_KEY y CODE; 22 | 3. Rellenar los valores correspondientes a las variables de entorno; 23 | 4. Haga clic en Agregar para confirmar la adición de variables de entorno; 24 | 5. Asegúrese de agregar OPENAI_API_KEY, de lo contrario no funcionará; 25 | 6. Haga clic en Implementar, créelo y espere pacientemente unos 5 minutos a que se complete la implementación. 26 | 27 | ## Cómo agregar un nombre de dominio personalizado 28 | 29 | \[TODO] 30 | 31 | ## Cómo cambiar las variables de entorno 32 | 33 | ![vercel-env-edit](./images/vercel/vercel-env-edit.jpg) 34 | 35 | 1. Vaya a la consola interna del proyecto Vercel y haga clic en el botón Configuración en la parte superior; 36 | 2. Haga clic en Variables de entorno a la izquierda; 37 | 3. Haga clic en el botón a la derecha de una entrada existente; 38 | 4. Seleccione Editar para editarlo y, a continuación, guárdelo. 39 | 40 | ⚠️️ Nota: Lo necesita cada vez que modifique las variables de entorno[Volver a implementar el proyecto](#如何重新部署)para que los cambios surtan efecto! 41 | 42 | ## Cómo volver a implementar 43 | 44 | ![vercel-redeploy](./images/vercel/vercel-redeploy.jpg) 45 | 46 | 1. Vaya a la consola interna del proyecto Vercel y haga clic en el botón Implementaciones en la parte superior; 47 | 2. Seleccione el botón derecho del artículo superior de la lista; 48 | 3. Haga clic en Volver a implementar para volver a implementar. 49 | -------------------------------------------------------------------------------- /app/api/openai/[...path]/route.ts: -------------------------------------------------------------------------------- 1 | import { type OpenAIListModelResponse } from "@/app/client/platforms/openai"; 2 | import { getServerSideConfig } from "@/app/config/server"; 3 | import { OpenaiPath } from "@/app/constant"; 4 | import { prettyObject } from "@/app/utils/format"; 5 | import { NextRequest, NextResponse } from "next/server"; 6 | import { auth } from "../../auth"; 7 | import { requestOpenai } from "../../common"; 8 | 9 | const ALLOWD_PATH = new Set(Object.values(OpenaiPath)); 10 | 11 | function getModels(remoteModelRes: OpenAIListModelResponse) { 12 | const config = getServerSideConfig(); 13 | 14 | if (config.disableGPT4) { 15 | remoteModelRes.data = remoteModelRes.data.filter( 16 | (m) => !m.id.startsWith("gpt-4"), 17 | ); 18 | } 19 | 20 | return remoteModelRes; 21 | } 22 | 23 | async function handle( 24 | req: NextRequest, 25 | { params }: { params: { path: string[] } }, 26 | ) { 27 | console.log("[OpenAI Route] params ", params); 28 | 29 | if (req.method === "OPTIONS") { 30 | return NextResponse.json({ body: "OK" }, { status: 200 }); 31 | } 32 | 33 | const subpath = params.path.join("/"); 34 | 35 | if (!ALLOWD_PATH.has(subpath)) { 36 | console.log("[OpenAI Route] forbidden path ", subpath); 37 | return NextResponse.json( 38 | { 39 | error: true, 40 | msg: "you are not allowed to request " + subpath, 41 | }, 42 | { 43 | status: 403, 44 | }, 45 | ); 46 | } 47 | 48 | const authResult = auth(req); 49 | if (authResult.error) { 50 | return NextResponse.json(authResult, { 51 | status: 401, 52 | }); 53 | } 54 | 55 | try { 56 | const response = await requestOpenai(req); 57 | 58 | // list models 59 | if (subpath === OpenaiPath.ListModelPath && response.status === 200) { 60 | const resJson = (await response.json()) as OpenAIListModelResponse; 61 | const availableModels = getModels(resJson); 62 | return NextResponse.json(availableModels, { 63 | status: response.status, 64 | }); 65 | } 66 | 67 | return response; 68 | } catch (e) { 69 | console.error("[OpenAI] ", e); 70 | return NextResponse.json(prettyObject(e)); 71 | } 72 | } 73 | 74 | export const GET = handle; 75 | export const POST = handle; 76 | 77 | export const runtime = "edge"; 78 | -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | import webpack from "webpack"; 2 | 3 | const mode = process.env.BUILD_MODE ?? "standalone"; 4 | console.log("[Next] build mode", mode); 5 | 6 | const disableChunk = !!process.env.DISABLE_CHUNK || mode === "export"; 7 | console.log("[Next] build with chunk: ", !disableChunk); 8 | 9 | /** @type {import('next').NextConfig} */ 10 | const nextConfig = { 11 | webpack(config) { 12 | config.module.rules.push({ 13 | test: /\.svg$/, 14 | use: ["@svgr/webpack"], 15 | }); 16 | 17 | if (disableChunk) { 18 | config.plugins.push( 19 | new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), 20 | ); 21 | } 22 | 23 | return config; 24 | }, 25 | output: mode, 26 | images: { 27 | unoptimized: mode === "export", 28 | }, 29 | }; 30 | 31 | if (mode !== "export") { 32 | nextConfig.headers = async () => { 33 | return [ 34 | { 35 | source: "/api/:path*", 36 | headers: [ 37 | { key: "Access-Control-Allow-Credentials", value: "true" }, 38 | { key: "Access-Control-Allow-Origin", value: "*" }, 39 | { 40 | key: "Access-Control-Allow-Methods", 41 | value: "*", 42 | }, 43 | { 44 | key: "Access-Control-Allow-Headers", 45 | value: "*", 46 | }, 47 | { 48 | key: "Access-Control-Max-Age", 49 | value: "86400", 50 | }, 51 | ], 52 | }, 53 | ]; 54 | }; 55 | 56 | nextConfig.rewrites = async () => { 57 | const ret = [ 58 | { 59 | source: "/api/proxy/:path*", 60 | destination: "https://api.openai.com/:path*", 61 | }, 62 | { 63 | source: "/google-fonts/:path*", 64 | destination: "https://fonts.googleapis.com/:path*", 65 | }, 66 | { 67 | source: "/kiaskshare", 68 | destination: "https://share.kiask.xyz/api/conversations", 69 | }, 70 | ]; 71 | 72 | const apiUrl = process.env.API_URL; 73 | if (apiUrl) { 74 | console.log("[Next] using api url ", apiUrl); 75 | ret.push({ 76 | source: "/api/:path*", 77 | destination: `${apiUrl}/:path*`, 78 | }); 79 | } 80 | 81 | return { 82 | beforeFiles: ret, 83 | }; 84 | }; 85 | } 86 | 87 | export default nextConfig; 88 | -------------------------------------------------------------------------------- /next.config.mjs.bak: -------------------------------------------------------------------------------- 1 | import webpack from "webpack"; 2 | 3 | const mode = process.env.BUILD_MODE ?? "standalone"; 4 | console.log("[Next] build mode", mode); 5 | 6 | const disableChunk = !!process.env.DISABLE_CHUNK || mode === "export"; 7 | console.log("[Next] build with chunk: ", !disableChunk); 8 | 9 | /** @type {import('next').NextConfig} */ 10 | const nextConfig = { 11 | webpack(config) { 12 | config.module.rules.push({ 13 | test: /\.svg$/, 14 | use: ["@svgr/webpack"], 15 | }); 16 | 17 | if (disableChunk) { 18 | config.plugins.push( 19 | new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), 20 | ); 21 | } 22 | 23 | return config; 24 | }, 25 | output: mode, 26 | images: { 27 | unoptimized: mode === "export", 28 | }, 29 | }; 30 | 31 | if (mode !== "export") { 32 | nextConfig.headers = async () => { 33 | return [ 34 | { 35 | source: "/api/:path*", 36 | headers: [ 37 | { key: "Access-Control-Allow-Credentials", value: "true" }, 38 | { key: "Access-Control-Allow-Origin", value: "*" }, 39 | { 40 | key: "Access-Control-Allow-Methods", 41 | value: "*", 42 | }, 43 | { 44 | key: "Access-Control-Allow-Headers", 45 | value: "*", 46 | }, 47 | { 48 | key: "Access-Control-Max-Age", 49 | value: "86400", 50 | }, 51 | ], 52 | }, 53 | ]; 54 | }; 55 | 56 | nextConfig.rewrites = async () => { 57 | const ret = [ 58 | { 59 | source: "/api/proxy/:path*", 60 | destination: "https://api.openai.com/:path*", 61 | }, 62 | { 63 | source: "/google-fonts/:path*", 64 | destination: "https://fonts.googleapis.com/:path*", 65 | }, 66 | { 67 | source: "/kiaskshare", 68 | destination: "https://www.kiask.xyz/api/conversations", 69 | }, 70 | ]; 71 | 72 | const apiUrl = process.env.API_URL; 73 | if (apiUrl) { 74 | console.log("[Next] using api url ", apiUrl); 75 | ret.push({ 76 | source: "/api/:path*", 77 | destination: `${apiUrl}/:path*`, 78 | }); 79 | } 80 | 81 | return { 82 | beforeFiles: ret, 83 | }; 84 | }; 85 | } 86 | 87 | export default nextConfig; 88 | -------------------------------------------------------------------------------- /app/styles/highlight.scss: -------------------------------------------------------------------------------- 1 | .markdown-body { 2 | pre { 3 | padding: 0; 4 | } 5 | 6 | pre, 7 | code { 8 | font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; 9 | } 10 | 11 | pre code { 12 | display: block; 13 | overflow-x: auto; 14 | padding: 1em; 15 | } 16 | 17 | code { 18 | padding: 3px 5px; 19 | } 20 | 21 | .hljs, 22 | pre { 23 | background: #1a1b26; 24 | color: #cbd2ea; 25 | } 26 | 27 | /*! 28 | Theme: Tokyo-night-Dark 29 | origin: https://github.com/enkia/tokyo-night-vscode-theme 30 | Description: Original highlight.js style 31 | Author: (c) Henri Vandersleyen 32 | License: see project LICENSE 33 | Touched: 2022 34 | */ 35 | .hljs-comment, 36 | .hljs-meta { 37 | color: #565f89; 38 | } 39 | 40 | .hljs-deletion, 41 | .hljs-doctag, 42 | .hljs-regexp, 43 | .hljs-selector-attr, 44 | .hljs-selector-class, 45 | .hljs-selector-id, 46 | .hljs-selector-pseudo, 47 | .hljs-tag, 48 | .hljs-template-tag, 49 | .hljs-variable.language_ { 50 | color: #f7768e; 51 | } 52 | 53 | .hljs-link, 54 | .hljs-literal, 55 | .hljs-number, 56 | .hljs-params, 57 | .hljs-template-variable, 58 | .hljs-type, 59 | .hljs-variable { 60 | color: #ff9e64; 61 | } 62 | 63 | .hljs-attribute, 64 | .hljs-built_in { 65 | color: #e0af68; 66 | } 67 | 68 | .hljs-keyword, 69 | .hljs-property, 70 | .hljs-subst, 71 | .hljs-title, 72 | .hljs-title.class_, 73 | .hljs-title.class_.inherited__, 74 | .hljs-title.function_ { 75 | color: #7dcfff; 76 | } 77 | 78 | .hljs-selector-tag { 79 | color: #73daca; 80 | } 81 | 82 | .hljs-addition, 83 | .hljs-bullet, 84 | .hljs-quote, 85 | .hljs-string, 86 | .hljs-symbol { 87 | color: #9ece6a; 88 | } 89 | 90 | .hljs-code, 91 | .hljs-formula, 92 | .hljs-section { 93 | color: #7aa2f7; 94 | } 95 | 96 | .hljs-attr, 97 | .hljs-char.escape_, 98 | .hljs-keyword, 99 | .hljs-name, 100 | .hljs-operator { 101 | color: #bb9af7; 102 | } 103 | 104 | .hljs-punctuation { 105 | color: #c0caf5; 106 | } 107 | 108 | .hljs-emphasis { 109 | font-style: italic; 110 | } 111 | 112 | .hljs-strong { 113 | font-weight: 700; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/components/error.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { IconButton } from "./button"; 3 | import GithubIcon from "../icons/github.svg"; 4 | import ResetIcon from "../icons/reload.svg"; 5 | import { ISSUE_URL } from "../constant"; 6 | import Locale from "../locales"; 7 | import { downloadAs } from "../utils"; 8 | import { showConfirm } from "./ui-lib"; 9 | 10 | interface IErrorBoundaryState { 11 | hasError: boolean; 12 | error: Error | null; 13 | info: React.ErrorInfo | null; 14 | } 15 | 16 | export class ErrorBoundary extends React.Component { 17 | constructor(props: any) { 18 | super(props); 19 | this.state = { hasError: false, error: null, info: null }; 20 | } 21 | 22 | componentDidCatch(error: Error, info: React.ErrorInfo) { 23 | // Update state with error details 24 | this.setState({ hasError: true, error, info }); 25 | } 26 | 27 | clearAndSaveData() { 28 | try { 29 | downloadAs( 30 | JSON.stringify(localStorage), 31 | "chatgpt-next-web-snapshot.json", 32 | ); 33 | } finally { 34 | localStorage.clear(); 35 | location.reload(); 36 | } 37 | } 38 | 39 | render() { 40 | if (this.state.hasError) { 41 | // Render error message 42 | return ( 43 |
44 |

Oops, something went wrong!

45 |
46 |             {this.state.error?.toString()}
47 |             {this.state.info?.componentStack}
48 |           
49 | 50 |
51 | 52 | } 55 | bordered 56 | /> 57 | 58 | } 60 | text="Clear All Data" 61 | onClick={async () => { 62 | if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) { 63 | this.clearAndSaveData(); 64 | } 65 | }} 66 | bordered 67 | /> 68 |
69 |
70 | ); 71 | } 72 | // if no error occurred, render children 73 | return this.props.children; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /scripts/fetch-prompts.mjs: -------------------------------------------------------------------------------- 1 | import fetch from "node-fetch"; 2 | import fs from "fs/promises"; 3 | 4 | const RAW_FILE_URL = "https://raw.githubusercontent.com/"; 5 | const MIRRORF_FILE_URL = "http://raw.fgit.ml/"; 6 | 7 | const RAW_CN_URL = "PlexPt/awesome-chatgpt-prompts-zh/main/prompts-zh.json"; 8 | const CN_URL = MIRRORF_FILE_URL + RAW_CN_URL; 9 | const RAW_EN_URL = "f/awesome-chatgpt-prompts/main/prompts.csv"; 10 | const EN_URL = MIRRORF_FILE_URL + RAW_EN_URL; 11 | const FILE = "./public/prompts.json"; 12 | 13 | const ignoreWords = ["涩涩", "魅魔"]; 14 | 15 | const timeoutPromise = (timeout) => { 16 | return new Promise((resolve, reject) => { 17 | setTimeout(() => { 18 | reject(new Error("Request timeout")); 19 | }, timeout); 20 | }); 21 | }; 22 | 23 | async function fetchCN() { 24 | console.log("[Fetch] fetching cn prompts..."); 25 | try { 26 | const response = await Promise.race([fetch(CN_URL), timeoutPromise(5000)]); 27 | const raw = await response.json(); 28 | return raw 29 | .map((v) => [v.act, v.prompt]) 30 | .filter( 31 | (v) => 32 | v[0] && 33 | v[1] && 34 | ignoreWords.every((w) => !v[0].includes(w) && !v[1].includes(w)), 35 | ); 36 | } catch (error) { 37 | console.error("[Fetch] failed to fetch cn prompts", error); 38 | return []; 39 | } 40 | } 41 | 42 | async function fetchEN() { 43 | console.log("[Fetch] fetching en prompts..."); 44 | try { 45 | // const raw = await (await fetch(EN_URL)).text(); 46 | const response = await Promise.race([fetch(EN_URL), timeoutPromise(5000)]); 47 | const raw = await response.text(); 48 | return raw 49 | .split("\n") 50 | .slice(1) 51 | .map((v) => 52 | v 53 | .split('","') 54 | .map((v) => v.replace(/^"|"$/g, "").replaceAll('""', '"')) 55 | .filter((v) => v[0] && v[1]), 56 | ); 57 | } catch (error) { 58 | console.error("[Fetch] failed to fetch en prompts", error); 59 | return []; 60 | } 61 | } 62 | 63 | async function main() { 64 | Promise.all([fetchCN(), fetchEN()]) 65 | .then(([cn, en]) => { 66 | fs.writeFile(FILE, JSON.stringify({ cn, en })); 67 | }) 68 | .catch((e) => { 69 | console.error("[Fetch] failed to fetch prompts"); 70 | fs.writeFile(FILE, JSON.stringify({ cn: [], en: [] })); 71 | }) 72 | .finally(() => { 73 | console.log("[Fetch] saved to " + FILE); 74 | }); 75 | } 76 | 77 | main(); 78 | -------------------------------------------------------------------------------- /app/components/mask.module.scss: -------------------------------------------------------------------------------- 1 | @import "../styles/animation.scss"; 2 | .mask-page { 3 | height: 100%; 4 | display: flex; 5 | flex-direction: column; 6 | 7 | .mask-page-body { 8 | padding: 20px; 9 | overflow-y: auto; 10 | 11 | .mask-filter { 12 | width: 100%; 13 | max-width: 100%; 14 | margin-bottom: 20px; 15 | animation: slide-in ease 0.3s; 16 | height: 40px; 17 | 18 | display: flex; 19 | 20 | .search-bar { 21 | flex-grow: 1; 22 | max-width: 100%; 23 | min-width: 0; 24 | } 25 | 26 | .mask-filter-lang { 27 | height: 100%; 28 | margin-left: 10px; 29 | } 30 | 31 | .mask-create { 32 | height: 100%; 33 | margin-left: 10px; 34 | box-sizing: border-box; 35 | min-width: 80px; 36 | } 37 | } 38 | 39 | .mask-item { 40 | display: flex; 41 | justify-content: space-between; 42 | padding: 20px; 43 | border: var(--border-in-light); 44 | animation: slide-in ease 0.3s; 45 | 46 | &:not(:last-child) { 47 | border-bottom: 0; 48 | } 49 | 50 | &:first-child { 51 | border-top-left-radius: 10px; 52 | border-top-right-radius: 10px; 53 | } 54 | 55 | &:last-child { 56 | border-bottom-left-radius: 10px; 57 | border-bottom-right-radius: 10px; 58 | } 59 | 60 | .mask-header { 61 | display: flex; 62 | align-items: center; 63 | 64 | .mask-icon { 65 | display: flex; 66 | align-items: center; 67 | justify-content: center; 68 | margin-right: 10px; 69 | } 70 | 71 | .mask-title { 72 | .mask-name { 73 | font-size: 14px; 74 | font-weight: bold; 75 | } 76 | .mask-info { 77 | font-size: 12px; 78 | } 79 | } 80 | } 81 | 82 | .mask-actions { 83 | display: flex; 84 | flex-wrap: nowrap; 85 | transition: all ease 0.3s; 86 | } 87 | 88 | @media screen and (max-width: 600px) { 89 | display: flex; 90 | flex-direction: column; 91 | padding-bottom: 10px; 92 | border-radius: 10px; 93 | margin-bottom: 20px; 94 | box-shadow: var(--card-shadow); 95 | 96 | &:not(:last-child) { 97 | border-bottom: var(--border-in-light); 98 | } 99 | 100 | .mask-actions { 101 | width: 100%; 102 | justify-content: space-between; 103 | padding-top: 10px; 104 | } 105 | } 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/api/common.ts: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from "next/server"; 2 | 3 | export const OPENAI_URL = "api.openai.com"; 4 | const DEFAULT_PROTOCOL = "https"; 5 | const PROTOCOL = process.env.PROTOCOL ?? DEFAULT_PROTOCOL; 6 | const BASE_URL = process.env.BASE_URL ?? OPENAI_URL; 7 | const DISABLE_GPT4 = !!process.env.DISABLE_GPT4; 8 | 9 | export async function requestOpenai(req: NextRequest) { 10 | const controller = new AbortController(); 11 | const authValue = req.headers.get("Authorization") ?? ""; 12 | const openaiPath = `${req.nextUrl.pathname}${req.nextUrl.search}`.replaceAll( 13 | "/api/openai/", 14 | "", 15 | ); 16 | 17 | let baseUrl = BASE_URL; 18 | 19 | if (!baseUrl.startsWith("http")) { 20 | baseUrl = `${PROTOCOL}://${baseUrl}`; 21 | } 22 | 23 | console.log("[Proxy] ", openaiPath); 24 | console.log("[Base Url]", baseUrl); 25 | 26 | if (process.env.OPENAI_ORG_ID) { 27 | console.log("[Org ID]", process.env.OPENAI_ORG_ID); 28 | } 29 | 30 | const timeoutId = setTimeout(() => { 31 | controller.abort(); 32 | }, 10 * 60 * 1000); 33 | 34 | const fetchUrl = `${baseUrl}/${openaiPath}`; 35 | const fetchOptions: RequestInit = { 36 | headers: { 37 | "Content-Type": "application/json", 38 | Authorization: authValue, 39 | ...(process.env.OPENAI_ORG_ID && { 40 | "OpenAI-Organization": process.env.OPENAI_ORG_ID, 41 | }), 42 | }, 43 | cache: "no-store", 44 | method: req.method, 45 | body: req.body, 46 | // @ts-ignore 47 | duplex: "half", 48 | signal: controller.signal, 49 | }; 50 | 51 | // #1815 try to refuse gpt4 request 52 | if (DISABLE_GPT4 && req.body) { 53 | try { 54 | const clonedBody = await req.text(); 55 | fetchOptions.body = clonedBody; 56 | 57 | const jsonBody = JSON.parse(clonedBody); 58 | 59 | if ((jsonBody?.model ?? "").includes("gpt-4")) { 60 | return NextResponse.json( 61 | { 62 | error: true, 63 | message: "you are not allowed to use gpt-4 model", 64 | }, 65 | { 66 | status: 403, 67 | }, 68 | ); 69 | } 70 | } catch (e) { 71 | console.error("[OpenAI] gpt4 filter", e); 72 | } 73 | } 74 | 75 | try { 76 | const res = await fetch(fetchUrl, fetchOptions); 77 | 78 | // to prevent browser prompt for credentials 79 | const newHeaders = new Headers(res.headers); 80 | newHeaders.delete("www-authenticate"); 81 | 82 | // to disbale ngnix buffering 83 | newHeaders.set("X-Accel-Buffering", "no"); 84 | 85 | return new Response(res.body, { 86 | status: res.status, 87 | statusText: res.statusText, 88 | headers: newHeaders, 89 | }); 90 | } finally { 91 | clearTimeout(timeoutId); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/store/access.ts: -------------------------------------------------------------------------------- 1 | import { create } from "zustand"; 2 | import { persist } from "zustand/middleware"; 3 | import { DEFAULT_API_HOST, StoreKey } from "../constant"; 4 | import { getHeaders } from "../client/api"; 5 | import { BOT_HELLO } from "./chat"; 6 | import { getClientConfig } from "../config/client"; 7 | 8 | export interface AccessControlStore { 9 | accessCode: string; 10 | token: string; 11 | 12 | needCode: boolean; 13 | hideUserApiKey: boolean; 14 | openaiUrl: string; 15 | hideBalanceQuery: boolean; 16 | 17 | updateToken: (_: string) => void; 18 | updateCode: (_: string) => void; 19 | updateOpenAiUrl: (_: string) => void; 20 | enabledAccessControl: () => boolean; 21 | isAuthorized: () => boolean; 22 | fetch: () => void; 23 | } 24 | 25 | let fetchState = 0; // 0 not fetch, 1 fetching, 2 done 26 | 27 | const DEFAULT_OPENAI_URL = 28 | getClientConfig()?.buildMode === "export" ? DEFAULT_API_HOST : "/api/openai/"; 29 | console.log("[API] default openai url", DEFAULT_OPENAI_URL); 30 | 31 | export const useAccessStore = create()( 32 | persist( 33 | (set, get) => ({ 34 | token: "", 35 | accessCode: "", 36 | needCode: true, 37 | hideUserApiKey: false, 38 | openaiUrl: DEFAULT_OPENAI_URL, 39 | hideBalanceQuery: false, 40 | 41 | enabledAccessControl() { 42 | get().fetch(); 43 | 44 | return get().needCode; 45 | }, 46 | updateCode(code: string) { 47 | set(() => ({ accessCode: code })); 48 | }, 49 | updateToken(token: string) { 50 | set(() => ({ token })); 51 | }, 52 | updateOpenAiUrl(url: string) { 53 | set(() => ({ openaiUrl: url })); 54 | }, 55 | isAuthorized() { 56 | get().fetch(); 57 | 58 | // has token or has code or disabled access control 59 | return ( 60 | !!get().token || !!get().accessCode || !get().enabledAccessControl() 61 | ); 62 | }, 63 | fetch() { 64 | if (fetchState > 0 || getClientConfig()?.buildMode === "export") return; 65 | fetchState = 1; 66 | fetch("/api/config", { 67 | method: "post", 68 | body: null, 69 | headers: { 70 | ...getHeaders(), 71 | }, 72 | }) 73 | .then((res) => res.json()) 74 | .then((res: DangerConfig) => { 75 | console.log("[Config] got config from server", res); 76 | set(() => ({ ...res })); 77 | 78 | if ((res as any).botHello) { 79 | BOT_HELLO.content = (res as any).botHello; 80 | } 81 | }) 82 | .catch(() => { 83 | console.error("[Config] failed to fetch config"); 84 | }) 85 | .finally(() => { 86 | fetchState = 2; 87 | }); 88 | }, 89 | }), 90 | { 91 | name: StoreKey.Access, 92 | version: 1, 93 | }, 94 | ), 95 | ); 96 | -------------------------------------------------------------------------------- /app/icons/light.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/components/new-chat.module.scss: -------------------------------------------------------------------------------- 1 | @import "../styles/animation.scss"; 2 | 3 | .new-chat { 4 | height: 100%; 5 | width: 100%; 6 | display: flex; 7 | align-items: center; 8 | justify-content: center; 9 | flex-direction: column; 10 | 11 | .mask-header { 12 | display: flex; 13 | justify-content: space-between; 14 | width: 100%; 15 | padding: 10px; 16 | box-sizing: border-box; 17 | animation: slide-in-from-top ease 0.3s; 18 | } 19 | 20 | .mask-cards { 21 | display: flex; 22 | margin-top: 5vh; 23 | margin-bottom: 20px; 24 | animation: slide-in ease 0.3s; 25 | 26 | .mask-card { 27 | padding: 20px 10px; 28 | border: var(--border-in-light); 29 | box-shadow: var(--card-shadow); 30 | border-radius: 14px; 31 | background-color: var(--white); 32 | transform: scale(1); 33 | 34 | &:first-child { 35 | transform: rotate(-15deg) translateY(5px); 36 | } 37 | 38 | &:last-child { 39 | transform: rotate(15deg) translateY(5px); 40 | } 41 | } 42 | } 43 | 44 | .title { 45 | font-size: 32px; 46 | font-weight: bolder; 47 | margin-bottom: 1vh; 48 | animation: slide-in ease 0.35s; 49 | } 50 | 51 | .sub-title { 52 | animation: slide-in ease 0.4s; 53 | } 54 | 55 | .actions { 56 | margin-top: 5vh; 57 | margin-bottom: 2vh; 58 | animation: slide-in ease 0.45s; 59 | display: flex; 60 | justify-content: center; 61 | font-size: 12px; 62 | 63 | .skip { 64 | margin-left: 10px; 65 | } 66 | } 67 | 68 | .masks { 69 | flex-grow: 1; 70 | width: 100%; 71 | overflow: auto; 72 | align-items: center; 73 | padding-top: 20px; 74 | 75 | $linear: linear-gradient( 76 | to bottom, 77 | rgba(0, 0, 0, 0), 78 | rgba(0, 0, 0, 1), 79 | rgba(0, 0, 0, 0) 80 | ); 81 | 82 | -webkit-mask-image: $linear; 83 | mask-image: $linear; 84 | 85 | animation: slide-in ease 0.5s; 86 | 87 | .mask-row { 88 | display: flex; 89 | // justify-content: center; 90 | margin-bottom: 10px; 91 | 92 | @for $i from 1 to 10 { 93 | &:nth-child(#{$i * 2}) { 94 | margin-left: 50px; 95 | } 96 | } 97 | 98 | .mask { 99 | display: flex; 100 | align-items: center; 101 | padding: 10px 14px; 102 | border: var(--border-in-light); 103 | box-shadow: var(--card-shadow); 104 | background-color: var(--white); 105 | border-radius: 10px; 106 | margin-right: 10px; 107 | max-width: 8em; 108 | transform: scale(1); 109 | cursor: pointer; 110 | transition: all ease 0.3s; 111 | 112 | &:hover { 113 | transform: translateY(-5px) scale(1.1); 114 | z-index: 999; 115 | border-color: var(--primary); 116 | } 117 | 118 | .mask-name { 119 | margin-left: 10px; 120 | font-size: 14px; 121 | } 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src-tauri/tauri.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../node_modules/@tauri-apps/cli/schema.json", 3 | "build": { 4 | "beforeBuildCommand": "yarn export", 5 | "beforeDevCommand": "yarn export:dev", 6 | "devPath": "http://localhost:3000", 7 | "distDir": "../out", 8 | "withGlobalTauri": true 9 | }, 10 | "package": { 11 | "productName": "Ultimate ChatGPT", 12 | "version": "2.8.8" 13 | }, 14 | "tauri": { 15 | "allowlist": { 16 | "all": false, 17 | "shell": { 18 | "all": false, 19 | "open": true 20 | }, 21 | "dialog": { 22 | "all": true, 23 | "ask": true, 24 | "confirm": true, 25 | "message": true, 26 | "open": true, 27 | "save": true 28 | }, 29 | "clipboard": { 30 | "all": true, 31 | "writeText": true, 32 | "readText": true 33 | }, 34 | "window": { 35 | "all": false, 36 | "close": true, 37 | "hide": true, 38 | "maximize": true, 39 | "minimize": true, 40 | "setIcon": true, 41 | "setIgnoreCursorEvents": true, 42 | "setResizable": true, 43 | "show": true, 44 | "startDragging": true, 45 | "unmaximize": true, 46 | "unminimize": true 47 | } 48 | }, 49 | "bundle": { 50 | "active": true, 51 | "category": "DeveloperTool", 52 | "copyright": "2023, Zhang Yifei All Rights Reserved.", 53 | "deb": { 54 | "depends": [] 55 | }, 56 | "externalBin": [], 57 | "icon": [ 58 | "icons/32x32.png", 59 | "icons/128x128.png", 60 | "icons/128x128@2x.png", 61 | "icons/icon.icns", 62 | "icons/icon.ico" 63 | ], 64 | "identifier": "com.yida.chatgpt.next.web", 65 | "longDescription": "Ultimate ChatGPT is a cross-platform ChatGPT client, including Web/Win/Linux/OSX/PWA.", 66 | "macOS": { 67 | "entitlements": null, 68 | "exceptionDomain": "", 69 | "frameworks": [], 70 | "providerShortName": null, 71 | "signingIdentity": null 72 | }, 73 | "resources": [], 74 | "shortDescription": "Ultimate ChatGPT App", 75 | "targets": "all", 76 | "windows": { 77 | "certificateThumbprint": null, 78 | "digestAlgorithm": "sha256", 79 | "timestampUrl": "" 80 | } 81 | }, 82 | "security": { 83 | "csp": null 84 | }, 85 | "updater": { 86 | "active": true, 87 | "endpoints": [ 88 | "https://github.com/Yidadaa/ChatGPT-Next-Web/releases/latest/download/latest.json" 89 | ], 90 | "dialog": false, 91 | "windows": { 92 | "installMode": "passive" 93 | }, 94 | "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IERFNDE4MENFM0Y1RTZBOTQKUldTVWFsNC96b0JCM3RqM2NmMnlFTmxIaStRaEJrTHNOU2VqRVlIV1hwVURoWUdVdEc1eDcxVEYK" 95 | }, 96 | "windows": [ 97 | { 98 | "fullscreen": false, 99 | "height": 600, 100 | "resizable": true, 101 | "title": "Ultimate ChatGPT", 102 | "width": 960, 103 | "hiddenTitle": true, 104 | "titleBarStyle": "Overlay" 105 | } 106 | ] 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/icons/plugin.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/icons/lightning.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/icons/cancel.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/store/mask.ts: -------------------------------------------------------------------------------- 1 | import { create } from "zustand"; 2 | import { persist } from "zustand/middleware"; 3 | import { BUILTIN_MASKS } from "../masks"; 4 | import { getLang, Lang } from "../locales"; 5 | import { DEFAULT_TOPIC, ChatMessage } from "./chat"; 6 | import { ModelConfig, useAppConfig } from "./config"; 7 | import { StoreKey } from "../constant"; 8 | 9 | export type Mask = { 10 | id: number; 11 | avatar: string; 12 | name: string; 13 | hideContext?: boolean; 14 | context: ChatMessage[]; 15 | syncGlobalConfig?: boolean; 16 | modelConfig: ModelConfig; 17 | lang: Lang; 18 | builtin: boolean; 19 | }; 20 | 21 | export const DEFAULT_MASK_STATE = { 22 | masks: {} as Record, 23 | globalMaskId: 0, 24 | }; 25 | 26 | export type MaskState = typeof DEFAULT_MASK_STATE; 27 | type MaskStore = MaskState & { 28 | create: (mask?: Partial) => Mask; 29 | update: (id: number, updater: (mask: Mask) => void) => void; 30 | delete: (id: number) => void; 31 | search: (text: string) => Mask[]; 32 | get: (id?: number) => Mask | null; 33 | getAll: () => Mask[]; 34 | }; 35 | 36 | export const DEFAULT_MASK_ID = 1145141919810; 37 | export const DEFAULT_MASK_AVATAR = "gpt-bot"; 38 | export const createEmptyMask = () => 39 | ({ 40 | id: DEFAULT_MASK_ID, 41 | avatar: DEFAULT_MASK_AVATAR, 42 | name: DEFAULT_TOPIC, 43 | context: [], 44 | syncGlobalConfig: true, // use global config as default 45 | modelConfig: { ...useAppConfig.getState().modelConfig }, 46 | lang: getLang(), 47 | builtin: false, 48 | } as Mask); 49 | 50 | export const useMaskStore = create()( 51 | persist( 52 | (set, get) => ({ 53 | ...DEFAULT_MASK_STATE, 54 | 55 | create(mask) { 56 | set(() => ({ globalMaskId: get().globalMaskId + 1 })); 57 | const id = get().globalMaskId; 58 | const masks = get().masks; 59 | masks[id] = { 60 | ...createEmptyMask(), 61 | ...mask, 62 | id, 63 | builtin: false, 64 | }; 65 | 66 | set(() => ({ masks })); 67 | 68 | return masks[id]; 69 | }, 70 | update(id, updater) { 71 | const masks = get().masks; 72 | const mask = masks[id]; 73 | if (!mask) return; 74 | const updateMask = { ...mask }; 75 | updater(updateMask); 76 | masks[id] = updateMask; 77 | set(() => ({ masks })); 78 | }, 79 | delete(id) { 80 | const masks = get().masks; 81 | delete masks[id]; 82 | set(() => ({ masks })); 83 | }, 84 | 85 | get(id) { 86 | return get().masks[id ?? 1145141919810]; 87 | }, 88 | getAll() { 89 | const userMasks = Object.values(get().masks).sort( 90 | (a, b) => b.id - a.id, 91 | ); 92 | const config = useAppConfig.getState(); 93 | if (config.hideBuiltinMasks) return userMasks; 94 | const buildinMasks = BUILTIN_MASKS.map( 95 | (m) => 96 | ({ 97 | ...m, 98 | modelConfig: { 99 | ...config.modelConfig, 100 | ...m.modelConfig, 101 | }, 102 | } as Mask), 103 | ); 104 | return userMasks.concat(buildinMasks); 105 | }, 106 | search(text) { 107 | return Object.values(get().masks); 108 | }, 109 | }), 110 | { 111 | name: StoreKey.Mask, 112 | version: 2, 113 | }, 114 | ), 115 | ); 116 | -------------------------------------------------------------------------------- /app/icons/chatgpt.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/locales/index.ts: -------------------------------------------------------------------------------- 1 | import cn from "./cn"; 2 | import en from "./en"; 3 | import tw from "./tw"; 4 | import fr from "./fr"; 5 | import es from "./es"; 6 | import it from "./it"; 7 | import tr from "./tr"; 8 | import jp from "./jp"; 9 | import de from "./de"; 10 | import vi from "./vi"; 11 | import ru from "./ru"; 12 | import no from "./no"; 13 | import cs from "./cs"; 14 | import ko from "./ko"; 15 | import ar from "./ar"; 16 | import bn from "./bn"; 17 | import hi from "./hi"; 18 | import hr from "./hr"; 19 | import ur from "./ur"; 20 | import pl from "./pl"; 21 | import ph from "./ph"; 22 | import pt from "./pt"; 23 | import tl from "./tl"; 24 | import du from "./du"; 25 | import cz from "./cz"; 26 | import gr from "./gr"; 27 | import kz from "./kz"; 28 | import id from "./id"; 29 | import zh from "./zh"; 30 | import tam from "./tam"; 31 | import am from "./am"; 32 | import { merge } from "../utils/merge"; 33 | 34 | import type { LocaleType } from "./cn"; 35 | export type { LocaleType, PartialLocaleType } from "./cn"; 36 | 37 | const ALL_LANGS = { 38 | cn, 39 | en, 40 | tw, 41 | jp, 42 | ko, 43 | zh, 44 | tam, 45 | fr, 46 | es, 47 | it, 48 | tr, 49 | de, 50 | vi, 51 | ru, 52 | cs, 53 | no, 54 | ar, 55 | bn, 56 | hi, 57 | hr, 58 | ur, 59 | pl, 60 | ph, 61 | pt, 62 | tl, 63 | du, 64 | cz, 65 | gr, 66 | kz, 67 | id, 68 | am, 69 | }; 70 | 71 | export type Lang = keyof typeof ALL_LANGS; 72 | 73 | export const AllLangs = Object.keys(ALL_LANGS) as Lang[]; 74 | 75 | export const ALL_LANG_OPTIONS: Record = { 76 | cn: "简体中文", 77 | en: "English", 78 | tw: "繁體中文", 79 | jp: "日本語", 80 | ko: "한국어", 81 | zh: "語言", 82 | fr: "Français", 83 | es: "Español", 84 | it: "Italiano", 85 | tr: "Türkçe", 86 | de: "Deutsch", 87 | vi: "Tiếng Việt", 88 | ru: "Русский", 89 | cs: "Čeština", 90 | no: "Nynorsk", 91 | ar: "العربية", 92 | bn: "বাংলা", 93 | hi: "भाषा", 94 | hr: "שפה", 95 | ur: "زبان", 96 | pl: "Język", 97 | ph: "Wika", 98 | pt: "Idioma", 99 | tl: "Tagalog", 100 | du: "Dutch", 101 | cz: "Czech", 102 | gr: "Γλώσσα", 103 | kz: "Қазақ", 104 | id: "Bahasa", 105 | tam: "Tamazight", 106 | am: "Armenian", 107 | }; 108 | 109 | const LANG_KEY = "lang"; 110 | const DEFAULT_LANG = "en"; 111 | 112 | const fallbackLang = en; 113 | const targetLang = ALL_LANGS[getLang()] as LocaleType; 114 | 115 | 116 | merge(fallbackLang, targetLang); 117 | 118 | export default fallbackLang as LocaleType; 119 | 120 | function getItem(key: string) { 121 | try { 122 | return localStorage.getItem(key); 123 | } catch { 124 | return null; 125 | } 126 | } 127 | 128 | function setItem(key: string, value: string) { 129 | try { 130 | localStorage.setItem(key, value); 131 | } catch {} 132 | } 133 | 134 | function getLanguage() { 135 | try { 136 | return navigator.language.toLowerCase(); 137 | } catch { 138 | return DEFAULT_LANG; 139 | } 140 | } 141 | 142 | export function getLang(): Lang { 143 | const savedLang = getItem(LANG_KEY); 144 | 145 | if (AllLangs.includes((savedLang ?? "") as Lang)) { 146 | return savedLang as Lang; 147 | } 148 | 149 | const lang = getLanguage(); 150 | 151 | for (const option of AllLangs) { 152 | if (lang.includes(option)) { 153 | return option; 154 | } 155 | } 156 | 157 | return DEFAULT_LANG; 158 | } 159 | 160 | export function changeLang(lang: Lang) { 161 | setItem(LANG_KEY, lang); 162 | location.reload(); 163 | } 164 | -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable @next/next/no-page-custom-font */ 2 | const FAVICON_FOLDER = "/favicons"; 3 | import "./styles/globals.scss"; 4 | import "./styles/markdown.scss"; 5 | import "./styles/highlight.scss"; 6 | import { getClientConfig } from "./config/client"; 7 | 8 | export const metadata = { 9 | title: "The Ultimate ChatGPT", 10 | description: "Experience the Ultimate ChatGPT Chat Bot: Powered by GPT-3.5 Turbo AI, our cutting-edge virtual assistant revolutionizes your online interactions. Engage in captivating conversations, get instant answers, and access a wealth of knowledge. With unparalleled intelligence and lightning-fast response times, our Chat Bot is your go-to source for expert advice, innovative ideas, and friendly banter. Don't miss out on this incredible opportunity to explore the future of AI. Click now to unlock endless possibilities with our advanced ChatGPT Chat Bot!", 11 | viewport: { 12 | width: "device-width", 13 | initialScale: 1, 14 | maximumScale: 1, 15 | }, 16 | themeColor: [ 17 | { media: "(prefers-color-scheme: light)", color: "#fafafa" }, 18 | { media: "(prefers-color-scheme: dark)", color: "#151515" }, 19 | ], 20 | appleWebApp: { 21 | title: "The Ultimate ChatGPT - Unlock the ultimate features of ChatGPT", 22 | statusBarStyle: "default", 23 | }, 24 | }; 25 | 26 | export default function RootLayout({ 27 | children, 28 | }: { 29 | children: React.ReactNode; 30 | }) { 31 | const { title, description } = metadata; // Add these variables or assign appropriate values 32 | const canonical = "https://chatgpt.kiask.xyz"; // Add the canonical URL or assign an appropriate value 33 | 34 | return ( 35 | 36 | 37 | 38 | 43 | 49 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | {children} 74 | 75 | ); 76 | } 77 | -------------------------------------------------------------------------------- /app/constant.ts: -------------------------------------------------------------------------------- 1 | export const OWNER = "imabutahersiddik"; 2 | export const REPO = "ultimate-chatgpt"; 3 | export const REPO_URL = `https://github.com/${OWNER}/${REPO}`; 4 | export const ISSUE_URL = `https://github.com/${OWNER}/${REPO}/issues`; 5 | export const UPDATE_URL = `${REPO_URL}#keep-updated`; 6 | export const RELEASE_URL = `${REPO_URL}/releases`; 7 | export const FETCH_COMMIT_URL = `https://api.github.com/repos/${OWNER}/${REPO}/commits?per_page=1`; 8 | export const FETCH_TAG_URL = `https://api.github.com/repos/${OWNER}/${REPO}/tags?per_page=1`; 9 | export const RUNTIME_CONFIG_DOM = "danger-runtime-config"; 10 | export const DEFAULT_API_HOST = "https://api.chatanywhere.cn"; 11 | 12 | export enum Path { 13 | Home = "/", 14 | Chat = "/chat", 15 | Settings = "/settings", 16 | NewChat = "/new-chat", 17 | Masks = "/masks", 18 | Auth = "/auth", 19 | } 20 | 21 | export enum SlotID { 22 | AppBody = "app-body", 23 | } 24 | 25 | export enum FileName { 26 | Masks = "masks.json", 27 | Prompts = "prompts.json", 28 | } 29 | 30 | export enum StoreKey { 31 | Chat = "chat-next-web-store", 32 | Access = "access-control", 33 | Config = "app-config", 34 | Mask = "mask-store", 35 | Prompt = "prompt-store", 36 | Update = "chat-update", 37 | Sync = "sync", 38 | } 39 | 40 | export const MAX_SIDEBAR_WIDTH = 500; 41 | export const MIN_SIDEBAR_WIDTH = 230; 42 | export const NARROW_SIDEBAR_WIDTH = 100; 43 | 44 | export const ACCESS_CODE_PREFIX = ""; 45 | 46 | export const LAST_INPUT_KEY = "last-input"; 47 | 48 | export const REQUEST_TIMEOUT_MS = 60000; 49 | 50 | export const EXPORT_MESSAGE_CLASS_NAME = "export-markdown"; 51 | 52 | export const OpenaiPath = { 53 | ChatPath: "v1/chat/completions", 54 | UsagePath: "dashboard/billing/usage", 55 | SubsPath: "dashboard/billing/subscription", 56 | ListModelPath: "v1/models", 57 | }; 58 | 59 | export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang 60 | export const DEFAULT_SYSTEM_TEMPLATE = ` 61 | You are ChatGPT, a large language model trained by OpenAI. 62 | Knowledge cutoff: 2021-09 63 | Current model: {{model}} 64 | Current time: {{time}}`; 65 | 66 | export const DEFAULT_MODELS = [ 67 | { 68 | name: "gpt-4", 69 | available: true, 70 | }, 71 | { 72 | name: "gpt-4-0314", 73 | available: true, 74 | }, 75 | { 76 | name: "gpt-4-0613", 77 | available: true, 78 | }, 79 | { 80 | name: "gpt-4-32k", 81 | available: true, 82 | }, 83 | { 84 | name: "gpt-4-32k-0314", 85 | available: true, 86 | }, 87 | { 88 | name: "gpt-4-32k-0613", 89 | available: true, 90 | }, 91 | { 92 | name: "gpt-3.5-turbo", 93 | available: true, 94 | }, 95 | { 96 | name: "gpt-3.5-turbo-0301", 97 | available: true, 98 | }, 99 | { 100 | name: "gpt-3.5-turbo-0613", 101 | available: true, 102 | }, 103 | { 104 | name: "gpt-3.5-turbo-16k", 105 | available: true, 106 | }, 107 | { 108 | name: "gpt-3.5-turbo-16k-0613", 109 | available: true, 110 | }, 111 | { 112 | name: "qwen-v1", // 通义千问 113 | available: false, 114 | }, 115 | { 116 | name: "ernie", // 文心一言 117 | available: false, 118 | }, 119 | { 120 | name: "spark", // 讯飞星火 121 | available: false, 122 | }, 123 | { 124 | name: "llama", // llama 125 | available: false, 126 | }, 127 | { 128 | name: "chatglm", // chatglm-6b 129 | available: false, 130 | }, 131 | { 132 | name: "text-bison-001", // text-bison-001 133 | available: true, 134 | }, 135 | ] as const; 136 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 版权所有(c)<2023> 2 | 3 | 反996许可证版本1.0 4 | 5 | 在符合下列条件的情况下, 6 | 特此免费向任何得到本授权作品的副本(包括源代码、文件和/或相关内容,以下统称为“授权作品” 7 | )的个人和法人实体授权:被授权个人或法人实体有权以任何目的处置授权作品,包括但不限于使 8 | 用、复制,修改,衍生利用、散布,发布和再许可: 9 | 10 | 11 | 1. 个人或法人实体必须在许可作品的每个再散布或衍生副本上包含以上版权声明和本许可证,不 12 | 得自行修改。 13 | 2. 个人或法人实体必须严格遵守与个人实际所在地或个人出生地或归化地、或法人实体注册地或 14 | 经营地(以较严格者为准)的司法管辖区所有适用的与劳动和就业相关法律、法规、规则和 15 | 标准。如果该司法管辖区没有此类法律、法规、规章和标准或其法律、法规、规章和标准不可 16 | 执行,则个人或法人实体必须遵守国际劳工标准的核心公约。 17 | 3. 个人或法人不得以任何方式诱导或强迫其全职或兼职员工或其独立承包人以口头或书面形式同 18 | 意直接或间接限制、削弱或放弃其所拥有的,受相关与劳动和就业有关的法律、法规、规则和 19 | 标准保护的权利或补救措施,无论该等书面或口头协议是否被该司法管辖区的法律所承认,该 20 | 等个人或法人实体也不得以任何方法限制其雇员或独立承包人向版权持有人或监督许可证合规 21 | 情况的有关当局报告或投诉上述违反许可证的行为的权利。 22 | 23 | 该授权作品是"按原样"提供,不做任何明示或暗示的保证,包括但不限于对适销性、特定用途适用 24 | 性和非侵权性的保证。在任何情况下,无论是在合同诉讼、侵权诉讼或其他诉讼中,版权持有人均 25 | 不承担因本软件或本软件的使用或其他交易而产生、引起或与之相关的任何索赔、损害或其他责任。 26 | 27 | 28 | ------------------------- ENGLISH ------------------------------ 29 | 30 | 31 | Copyright (c) <2023> 32 | 33 | Anti 996 License Version 1.0 (Draft) 34 | 35 | Permission is hereby granted to any individual or legal entity obtaining a copy 36 | of this licensed work (including the source code, documentation and/or related 37 | items, hereinafter collectively referred to as the "licensed work"), free of 38 | charge, to deal with the licensed work for any purpose, including without 39 | limitation, the rights to use, reproduce, modify, prepare derivative works of, 40 | publish, distribute and sublicense the licensed work, subject to the following 41 | conditions: 42 | 43 | 1. The individual or the legal entity must conspicuously display, without 44 | modification, this License on each redistributed or derivative copy of the 45 | Licensed Work. 46 | 47 | 2. The individual or the legal entity must strictly comply with all applicable 48 | laws, regulations, rules and standards of the jurisdiction relating to 49 | labor and employment where the individual is physically located or where 50 | the individual was born or naturalized; or where the legal entity is 51 | registered or is operating (whichever is stricter). In case that the 52 | jurisdiction has no such laws, regulations, rules and standards or its 53 | laws, regulations, rules and standards are unenforceable, the individual 54 | or the legal entity are required to comply with Core International Labor 55 | Standards. 56 | 57 | 3. The individual or the legal entity shall not induce or force its 58 | employee(s), whether full-time or part-time, or its independent 59 | contractor(s), in any methods, to agree in oral or written form, 60 | to directly or indirectly restrict, weaken or relinquish his or 61 | her rights or remedies under such laws, regulations, rules and 62 | standards relating to labor and employment as mentioned above, 63 | no matter whether such written or oral agreement are enforceable 64 | under the laws of the said jurisdiction, nor shall such individual 65 | or the legal entity limit, in any methods, the rights of its employee(s) 66 | or independent contractor(s) from reporting or complaining to the copyright 67 | holder or relevant authorities monitoring the compliance of the license 68 | about its violation(s) of the said license. 69 | 70 | THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 71 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 72 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT 73 | HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 74 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION 75 | WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. -------------------------------------------------------------------------------- /app/layout.tsx.bak: -------------------------------------------------------------------------------- 1 | /* eslint-disable @next/next/no-page-custom-font */ 2 | const FAVICON_FOLDER = "/favicons"; 3 | import "./styles/globals.scss"; 4 | import "./styles/markdown.scss"; 5 | import "./styles/highlight.scss"; 6 | import { getClientConfig } from "./config/client"; 7 | 8 | export const metadata = { 9 | title: "The Ultimate ChatGPT", 10 | description: "Experience the Ultimate ChatGPT Chat Bot: Powered by GPT-3.5 Turbo AI, our cutting-edge virtual assistant revolutionizes your online interactions. Engage in captivating conversations, get instant answers, and access a wealth of knowledge. With unparalleled intelligence and lightning-fast response times, our Chat Bot is your go-to source for expert advice, innovative ideas, and friendly banter. Don't miss out on this incredible opportunity to explore the future of AI. Click now to unlock endless possibilities with our advanced ChatGPT Chat Bot!", 11 | viewport: { 12 | width: "device-width", 13 | initialScale: 1, 14 | maximumScale: 1, 15 | }, 16 | themeColor: [ 17 | { media: "(prefers-color-scheme: light)", color: "#fafafa" }, 18 | { media: "(prefers-color-scheme: dark)", color: "#151515" }, 19 | ], 20 | appleWebApp: { 21 | title: "The Ultimate ChatGPT - Unlock the ultimate features of ChatGPT", 22 | statusBarStyle: "default", 23 | }, 24 | }; 25 | 26 | export default function RootLayout({ 27 | children, 28 | }: { 29 | children: React.ReactNode; 30 | }) { 31 | const { title, description } = metadata; // Add these variables or assign appropriate values 32 | const canonical = "https://chatgpt.kiask.xyz"; // Add the canonical URL or assign an appropriate value 33 | 34 | return ( 35 | 36 | 37 | 38 | 43 | 49 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 |