mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 16:16:39 +08:00
commit
4a8a151966
6
.github/workflows/dockerToHub-dev.yml
vendored
6
.github/workflows/dockerToHub-dev.yml
vendored
@ -16,13 +16,13 @@ jobs:
|
|||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: 'dev'
|
ref: 'dev'
|
||||||
clean: true
|
clean: false
|
||||||
github-server-url: 'https://gh.siji.ci'
|
github-server-url: 'https://gh.siji.ci'
|
||||||
- name: build and deploy to Docker Hub
|
- name: build and deploy to Docker Hub
|
||||||
run: |
|
run: |
|
||||||
echo ${{ secrets.ALY_DOCKER_PASSWORD }} | docker login registry.cn-hangzhou.aliyuncs.com -u ${{ secrets.ALY_DOCKER_USERNAME }} --password-stdin
|
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 "${{ secrets.DOCKER_ENV }}" > .env
|
||||||
echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" > .env
|
echo "COMPOSE_PROJECT_NAME=test-chatgpt-web" >> .env
|
||||||
bash ./start.sh
|
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
|
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
|
cd /data/test/ChatGPT-Next-Web
|
||||||
echo "${{ secrets.DOCKER_ENV }}" > .env
|
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
|
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
|
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
|
sed -i 's|23000:|23001:|g' docker-compose.yml
|
||||||
|
2
.github/workflows/dockerToHub.yml
vendored
2
.github/workflows/dockerToHub.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
clean: true
|
clean: false
|
||||||
github-server-url: 'https://gh.siji.ci'
|
github-server-url: 'https://gh.siji.ci'
|
||||||
- name: build and deploy to Docker Hub
|
- name: build and deploy to Docker Hub
|
||||||
run: |
|
run: |
|
||||||
|
@ -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
|
// 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
|
// Old CDN broken, so I had to switch to this one
|
||||||
// Author: https://github.com/H0llyW00dzZ
|
// 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: {
|
export function AvatarPicker(props: {
|
||||||
|
@ -268,7 +268,7 @@ function CheckButton() {
|
|||||||
const syncStore = useSyncStore();
|
const syncStore = useSyncStore();
|
||||||
|
|
||||||
const couldCheck = useMemo(() => {
|
const couldCheck = useMemo(() => {
|
||||||
return syncStore.coundSync();
|
return syncStore.cloudSync();
|
||||||
}, [syncStore]);
|
}, [syncStore]);
|
||||||
|
|
||||||
const [checkState, setCheckState] = useState<
|
const [checkState, setCheckState] = useState<
|
||||||
@ -472,7 +472,7 @@ function SyncItems() {
|
|||||||
const promptStore = usePromptStore();
|
const promptStore = usePromptStore();
|
||||||
const maskStore = useMaskStore();
|
const maskStore = useMaskStore();
|
||||||
const couldSync = useMemo(() => {
|
const couldSync = useMemo(() => {
|
||||||
return syncStore.coundSync();
|
return syncStore.cloudSync();
|
||||||
}, [syncStore]);
|
}, [syncStore]);
|
||||||
|
|
||||||
const [showSyncConfigModal, setShowSyncConfigModal] = useState(false);
|
const [showSyncConfigModal, setShowSyncConfigModal] = useState(false);
|
||||||
|
@ -99,7 +99,7 @@ export const Google = {
|
|||||||
|
|
||||||
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
|
export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang
|
||||||
export const DEFAULT_SYSTEM_TEMPLATE = `
|
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}}
|
Knowledge cutoff: {{cutoff}}
|
||||||
Current model: {{model}}
|
Current model: {{model}}
|
||||||
Current time: {{time}}
|
Current time: {{time}}
|
||||||
@ -115,7 +115,9 @@ export const KnowledgeCutOffDate: Record<string, string> = {
|
|||||||
"gpt-4-1106-preview": "2023-04",
|
"gpt-4-1106-preview": "2023-04",
|
||||||
"gpt-4-0125-preview": "2023-04",
|
"gpt-4-0125-preview": "2023-04",
|
||||||
"gpt-4-vision-preview": "2023-04",
|
"gpt-4-vision-preview": "2023-04",
|
||||||
"gemini-pro": "2021-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 = [
|
export const DEFAULT_MODELS = [
|
||||||
|
@ -6,6 +6,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config";
|
|||||||
import { createEmptyMask, Mask } from "./mask";
|
import { createEmptyMask, Mask } from "./mask";
|
||||||
import {
|
import {
|
||||||
DEFAULT_INPUT_TEMPLATE,
|
DEFAULT_INPUT_TEMPLATE,
|
||||||
|
DEFAULT_MODELS,
|
||||||
DEFAULT_SYSTEM_TEMPLATE,
|
DEFAULT_SYSTEM_TEMPLATE,
|
||||||
KnowledgeCutOffDate,
|
KnowledgeCutOffDate,
|
||||||
ModelProvider,
|
ModelProvider,
|
||||||
@ -99,10 +100,20 @@ function countMessages(msgs: ChatMessage[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fillTemplateWith(input: string, modelConfig: ModelConfig) {
|
function fillTemplateWith(input: string, modelConfig: ModelConfig) {
|
||||||
let cutoff =
|
const cutoff =
|
||||||
KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default;
|
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 = {
|
const vars = {
|
||||||
|
ServiceProvider: serviceProvider,
|
||||||
cutoff,
|
cutoff,
|
||||||
model: modelConfig.model,
|
model: modelConfig.model,
|
||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
@ -119,7 +130,8 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object.entries(vars).forEach(([name, value]) => {
|
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;
|
return output;
|
||||||
|
@ -48,7 +48,7 @@ const DEFAULT_SYNC_STATE = {
|
|||||||
export const useSyncStore = createPersistStore(
|
export const useSyncStore = createPersistStore(
|
||||||
DEFAULT_SYNC_STATE,
|
DEFAULT_SYNC_STATE,
|
||||||
(set, get) => ({
|
(set, get) => ({
|
||||||
coundSync() {
|
cloudSync() {
|
||||||
const config = get()[get().provider];
|
const config = get()[get().provider];
|
||||||
return Object.values(config).every((c) => c.toString().length > 0);
|
return Object.values(config).every((c) => c.toString().length > 0);
|
||||||
},
|
},
|
||||||
|
@ -70,7 +70,7 @@ export const authOptions: NextAuthOptions = {
|
|||||||
error: "/login", // Error code passed in query string as ?error=
|
error: "/login", // Error code passed in query string as ?error=
|
||||||
},
|
},
|
||||||
adapter: PrismaAdapter(prisma),
|
adapter: PrismaAdapter(prisma),
|
||||||
session: { strategy: "jwt", maxAge: 7 * 24 * 60 * 60 },
|
session: { strategy: "jwt", maxAge: 3 * 24 * 60 * 60 },
|
||||||
cookies: {
|
cookies: {
|
||||||
sessionToken: {
|
sessionToken: {
|
||||||
name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`,
|
name: `${SECURE_COOKIES ? "__Secure-" : ""}next-auth.session-token`,
|
||||||
@ -109,7 +109,7 @@ export const authOptions: NextAuthOptions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getSession() {
|
export function getSession() {
|
||||||
// console.log('in........',)
|
console.log('in........',)
|
||||||
return getServerSession(authOptions) as Promise<{
|
return getServerSession(authOptions) as Promise<{
|
||||||
user: {
|
user: {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
"@tailwindcss/forms": "^0.5.7",
|
"@tailwindcss/forms": "^0.5.7",
|
||||||
"@tailwindcss/typography": "^0.5.10",
|
"@tailwindcss/typography": "^0.5.10",
|
||||||
"@tauri-apps/cli": "^1.5.8",
|
"@tauri-apps/cli": "^1.5.8",
|
||||||
|
"@types/cookie": "^0.6.0",
|
||||||
"@types/node": "^20.11.10",
|
"@types/node": "^20.11.10",
|
||||||
"@types/react": "^18.2.48",
|
"@types/react": "^18.2.48",
|
||||||
"@types/react-dom": "^18.2.7",
|
"@types/react-dom": "^18.2.7",
|
||||||
|
Loading…
Reference in New Issue
Block a user