From 2797022f644135c711d7d049eb92c4f08e1de5e2 Mon Sep 17 00:00:00 2001 From: sijinhui Date: Wed, 31 Jan 2024 00:03:15 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dockerToHub-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dockerToHub-dev.yml b/.github/workflows/dockerToHub-dev.yml index 4ad5e20fc..378d89911 100644 --- a/.github/workflows/dockerToHub-dev.yml +++ b/.github/workflows/dockerToHub-dev.yml @@ -22,7 +22,7 @@ jobs: run: | echo ${{ secrets.ALY_DOCKER_PASSWORD }} | docker login registry.cn-hangzhou.aliyuncs.com -u ${{ secrets.ALY_DOCKER_USERNAME }} --password-stdin echo "${{ secrets.DOCKER_ENV }}" > .env - echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" > .env + echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" >> .env bash ./start.sh # 替换测试镜像 sed -i 's@image: registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web@image: registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:test@g' docker-compose.yml @@ -63,7 +63,7 @@ jobs: cd /data/test/ChatGPT-Next-Web echo "${{ secrets.DOCKER_ENV }}" > .env # 测试分支, - echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" > .env + echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" >> .env sed -i 's@image: registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web@image: registry.cn-hangzhou.aliyuncs.com/si-private/chatgpt-next-web:test@g' docker-compose.yml echo ${{ secrets.ALY_DOCKER_PASSWORD }} | docker login registry.cn-hangzhou.aliyuncs.com -u ${{ secrets.ALY_DOCKER_USERNAME }} --password-stdin sed -i 's|23000:|23001:|g' docker-compose.yml From c9f21e3f0f666a73b3a8d4668567f32bce02b45c Mon Sep 17 00:00:00 2001 From: sijinhui Date: Fri, 2 Feb 2024 17:23:39 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dockerToHub-dev.yml | 4 ++-- .github/workflows/dockerToHub.yml | 2 +- lib/auth.ts | 4 ++-- middleware.ts | 2 +- package.json | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dockerToHub-dev.yml b/.github/workflows/dockerToHub-dev.yml index 378d89911..43f1aa219 100644 --- a/.github/workflows/dockerToHub-dev.yml +++ b/.github/workflows/dockerToHub-dev.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@v3 with: ref: 'dev' - clean: true + clean: false github-server-url: 'https://gh.siji.ci' - name: build and deploy to Docker Hub run: | @@ -70,4 +70,4 @@ jobs: docker-compose pull && docker-compose up -d yes | docker image prune rm -rf /www/server/nginx/proxy_cache_dir/* - rm -rf /www/server/nginx/proxy_temp_dir/* \ No newline at end of file + rm -rf /www/server/nginx/proxy_temp_dir/* diff --git a/.github/workflows/dockerToHub.yml b/.github/workflows/dockerToHub.yml index 8dcf632c2..6d90ee977 100644 --- a/.github/workflows/dockerToHub.yml +++ b/.github/workflows/dockerToHub.yml @@ -23,7 +23,7 @@ jobs: - name: Check out the repo uses: actions/checkout@v3 with: - clean: true + clean: false github-server-url: 'https://gh.siji.ci' - name: build and deploy to Docker Hub run: | diff --git a/lib/auth.ts b/lib/auth.ts index 48ebb2e37..642d0ca08 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -70,7 +70,7 @@ export const authOptions: NextAuthOptions = { error: "/login", // Error code passed in query string as ?error= }, adapter: PrismaAdapter(prisma), - session: { strategy: "jwt", maxAge: 7 * 24 * 60 * 60 }, + session: { strategy: "jwt", maxAge: 3 * 24 * 60 * 60 }, cookies: { sessionToken: { name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`, @@ -109,7 +109,7 @@ export const authOptions: NextAuthOptions = { }; export function getSession() { - // console.log('in........',) + console.log('in........',) return getServerSession(authOptions) as Promise<{ user: { id: string; diff --git a/middleware.ts b/middleware.ts index 9a231f903..baf4bbe96 100644 --- a/middleware.ts +++ b/middleware.ts @@ -1,7 +1,7 @@ import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; import { getToken } from "next-auth/jwt"; -import {DENY_LIST, isName} from "@/lib/auth_list"; +import { DENY_LIST, isName } from "@/lib/auth_list"; export default async function middleware(req: NextRequest) { const url = req.nextUrl; diff --git a/package.json b/package.json index 91762af7d..03b3eaee0 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@tauri-apps/cli": "^1.5.8", + "@types/cookie": "^0.6.0", "@types/node": "^20.11.10", "@types/react": "^18.2.48", "@types/react-dom": "^18.2.7", From 1a97bd55c7364c7652063d0bfd6d91de8398b2c4 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Sat, 3 Feb 2024 00:19:25 +0700 Subject: [PATCH 3/7] Feat [OpenAI] [Models] gpt-3.5-turbo-0125 (#3971) - [+] feat(constant.ts): add new model 'gpt-3.5-turbo-0125' to DEFAULT_MODELS array --- app/constant.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index 8f2518140..fc49e3dbc 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -213,6 +213,15 @@ export const DEFAULT_MODELS = [ providerType: "openai", }, }, + { + name: "gpt-3.5-turbo-0125", + available: true, + provider: { + id: "openai", + providerName: "OpenAI", + providerType: "openai", + }, + }, { name: "gpt-3.5-turbo-0301", available: true, From b25a0545f5b348bbef81f4fe8d41695c3fc10d94 Mon Sep 17 00:00:00 2001 From: Duplicate4 Date: Sat, 3 Feb 2024 01:20:10 +0800 Subject: [PATCH 4/7] fix: typo (#3871) Signed-off-by: Dup4 --- app/components/settings.tsx | 4 ++-- app/store/sync.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 409af64d3..35d3b0215 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -268,7 +268,7 @@ function CheckButton() { const syncStore = useSyncStore(); const couldCheck = useMemo(() => { - return syncStore.coundSync(); + return syncStore.cloudSync(); }, [syncStore]); const [checkState, setCheckState] = useState< @@ -472,7 +472,7 @@ function SyncItems() { const promptStore = usePromptStore(); const maskStore = useMaskStore(); const couldSync = useMemo(() => { - return syncStore.coundSync(); + return syncStore.cloudSync(); }, [syncStore]); const [showSyncConfigModal, setShowSyncConfigModal] = useState(false); diff --git a/app/store/sync.ts b/app/store/sync.ts index b74f6895f..5ff1cc6e5 100644 --- a/app/store/sync.ts +++ b/app/store/sync.ts @@ -48,7 +48,7 @@ const DEFAULT_SYNC_STATE = { export const useSyncStore = createPersistStore( DEFAULT_SYNC_STATE, (set, get) => ({ - coundSync() { + cloudSync() { const config = get()[get().provider]; return Object.values(config).every((c) => c.toString().length > 0); }, @@ -60,8 +60,10 @@ export const useSyncStore = createPersistStore( export() { const state = getLocalAppState(); const datePart = isApp - ? `${new Date().toLocaleDateString().replace(/\//g, '_')} ${new Date().toLocaleTimeString().replace(/:/g, '_')}` - : new Date().toLocaleString(); + ? `${new Date().toLocaleDateString().replace(/\//g, "_")} ${new Date() + .toLocaleTimeString() + .replace(/:/g, "_")}` + : new Date().toLocaleString(); const fileName = `Backup-${datePart}.json`; downloadAs(JSON.stringify(state), fileName); From 4511aa4d21eda4e6e0b5130d1e3222bb30734672 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Sat, 3 Feb 2024 00:24:37 +0700 Subject: [PATCH 5/7] Fix [UI/UX] [Emoji] Update CDN (#3966) - [+] fix(emoji.tsx): update CDN url from 'cdn.jsdelivr.net' to 'fastly.jsdelivr.net' --- app/components/emoji.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index a2a50320d..b24349307 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -13,7 +13,7 @@ export function getEmojiUrl(unified: string, style: EmojiStyle) { // Whoever owns this Content Delivery Network (CDN), I am using your CDN to serve emojis // Old CDN broken, so I had to switch to this one // Author: https://github.com/H0llyW00dzZ - return `https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`; + return `https://fastly.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`; } export function AvatarPicker(props: { From a5517a1a51de81f9527f2e734d8412f6f4f8962c Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Mon, 5 Feb 2024 12:35:51 +0700 Subject: [PATCH 6/7] Improve Default System Template (#3996) * Feat [UI/UX] [Constant] [DEFAULT System Template] replace hardcoded - [+] feat(constant.ts): replace hardcoded OpenAI with dynamic ServiceProvider variable in DEFAULT_SYSTEM_TEMPLATE * Improve [UI/UX] [Chat] "fillTemplateWith" - [+] feat(chat.ts): add DEFAULT_MODELS to modelConfig - [+] fix(chat.ts): replace replaceAll with regex in output string replacement - [+] refactor(chat.ts): use const instead of let for cutoff variable --- app/constant.ts | 2 +- app/store/chat.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/constant.ts b/app/constant.ts index fc49e3dbc..68d0e1395 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -95,7 +95,7 @@ export const Google = { 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. +You are ChatGPT, a large language model trained by {{ServiceProvider}}. Knowledge cutoff: {{cutoff}} Current model: {{model}} Current time: {{time}} diff --git a/app/store/chat.ts b/app/store/chat.ts index dff6b7bf1..a3dc94089 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -6,6 +6,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config"; import { createEmptyMask, Mask } from "./mask"; import { DEFAULT_INPUT_TEMPLATE, + DEFAULT_MODELS, DEFAULT_SYSTEM_TEMPLATE, KnowledgeCutOffDate, ModelProvider, @@ -91,10 +92,17 @@ function countMessages(msgs: ChatMessage[]) { } function fillTemplateWith(input: string, modelConfig: ModelConfig) { - let cutoff = - KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default; + const cutoff = KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default; + // Find the model in the DEFAULT_MODELS array that matches the modelConfig.model + const modelInfo = DEFAULT_MODELS.find(m => m.name === modelConfig.model); + if (!modelInfo) { + throw new Error(`Model ${modelConfig.model} not found in DEFAULT_MODELS array.`); + } + // Directly use the providerName from the modelInfo + const serviceProvider = modelInfo.provider.providerName; const vars = { + ServiceProvider: serviceProvider, cutoff, model: modelConfig.model, time: new Date().toLocaleString(), @@ -111,7 +119,8 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) { } Object.entries(vars).forEach(([name, value]) => { - output = output.replaceAll(`{{${name}}}`, value); + const regex = new RegExp(`{{${name}}}`, 'g'); + output = output.replace(regex, value.toString()); // Ensure value is a string }); return output; From bb26c03141473c9437827ceb559d43041b149604 Mon Sep 17 00:00:00 2001 From: H0llyW00dzZ Date: Mon, 5 Feb 2024 13:44:46 +0700 Subject: [PATCH 7/7] Feat [UI/UX] [Constants] [Models] gemini-pro KnowledgeCutOffDate (#3997) - [+] feat(constant.ts): add 'gemini-pro' to KnowledgeCutOffDate constant --- app/constant.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/constant.ts b/app/constant.ts index 68d0e1395..f0e895ed9 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -111,6 +111,9 @@ export const KnowledgeCutOffDate: Record = { "gpt-4-1106-preview": "2023-04", "gpt-4-0125-preview": "2023-04", "gpt-4-vision-preview": "2023-04", + // After improvements, + // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously. + "gemini-pro": "2023-12", }; export const DEFAULT_MODELS = [