mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-17 14:33:41 +08:00
@@ -59,6 +59,7 @@ import {
|
||||
DEFAULT_TOPIC,
|
||||
ModelType,
|
||||
usePluginStore,
|
||||
DEFAULT_CONFIG,
|
||||
} from "../store";
|
||||
|
||||
import {
|
||||
@@ -114,6 +115,7 @@ import { ExportMessageModal } from "./exporter";
|
||||
import { getClientConfig } from "../config/client";
|
||||
import { useAllModels } from "../utils/hooks";
|
||||
import { MultimodalContent } from "../client/api";
|
||||
import { useCookies } from "react-cookie";
|
||||
|
||||
const localStorage = safeLocalStorage();
|
||||
import { ClientApi } from "../client/api";
|
||||
@@ -1244,6 +1246,99 @@ function _Chat() {
|
||||
return session.mask.hideContext ? [] : session.mask.context.slice();
|
||||
}, [session.mask.context, session.mask.hideContext]);
|
||||
|
||||
const [cookies, setCookie, removeCookie] = useCookies(["sfak"], {
|
||||
doNotParse: true,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const sfakValue = cookies.sfak;
|
||||
|
||||
const model = "Qwen/Qwen2-7B-Instruct";
|
||||
config.update((config) => {
|
||||
const ids = [
|
||||
"stabilityai/stable-diffusion-xl-base-1.0",
|
||||
"TencentARC/PhotoMaker",
|
||||
"InstantX/InstantID",
|
||||
"stabilityai/stable-diffusion-2-1",
|
||||
"stabilityai/sd-turbo",
|
||||
"stabilityai/sdxl-turbo",
|
||||
"ByteDance/SDXL-Lightning",
|
||||
"deepseek-ai/deepseek-llm-67b-chat",
|
||||
"Qwen/Qwen1.5-14B-Chat",
|
||||
"Qwen/Qwen1.5-7B-Chat",
|
||||
"Qwen/Qwen1.5-110B-Chat",
|
||||
"Qwen/Qwen1.5-32B-Chat",
|
||||
"01-ai/Yi-1.5-6B-Chat",
|
||||
"01-ai/Yi-1.5-9B-Chat-16K",
|
||||
"01-ai/Yi-1.5-34B-Chat-16K",
|
||||
"THUDM/chatglm3-6b",
|
||||
"deepseek-ai/DeepSeek-V2-Chat",
|
||||
"THUDM/glm-4-9b-chat",
|
||||
"Qwen/Qwen2-72B-Instruct",
|
||||
"Qwen/Qwen2-7B-Instruct",
|
||||
"Qwen/Qwen2-57B-A14B-Instruct",
|
||||
"stabilityai/stable-diffusion-3-medium",
|
||||
"deepseek-ai/DeepSeek-Coder-V2-Instruct",
|
||||
"Qwen/Qwen2-1.5B-Instruct",
|
||||
"internlm/internlm2_5-7b-chat",
|
||||
"BAAI/bge-large-en-v1.5",
|
||||
"BAAI/bge-large-zh-v1.5",
|
||||
"Pro/Qwen/Qwen2-7B-Instruct",
|
||||
"Pro/Qwen/Qwen2-1.5B-Instruct",
|
||||
"Pro/Qwen/Qwen1.5-7B-Chat",
|
||||
"Pro/THUDM/glm-4-9b-chat",
|
||||
"Pro/THUDM/chatglm3-6b",
|
||||
"Pro/01-ai/Yi-1.5-9B-Chat-16K",
|
||||
"Pro/01-ai/Yi-1.5-6B-Chat",
|
||||
"Pro/internlm/internlm2_5-7b-chat",
|
||||
"black-forest-labs/FLUX.1-schnell",
|
||||
"FunAudioLLM/SenseVoiceSmall",
|
||||
"netease-youdao/bce-embedding-base_v1",
|
||||
"BAAI/bge-m3",
|
||||
"internlm/internlm2_5-20b-chat",
|
||||
"Qwen/Qwen2-Math-72B-Instruct",
|
||||
"netease-youdao/bce-reranker-base_v1",
|
||||
"BAAI/bge-reranker-v2-m3",
|
||||
"deepseek-ai/DeepSeek-V2.5",
|
||||
"Ascend/Qwen/Qwen2-72B-Instruct",
|
||||
];
|
||||
config.customModels = ids
|
||||
.sort()
|
||||
.filter(
|
||||
(id) =>
|
||||
!id.toLowerCase().includes("voice") &&
|
||||
!id.toLowerCase().includes("flux") &&
|
||||
!id.toLowerCase().includes("stability") &&
|
||||
!id.toLowerCase().includes("sdxl") &&
|
||||
!id.toLowerCase().includes("photomaker") &&
|
||||
!id.toLowerCase().includes("instantid") &&
|
||||
!id.toLowerCase().includes("bge") &&
|
||||
!id.toLowerCase().includes("bce"),
|
||||
)
|
||||
.join(","); // Filter out unwanted ids;
|
||||
config.modelConfig.model = model as ModelType;
|
||||
config.modelConfig.providerName = model as ServiceProvider;
|
||||
});
|
||||
if (sfakValue) {
|
||||
chatStore.updateCurrentSession((session) => {
|
||||
if (
|
||||
session.mask.modelConfig.model == DEFAULT_CONFIG.modelConfig.model
|
||||
) {
|
||||
session.mask.modelConfig.model = model as ModelType;
|
||||
session.mask.modelConfig.providerName = model as ServiceProvider;
|
||||
}
|
||||
});
|
||||
accessStore.update((access) => {
|
||||
console.log("update access store with SF API key");
|
||||
access.useCustomConfig = true;
|
||||
access.openaiApiKey = sfakValue;
|
||||
access.openaiUrl =
|
||||
process.env.NEXT_PUBLIC_SF_NEXT_CHAT_SF_API_ENDPOINT!;
|
||||
});
|
||||
removeCookie("sfak");
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (
|
||||
context.length === 0 &&
|
||||
session.messages.at(0)?.content !== BOT_HELLO.content
|
||||
|
||||
@@ -5,6 +5,8 @@ import styles from "./home.module.scss";
|
||||
import { IconButton } from "./button";
|
||||
import SettingsIcon from "../icons/settings.svg";
|
||||
import GithubIcon from "../icons/github.svg";
|
||||
import SiliconFlowIcon from "../icons/sf.svg";
|
||||
import SiliconFlowActiveIcon from "../icons/sf.active.svg";
|
||||
import ChatGptIcon from "../icons/chatgpt.svg";
|
||||
import AddIcon from "../icons/add.svg";
|
||||
import DeleteIcon from "../icons/delete.svg";
|
||||
@@ -14,7 +16,12 @@ import DiscoveryIcon from "../icons/discovery.svg";
|
||||
|
||||
import Locale from "../locales";
|
||||
|
||||
import { useAppConfig, useChatStore } from "../store";
|
||||
import {
|
||||
DEFAULT_CONFIG,
|
||||
useAccessStore,
|
||||
useAppConfig,
|
||||
useChatStore,
|
||||
} from "../store";
|
||||
|
||||
import {
|
||||
DEFAULT_SIDEBAR_WIDTH,
|
||||
@@ -30,6 +37,7 @@ import { Link, useNavigate } from "react-router-dom";
|
||||
import { isIOS, useMobileScreen } from "../utils";
|
||||
import dynamic from "next/dynamic";
|
||||
import { showConfirm, Selector } from "./ui-lib";
|
||||
import { useCookies } from "react-cookie";
|
||||
|
||||
const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, {
|
||||
loading: () => null,
|
||||
@@ -216,6 +224,10 @@ export function SideBar(props: { className?: string }) {
|
||||
const navigate = useNavigate();
|
||||
const config = useAppConfig();
|
||||
const chatStore = useChatStore();
|
||||
const accessStore = useAccessStore();
|
||||
const [cookies, setCookie, removeCookie] = useCookies(["sfak"], {
|
||||
doNotParse: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<SideBarContainer
|
||||
@@ -307,6 +319,53 @@ export function SideBar(props: { className?: string }) {
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
<div className={styles["sidebar-action"]}>
|
||||
<a
|
||||
rel="noopener noreferrer"
|
||||
onClick={() => {
|
||||
if (accessStore.useCustomConfig && accessStore.openaiApiKey) {
|
||||
const confirmLogout = window.confirm(
|
||||
"Are you sure you want to log out?",
|
||||
);
|
||||
if (confirmLogout) {
|
||||
chatStore.updateCurrentSession((session) => {
|
||||
session.mask.modelConfig.model =
|
||||
DEFAULT_CONFIG.modelConfig.model;
|
||||
session.mask.modelConfig.providerName =
|
||||
DEFAULT_CONFIG.modelConfig.providerName;
|
||||
accessStore.update((access) => {
|
||||
removeCookie("sfak");
|
||||
access.openaiApiKey = "";
|
||||
access.useCustomConfig = false;
|
||||
window.location.href = "/";
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
window.location.href = `${
|
||||
process.env
|
||||
.NEXT_PUBLIC_SF_NEXT_CHAT_SF_ACCOUNT_ENDPOINT ||
|
||||
"https://account.siliconflow.cn"
|
||||
}/oauth?client_id=${
|
||||
process.env.NEXT_PUBLIC_SF_NEXT_CHAT_CLIENT_ID
|
||||
}`;
|
||||
}
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
aria={Locale.Export.MessageFromChatGPT}
|
||||
key={accessStore.openaiApiKey + accessStore.openaiUrl}
|
||||
icon={
|
||||
accessStore.useCustomConfig && accessStore.openaiApiKey ? (
|
||||
<SiliconFlowActiveIcon />
|
||||
) : (
|
||||
<SiliconFlowIcon />
|
||||
)
|
||||
}
|
||||
shadow
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
secondaryAction={
|
||||
|
||||
Reference in New Issue
Block a user