diff --git a/app/config/server.ts b/app/config/server.ts
index 6eab9ebec..2df806fed 100644
--- a/app/config/server.ts
+++ b/app/config/server.ts
@@ -12,7 +12,8 @@ declare global {
DISABLE_GPT4?: string; // allow user to use gpt-4 or not
BUILD_MODE?: "standalone" | "export";
BUILD_APP?: string; // is building desktop app
- HIDE_BALANCE_QUERY?: string; // allow user to query balance or not
+ ENABLE_BALANCE_QUERY?: string; // allow user to query balance or not
+ DISABLE_FAST_LINK?: string; // disallow parse settings from url or not
}
}
}
@@ -47,6 +48,7 @@ export const getServerSideConfig = () => {
isVercel: !!process.env.VERCEL,
hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
disableGPT4: !!process.env.DISABLE_GPT4,
- hideBalanceQuery: !!process.env.HIDE_BALANCE_QUERY,
+ hideBalanceQuery: !process.env.ENABLE_BALANCE_QUERY,
+ disableFastLink: !!process.env.DISABLE_FAST_LINK,
};
};
diff --git a/app/constant.ts b/app/constant.ts
index 3bec33b62..ca4f3f2e4 100644
--- a/app/constant.ts
+++ b/app/constant.ts
@@ -10,6 +10,7 @@ export const RUNTIME_CONFIG_DOM = "danger-runtime-config";
export const DEFAULT_CORS_HOST = "https://ab.nextweb.fun";
export const DEFAULT_API_HOST = `${DEFAULT_CORS_HOST}/api/proxy`;
+export const OPENAI_BASE_URL = "https://api.openai.com";
export enum Path {
Home = "/",
@@ -72,13 +73,20 @@ export const OpenaiPath = {
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
export const DEFAULT_SYSTEM_TEMPLATE = `
You are ChatGPT, a large language model trained by OpenAI.
-Knowledge cutoff: {{knowledgeCutoff}}
+Knowledge cutoff: {{cutoff}}
Current model: {{model}}
Current time: {{time}}
`;
export const SUMMARIZE_MODEL = "gpt-3.5-turbo";
+export const KnowledgeCutOffDate: Record = {
+ default: "2021-09",
+ "gpt-3.5-turbo-1106": "2023-04",
+ "gpt-4-1106-preview": "2023-04",
+ "gpt-4-vision-preview": "2023-04",
+};
+
export const DEFAULT_MODELS = [
{
name: "gpt-4",
diff --git a/app/store/access.ts b/app/store/access.ts
index 9eaa81e5e..3d889f6e7 100644
--- a/app/store/access.ts
+++ b/app/store/access.ts
@@ -16,6 +16,7 @@ const DEFAULT_ACCESS_STATE = {
hideUserApiKey: false,
hideBalanceQuery: false,
disableGPT4: false,
+ disableFastLink: false,
openaiUrl: DEFAULT_OPENAI_URL,
};
@@ -29,15 +30,6 @@ export const useAccessStore = createPersistStore(
return get().needCode;
},
- updateCode(code: string) {
- set(() => ({ accessCode: code?.trim() }));
- },
- updateToken(token: string) {
- set(() => ({ token: token?.trim() }));
- },
- updateOpenAiUrl(url: string) {
- set(() => ({ openaiUrl: url?.trim() }));
- },
isAuthorized() {
this.fetch();
diff --git a/app/store/chat.ts b/app/store/chat.ts
index 678924ac3..ea48948fc 100644
--- a/app/store/chat.ts
+++ b/app/store/chat.ts
@@ -7,6 +7,7 @@ import { createEmptyMask, Mask } from "./mask";
import {
DEFAULT_INPUT_TEMPLATE,
DEFAULT_SYSTEM_TEMPLATE,
+ KnowledgeCutOffDate,
StoreKey,
SUMMARIZE_MODEL,
} from "../constant";
@@ -124,7 +125,11 @@ function countMessages(msgs: ChatMessage[]) {
}
function fillTemplateWith(input: string, modelConfig: ModelConfig) {
+ let cutoff =
+ KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default;
+
const vars = {
+ cutoff,
model: modelConfig.model,
time: new Date().toLocaleString(),
lang: getLang(),
@@ -492,26 +497,22 @@ export const useChatStore = createPersistStore(
// system prompts, to get close to OpenAI Web ChatGPT
const shouldInjectSystemPrompts = modelConfig.enableInjectSystemPrompts;
- let systemPrompts = shouldInjectSystemPrompts ? [] : [];
-
+ const systemPrompts = shouldInjectSystemPrompts
+ ? [
+ createMessage({
+ role: "system",
+ content: fillTemplateWith("", {
+ ...modelConfig,
+ template: DEFAULT_SYSTEM_TEMPLATE,
+ }),
+ }),
+ ]
+ : [];
if (shouldInjectSystemPrompts) {
- const model = modelConfig.model;
- let systemTemplate = DEFAULT_SYSTEM_TEMPLATE;
-
- if (model === "gpt-4-1106-preview" || model === "gpt-4-vision-preview") {
- systemTemplate = systemTemplate.replace("{{knowledgeCutoff}}", "2023-04");
- } else {
- systemTemplate = systemTemplate.replace("{{knowledgeCutoff}}", "2021-09");
- }
-
- const systemPrompt = createMessage({
- role: "system",
- content: fillTemplateWith("", {
- ...modelConfig,
- template: systemTemplate,
- }),
- });
- console.log("[Global System Prompt] ", systemPrompt.content);
+ console.log(
+ "[Global System Prompt] ",
+ systemPrompts.at(0)?.content ?? "empty",
+ );
}
// long term memory
diff --git a/app/store/config.ts b/app/store/config.ts
index 5c852d9da..31df71d56 100644
--- a/app/store/config.ts
+++ b/app/store/config.ts
@@ -140,7 +140,9 @@ export const useAppConfig = createPersistStore(
.customModels.split(",")
.filter((v) => !!v && v.length > 0)
.map((m) => ({ name: m, available: true }));
- return get().models.concat(customModels);
+ const allModels = get().models.concat(customModels);
+ allModels.sort((a, b) => (a.name < b.name ? -1 : 1));
+ return allModels;
},
}),
{
diff --git a/docker-compose.yml b/docker-compose.yml
index c4312cfe3..57ca12e03 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
-version: '3.9'
+version: "3.9"
services:
- chatgpt-next-web:
+ chatgpt-next-web:
profiles: ["no-proxy"]
container_name: chatgpt-next-web
image: yidadaa/chatgpt-next-web
@@ -13,8 +13,11 @@ services:
- OPENAI_ORG_ID=$OPENAI_ORG_ID
- HIDE_USER_API_KEY=$HIDE_USER_API_KEY
- DISABLE_GPT4=$DISABLE_GPT4
+ - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY
+ - DISABLE_FAST_LINK=$DISABLE_FAST_LINK
+ - OPENAI_SB=$OPENAI_SB
- chatgpt-next-web-proxy:
+ chatgpt-next-web-proxy:
profiles: ["proxy"]
container_name: chatgpt-next-web-proxy
image: yidadaa/chatgpt-next-web
@@ -28,3 +31,6 @@ services:
- OPENAI_ORG_ID=$OPENAI_ORG_ID
- HIDE_USER_API_KEY=$HIDE_USER_API_KEY
- DISABLE_GPT4=$DISABLE_GPT4
+ - ENABLE_BALANCE_QUERY=$ENABLE_BALANCE_QUERY
+ - DISABLE_FAST_LINK=$DISABLE_FAST_LINK
+ - OPENAI_SB=$OPENAI_SB
diff --git a/docs/cloudflare-pages-cn.md b/docs/cloudflare-pages-cn.md
index 2f9a99f2d..137bb9dc3 100644
--- a/docs/cloudflare-pages-cn.md
+++ b/docs/cloudflare-pages-cn.md
@@ -1,6 +1,7 @@
# Cloudflare Pages 部署指南
## 如何新建项目
+
在 Github 上 fork 本项目,然后登录到 dash.cloudflare.com 并进入 Pages。
1. 点击 "Create a project"。
@@ -12,7 +13,7 @@
7. 在 "Build Settings" 中,选择 "Framework presets" 选项并选择 "Next.js"。
8. 由于 node:buffer 的 bug,暂时不要使用默认的 "Build command"。请使用以下命令:
```
- npx https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/4930842298/npm-package-next-on-pages-230 --experimental-minify
+ npx @cloudflare/next-on-pages@1.5.0
```
9. 对于 "Build output directory",使用默认值并且不要修改。
10. 不要修改 "Root Directory"。
@@ -30,10 +31,12 @@
- `OPENAI_ORG_ID= 可选填,指定 OpenAI 中的组织 ID`
- `HIDE_USER_API_KEY=1 可选,不让用户自行填入 API Key`
- `DISABLE_GPT4=1 可选,不让用户使用 GPT-4`
-
+ - `ENABLE_BALANCE_QUERY=1 可选,启用余额查询功能`
+ - `DISABLE_FAST_LINK=1 可选,禁用从链接解析预制设置`
+
12. 点击 "Save and Deploy"。
13. 点击 "Cancel deployment",因为需要填写 Compatibility flags。
14. 前往 "Build settings"、"Functions",找到 "Compatibility flags"。
15. 在 "Configure Production compatibility flag" 和 "Configure Preview compatibility flag" 中填写 "nodejs_compat"。
16. 前往 "Deployments",点击 "Retry deployment"。
-17. Enjoy.
\ No newline at end of file
+17. Enjoy.
diff --git a/docs/cloudflare-pages-en.md b/docs/cloudflare-pages-en.md
index 2279ff232..c5d550438 100644
--- a/docs/cloudflare-pages-en.md
+++ b/docs/cloudflare-pages-en.md
@@ -1,6 +1,7 @@
# Cloudflare Pages Deployment Guide
## How to create a new project
+
Fork this project on GitHub, then log in to dash.cloudflare.com and go to Pages.
1. Click "Create a project".
@@ -11,12 +12,13 @@ Fork this project on GitHub, then log in to dash.cloudflare.com and go to Pages.
6. For "Project name" and "Production branch", use the default values or change them as needed.
7. In "Build Settings", choose the "Framework presets" option and select "Next.js".
8. Do not use the default "Build command" due to a node:buffer bug. Instead, use the following command:
- ```
- npx @cloudflare/next-on-pages --experimental-minify
- ```
+ ```
+ npx @cloudflare/next-on-pages --experimental-minify
+ ```
9. For "Build output directory", use the default value and do not modify it.
10. Do not modify "Root Directory".
11. For "Environment variables", click ">" and then "Add variable". Fill in the following information:
+
- `NODE_VERSION=20.1`
- `NEXT_TELEMETRY_DISABLE=1`
- `OPENAI_API_KEY=your_own_API_key`
@@ -29,7 +31,10 @@ Fork this project on GitHub, then log in to dash.cloudflare.com and go to Pages.
- `OPENAI_ORG_ID= Optional, specify the organization ID in OpenAI`
- `HIDE_USER_API_KEY=1 Optional, do not allow users to enter their own API key`
- `DISABLE_GPT4=1 Optional, do not allow users to use GPT-4`
-
+ - `ENABLE_BALANCE_QUERY=1 Optional, allow users to query balance`
+ - `DISABLE_FAST_LINK=1 Optional, disable parse settings from url`
+ - `OPENAI_SB=1 Optional,use the third-party OpenAI-SB API`
+
12. Click "Save and Deploy".
13. Click "Cancel deployment" because you need to fill in Compatibility flags.
14. Go to "Build settings", "Functions", and find "Compatibility flags".
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index b337f732f..0f91501c6 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -9,7 +9,7 @@
},
"package": {
"productName": "ChatGPT Next Web",
- "version": "2.9.9"
+ "version": "2.9.10"
},
"tauri": {
"allowlist": {