mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-02 08:06:38 +08:00
optimize mask
This commit is contained in:
parent
1ac9325f31
commit
e2f78ede72
@ -92,8 +92,8 @@ import {
|
|||||||
UNFINISHED_INPUT,
|
UNFINISHED_INPUT,
|
||||||
} from "../constant";
|
} from "../constant";
|
||||||
import { Avatar } from "./emoji";
|
import { Avatar } from "./emoji";
|
||||||
import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask";
|
// import { ContextPrompts, MaskAvatar, MaskConfig } from "./mask";
|
||||||
import { useMaskStore } from "../store/mask";
|
// import { useMaskStore } from "../store/mask";
|
||||||
import { ChatCommandPrefix, useChatCommand, useCommand } from "../command";
|
import { ChatCommandPrefix, useChatCommand, useCommand } from "../command";
|
||||||
import { prettyObject } from "../utils/format";
|
import { prettyObject } from "../utils/format";
|
||||||
import { ExportMessageModal } from "./exporter";
|
import { ExportMessageModal } from "./exporter";
|
||||||
@ -114,7 +114,7 @@ const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
|
|||||||
export function SessionConfigModel(props: { onClose: () => void }) {
|
export function SessionConfigModel(props: { onClose: () => void }) {
|
||||||
const chatStore = useChatStore();
|
const chatStore = useChatStore();
|
||||||
const session = chatStore.currentSession();
|
const session = chatStore.currentSession();
|
||||||
const maskStore = useMaskStore();
|
// const maskStore = useMaskStore();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -136,40 +136,40 @@ export function SessionConfigModel(props: { onClose: () => void }) {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>,
|
/>,
|
||||||
<IconButton
|
// <IconButton
|
||||||
key="copy"
|
// key="copy"
|
||||||
icon={<CopyIcon />}
|
// icon={<CopyIcon />}
|
||||||
bordered
|
// bordered
|
||||||
text={Locale.Chat.Config.SaveAs}
|
// text={Locale.Chat.Config.SaveAs}
|
||||||
onClick={() => {
|
// onClick={() => {
|
||||||
navigate(Path.Masks);
|
// navigate(Path.Masks);
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
maskStore.create(session.mask);
|
// maskStore.create(session.mask);
|
||||||
}, 500);
|
// }, 500);
|
||||||
}}
|
// }}
|
||||||
/>,
|
// />,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<MaskConfig
|
{/*<MaskConfig*/}
|
||||||
mask={session.mask}
|
{/* mask={session.mask}*/}
|
||||||
updateMask={(updater) => {
|
{/* updateMask={(updater) => {*/}
|
||||||
const mask = { ...session.mask };
|
{/* const mask = { ...session.mask };*/}
|
||||||
updater(mask);
|
{/* updater(mask);*/}
|
||||||
chatStore.updateCurrentSession((session) => (session.mask = mask));
|
{/* chatStore.updateCurrentSession((session) => (session.mask = mask));*/}
|
||||||
}}
|
{/* }}*/}
|
||||||
shouldSyncFromGlobal
|
{/* shouldSyncFromGlobal*/}
|
||||||
extraListItems={
|
{/* extraListItems={*/}
|
||||||
session.mask.modelConfig.sendMemory ? (
|
{/* session.mask.modelConfig.sendMemory ? (*/}
|
||||||
<ListItem
|
{/* <ListItem*/}
|
||||||
className="copyable"
|
{/* className="copyable"*/}
|
||||||
title={`${Locale.Memory.Title} (${session.lastSummarizeIndex} of ${session.messages.length})`}
|
{/* title={`${Locale.Memory.Title} (${session.lastSummarizeIndex} of ${session.messages.length})`}*/}
|
||||||
subTitle={session.memoryPrompt || Locale.Memory.EmptyContent}
|
{/* subTitle={session.memoryPrompt || Locale.Memory.EmptyContent}*/}
|
||||||
></ListItem>
|
{/* ></ListItem>*/}
|
||||||
) : (
|
{/* ) : (*/}
|
||||||
<></>
|
{/* <></>*/}
|
||||||
)
|
{/* )*/}
|
||||||
}
|
{/* }*/}
|
||||||
></MaskConfig>
|
{/*></MaskConfig>*/}
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -680,14 +680,14 @@ export function EditMessageModal(props: { onClose: () => void }) {
|
|||||||
></input>
|
></input>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
<ContextPrompts
|
{/*<ContextPrompts*/}
|
||||||
context={messages}
|
{/* context={messages}*/}
|
||||||
updateContext={(updater) => {
|
{/* updateContext={(updater) => {*/}
|
||||||
const newMessages = messages.slice();
|
{/* const newMessages = messages.slice();*/}
|
||||||
updater(newMessages);
|
{/* updater(newMessages);*/}
|
||||||
setMessages(newMessages);
|
{/* setMessages(newMessages);*/}
|
||||||
}}
|
{/* }}*/}
|
||||||
/>
|
{/*/>*/}
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -867,10 +867,10 @@ function _Chat() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// auto sync mask config from global config
|
// auto sync mask config from global config
|
||||||
if (session.mask.syncGlobalConfig) {
|
// if (session.mask.syncGlobalConfig) {
|
||||||
console.log("[Mask] syncing from global, name = ", session.mask.name);
|
// console.log("[Mask] syncing from global, name = ", session.mask.name);
|
||||||
session.mask.modelConfig = { ...config.modelConfig };
|
// session.mask.modelConfig = { ...config.modelConfig };
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
@ -1411,16 +1411,16 @@ function _Chat() {
|
|||||||
<Avatar avatar={config.avatar} />
|
<Avatar avatar={config.avatar} />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{["system"].includes(message.role) ? (
|
{/*{["system"].includes(message.role) ? (*/}
|
||||||
<Avatar avatar="2699-fe0f" />
|
{/* <Avatar avatar="2699-fe0f" />*/}
|
||||||
) : (
|
{/*) : (*/}
|
||||||
<MaskAvatar
|
{/* <MaskAvatar*/}
|
||||||
avatar={session.mask.avatar}
|
{/* avatar={session.mask.avatar}*/}
|
||||||
model={
|
{/* model={*/}
|
||||||
message.model || session.mask.modelConfig.model
|
{/* message.model || session.mask.modelConfig.model*/}
|
||||||
}
|
{/* }*/}
|
||||||
/>
|
{/* />*/}
|
||||||
)}
|
{/*)}*/}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -159,7 +159,7 @@ function Screen() {
|
|||||||
<Routes>
|
<Routes>
|
||||||
<Route path={Path.Home} element={<Chat />} />
|
<Route path={Path.Home} element={<Chat />} />
|
||||||
<Route path={Path.NewChat} element={<NewChat />} />
|
<Route path={Path.NewChat} element={<NewChat />} />
|
||||||
<Route path={Path.Masks} element={<MaskPage />} />
|
{/*<Route path={Path.Masks} element={<MaskPage />} />*/}
|
||||||
<Route path={Path.Chat} element={<Chat />} />
|
<Route path={Path.Chat} element={<Chat />} />
|
||||||
<Route path={Path.Settings} element={<Settings />} />
|
<Route path={Path.Settings} element={<Settings />} />
|
||||||
<Route path={Path.Reward} element={<Reward />} />
|
<Route path={Path.Reward} element={<Reward />} />
|
||||||
|
@ -148,13 +148,13 @@ export function NewChat() {
|
|||||||
<div className={styles["sub-title"]}>{Locale.NewChat.SubTitle}</div>
|
<div className={styles["sub-title"]}>{Locale.NewChat.SubTitle}</div>
|
||||||
|
|
||||||
<div className={styles["actions"]}>
|
<div className={styles["actions"]}>
|
||||||
<IconButton
|
{/*<IconButton*/}
|
||||||
text={Locale.NewChat.More}
|
{/* text={Locale.NewChat.More}*/}
|
||||||
onClick={() => navigate(Path.Masks)}
|
{/* onClick={() => navigate(Path.Masks)}*/}
|
||||||
icon={<EyeIcon />}
|
{/* icon={<EyeIcon />}*/}
|
||||||
bordered
|
{/* bordered*/}
|
||||||
shadow
|
{/* shadow*/}
|
||||||
/>
|
{/*/>*/}
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
text={Locale.NewChat.Skip}
|
text={Locale.NewChat.Skip}
|
||||||
|
@ -8,7 +8,7 @@ import ChatGptIcon from "../icons/chatgpt.svg";
|
|||||||
import AddIcon from "../icons/add.svg";
|
import AddIcon from "../icons/add.svg";
|
||||||
import CloseIcon from "../icons/close.svg";
|
import CloseIcon from "../icons/close.svg";
|
||||||
import DeleteIcon from "../icons/clear.svg";
|
import DeleteIcon from "../icons/clear.svg";
|
||||||
import MaskIcon from "../icons/mask.svg";
|
// import MaskIcon from "../icons/mask.svg";
|
||||||
import CoffeeIcon from "../icons/coffee.svg";
|
import CoffeeIcon from "../icons/coffee.svg";
|
||||||
import DragIcon from "../icons/drag.svg";
|
import DragIcon from "../icons/drag.svg";
|
||||||
|
|
||||||
@ -171,19 +171,19 @@ export function SideBar(props: { className?: string }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles["sidebar-header-bar"]}>
|
<div className={styles["sidebar-header-bar"]}>
|
||||||
<IconButton
|
{/*<IconButton*/}
|
||||||
icon={<MaskIcon />}
|
{/* icon={<MaskIcon />}*/}
|
||||||
text={shouldNarrow ? undefined : Locale.Mask.Name}
|
{/* text={shouldNarrow ? undefined : Locale.Mask.Name}*/}
|
||||||
className={styles["sidebar-bar-button"]}
|
{/* className={styles["sidebar-bar-button"]}*/}
|
||||||
onClick={() => {
|
{/* onClick={() => {*/}
|
||||||
if (config.dontShowMaskSplashScreen !== true) {
|
{/* if (config.dontShowMaskSplashScreen !== true) {*/}
|
||||||
navigate(Path.NewChat, { state: { fromHome: true } });
|
{/* navigate(Path.NewChat, { state: { fromHome: true } });*/}
|
||||||
} else {
|
{/* } else {*/}
|
||||||
navigate(Path.Masks, { state: { fromHome: true } });
|
{/* navigate(Path.Masks, { state: { fromHome: true } });*/}
|
||||||
}
|
{/* }*/}
|
||||||
}}
|
{/* }}*/}
|
||||||
shadow
|
{/* shadow*/}
|
||||||
/>
|
{/*/>*/}
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<CoffeeIcon />}
|
icon={<CoffeeIcon />}
|
||||||
text={shouldNarrow ? undefined : "赏杯咖啡️"}
|
text={shouldNarrow ? undefined : "赏杯咖啡️"}
|
||||||
|
@ -4,7 +4,6 @@ import {get_encoding} from "tiktoken";
|
|||||||
|
|
||||||
export function getTokenLength(input: string): number {
|
export function getTokenLength(input: string): number {
|
||||||
const encoding = get_encoding("cl100k_base");
|
const encoding = get_encoding("cl100k_base");
|
||||||
// console.log('tokens: ', input, encoding.countTokens())
|
|
||||||
return encoding.encode(input).length;
|
return encoding.encode(input).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user