From bfdb47a7edd55d34655fb9da025f9b304e8df2ca Mon Sep 17 00:00:00 2001 From: Hao Jia Date: Thu, 16 May 2024 15:03:14 +0800 Subject: [PATCH] ChatGPT Logo --- app/components/auth.tsx | 54 +- app/components/chat.tsx | 177 ++++--- app/components/settings.tsx | 947 +++++++++++++++++------------------- app/components/sidebar.tsx | 65 +-- app/layout.tsx | 2 +- app/locales/cn.ts | 2 +- app/locales/index.ts | 30 +- app/store/config.ts | 4 +- 8 files changed, 608 insertions(+), 673 deletions(-) diff --git a/app/components/auth.tsx b/app/components/auth.tsx index 57118349b..5c8b4fc00 100644 --- a/app/components/auth.tsx +++ b/app/components/auth.tsx @@ -50,33 +50,33 @@ export function AuthPage() { ); }} /> - {!accessStore.hideUserApiKey ? ( - <> -
{Locale.Auth.SubTips}
- { - accessStore.update( - (access) => (access.openaiApiKey = e.currentTarget.value), - ); - }} - /> - { - accessStore.update( - (access) => (access.googleApiKey = e.currentTarget.value), - ); - }} - /> - - ) : null} + {/*{!accessStore.hideUserApiKey ? (*/} + {/* <>*/} + {/*
{Locale.Auth.SubTips}
*/} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) => (access.openaiApiKey = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) => (access.googleApiKey = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* */} + {/*) : null}*/}
- {couldStop && ( - } - /> - )} - {!props.hitBottom && ( - } - /> - )} - {props.hitBottom && ( - } - /> - )} + {/*{couldStop && (*/} + {/* }*/} + {/* />*/} + {/*)}*/} + {/*{!props.hitBottom && (*/} + {/* }*/} + {/* />*/} + {/*)}*/} + {/*{props.hitBottom && (*/} + {/* }*/} + {/* />*/} + {/*)}*/} - {showUploadImage && ( - : } - /> - )} - - {theme === Theme.Auto ? ( - - ) : theme === Theme.Light ? ( - - ) : theme === Theme.Dark ? ( - - ) : null} - - } - /> + {/*{showUploadImage && (*/} + {/* : }*/} + {/* />*/} + {/*)}*/} + {/**/} + {/* {theme === Theme.Auto ? (*/} + {/* */} + {/* ) : theme === Theme.Light ? (*/} + {/* */} + {/* ) : theme === Theme.Dark ? (*/} + {/* */} + {/* ) : null}*/} + {/* */} + {/* }*/} + {/*/>*/} - } - /> + {/*}*/} + {/*/>*/} - { - navigate(Path.Masks); - }} - text={Locale.Chat.InputActions.Masks} - icon={} - /> + {/* {*/} + {/* navigate(Path.Masks);*/} + {/* }}*/} + {/* text={Locale.Chat.InputActions.Masks}*/} + {/* icon={}*/} + {/*/>*/} - } - onClick={() => { - chatStore.updateCurrentSession((session) => { - if (session.clearContextIndex === session.messages.length) { - session.clearContextIndex = undefined; - } else { - session.clearContextIndex = session.messages.length; - session.memoryPrompt = ""; // will clear memory - } - }); - }} - /> + {/*}*/} + {/* onClick={() => {*/} + {/* chatStore.updateCurrentSession((session) => {*/} + {/* if (session.clearContextIndex === session.messages.length) {*/} + {/* session.clearContextIndex = undefined;*/} + {/* } else {*/} + {/* session.clearContextIndex = session.messages.length;*/} + {/* session.memoryPrompt = ""; // will clear memory*/} + {/* }*/} + {/* });*/} + {/* }}*/} + {/*/>*/} setShowModelSelector(true)} @@ -1088,7 +1088,6 @@ function _Chat() { if (payload.url) { accessStore.update((access) => (access.openaiUrl = payload.url!)); } - accessStore.update((access) => (access.useCustomConfig = true)); }); } } catch { @@ -1233,25 +1232,25 @@ function _Chat() {
- {!isMobileScreen && ( -
- } - bordered - onClick={() => setIsEditingMessage(true)} - /> -
- )} -
- } - bordered - title={Locale.Chat.Actions.Export} - onClick={() => { - setShowExport(true); - }} - /> -
+ {/*{!isMobileScreen && (*/} + {/*
*/} + {/* }*/} + {/* bordered*/} + {/* onClick={() => setIsEditingMessage(true)}*/} + {/* />*/} + {/*
*/} + {/*)}*/} + {/*
*/} + {/* }*/} + {/* bordered*/} + {/* title={Locale.Chat.Actions.Export}*/} + {/* onClick={() => {*/} + {/* setShowExport(true);*/} + {/* }}*/} + {/* />*/} + {/*
*/} {showMaxIcon && (
- - {checkingUpdate ? ( - - ) : hasNewVersion ? ( - - {Locale.Settings.Update.GoToUpdate} - - ) : ( - } - text={Locale.Settings.Update.CheckUpdate} - onClick={() => checkUpdate(true)} - /> - )} - + {/**/} + {/* {checkingUpdate ? (*/} + {/* */} + {/* ) : hasNewVersion ? (*/} + {/* */} + {/* {Locale.Settings.Update.GoToUpdate}*/} + {/* */} + {/* ) : (*/} + {/* }*/} + {/* text={Locale.Settings.Update.CheckUpdate}*/} + {/* onClick={() => checkUpdate(true)}*/} + {/* />*/} + {/* )}*/} + {/**/} - - - + {/**/} + {/* {*/} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.submitKey = e.target.value as any as SubmitKey),*/} + {/* );*/} + {/* }}*/} + {/* >*/} + {/* {Object.values(SubmitKey).map((v) => (*/} + {/* */} + {/* ))}*/} + {/* */} + {/**/} - - - + {/**/} + {/* {*/} + {/* updateConfig(*/} + {/* (config) => (config.theme = e.target.value as any as Theme),*/} + {/* );*/} + {/* }}*/} + {/* >*/} + {/* {Object.values(Theme).map((v) => (*/} + {/* */} + {/* ))}*/} + {/* */} + {/**/} - - - + {/**/} + {/* {*/} + {/* changeLang(e.target.value as any);*/} + {/* }}*/} + {/* >*/} + {/* {AllLangs.map((lang) => (*/} + {/* */} + {/* ))}*/} + {/* */} + {/**/} - - - updateConfig( - (config) => - (config.enableAutoGenerateTitle = e.currentTarget.checked), - ) - } - > - + {/**/} + {/* */} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.enableAutoGenerateTitle = e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/**/} - - - updateConfig( - (config) => - (config.sendPreviewBubble = e.currentTarget.checked), - ) - } - > - + {/**/} + {/* */} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.sendPreviewBubble = e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/**/} - + {/**/} - - - - updateConfig( - (config) => - (config.dontShowMaskSplashScreen = - !e.currentTarget.checked), - ) - } - > - + {/**/} + {/* */} + {/* */} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.dontShowMaskSplashScreen =*/} + {/* !e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} - - - updateConfig( - (config) => - (config.hideBuiltinMasks = e.currentTarget.checked), - ) - } - > - - + {/* */} + {/* */} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.hideBuiltinMasks = e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/**/} - - - - updateConfig( - (config) => - (config.disablePromptHint = e.currentTarget.checked), - ) - } - > - + {/**/} + {/* */} + {/* */} + {/* updateConfig(*/} + {/* (config) =>*/} + {/* (config.disablePromptHint = e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} - - } - text={Locale.Settings.Prompt.Edit} - onClick={() => setShowPromptModal(true)} - /> - - + {/* */} + {/* }*/} + {/* text={Locale.Settings.Prompt.Edit}*/} + {/* onClick={() => setShowPromptModal(true)}*/} + {/* />*/} + {/* */} + {/**/} - - {showAccessCode && ( - - { - accessStore.update( - (access) => (access.accessCode = e.currentTarget.value), - ); - }} - /> - - )} + {/**/} + {/* {showAccessCode && (*/} + {/* */} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) => (access.accessCode = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* )}*/} - {!accessStore.hideUserApiKey && ( - <> - { - // Conditionally render the following ListItem based on clientConfig.isApp - !clientConfig?.isApp && ( // only show if isApp is false - - - accessStore.update( - (access) => - (access.useCustomConfig = e.currentTarget.checked), - ) - } - > - - ) - } - {accessStore.useCustomConfig && ( - <> - - - + {/* {!accessStore.hideUserApiKey && (*/} + {/* <>*/} + {/* {*/} + {/* // Conditionally render the following ListItem based on clientConfig.isApp*/} + {/* !clientConfig?.isApp && ( // only show if isApp is false*/} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.useCustomConfig = e.currentTarget.checked),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* )*/} + {/* }*/} + {/* {accessStore.useCustomConfig && (*/} + {/* <>*/} + {/* */} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.provider = e.target*/} + {/* .value as ServiceProvider),*/} + {/* );*/} + {/* }}*/} + {/* >*/} + {/* {Object.entries(ServiceProvider).map(([k, v]) => (*/} + {/* */} + {/* ))}*/} + {/* */} + {/* */} - {accessStore.provider === ServiceProvider.OpenAI && ( - <> - - - accessStore.update( - (access) => - (access.openaiUrl = e.currentTarget.value), - ) - } - > - - - { - accessStore.update( - (access) => - (access.openaiApiKey = e.currentTarget.value), - ); - }} - /> - - - )} - {accessStore.provider === ServiceProvider.Azure && ( - <> - - - accessStore.update( - (access) => - (access.azureUrl = e.currentTarget.value), - ) - } - > - - - { - accessStore.update( - (access) => - (access.azureApiKey = e.currentTarget.value), - ); - }} - /> - - - - accessStore.update( - (access) => - (access.azureApiVersion = - e.currentTarget.value), - ) - } - > - - - )} - {accessStore.provider === ServiceProvider.Google && ( - <> - - - accessStore.update( - (access) => - (access.googleUrl = e.currentTarget.value), - ) - } - > - - - { - accessStore.update( - (access) => - (access.googleApiKey = e.currentTarget.value), - ); - }} - /> - - - - accessStore.update( - (access) => - (access.googleApiVersion = - e.currentTarget.value), - ) - } - > - - - )} - {accessStore.provider === ServiceProvider.Anthropic && ( - <> - - - accessStore.update( - (access) => - (access.anthropicUrl = e.currentTarget.value), - ) - } - > - - - { - accessStore.update( - (access) => - (access.anthropicApiKey = - e.currentTarget.value), - ); - }} - /> - - - - accessStore.update( - (access) => - (access.anthropicApiVersion = - e.currentTarget.value), - ) - } - > - - - )} - - )} - - )} + {/* {accessStore.provider === "OpenAI" ? (*/} + {/* <>*/} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.openaiUrl = e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* */} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.openaiApiKey = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* ) : accessStore.provider === "Azure" ? (*/} + {/* <>*/} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.azureUrl = e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* */} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.azureApiKey = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.azureApiVersion =*/} + {/* e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* */} + {/* ) : accessStore.provider === "Google" ? (*/} + {/* <>*/} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.googleUrl = e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* */} + {/* {*/} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.googleApiKey = e.currentTarget.value),*/} + {/* );*/} + {/* }}*/} + {/* />*/} + {/* */} + {/* */} + {/* */} + {/* accessStore.update(*/} + {/* (access) =>*/} + {/* (access.googleApiVersion =*/} + {/* e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/* */} + {/* ) : null}*/} + {/* */} + {/* )}*/} + {/* */} + {/* )}*/} - {!shouldHideBalanceQuery && !clientConfig?.isApp ? ( - - {!showUsage || loadingUsage ? ( -
- ) : ( - } - text={Locale.Settings.Usage.Check} - onClick={() => checkUsage(true)} - /> - )} - - ) : null} + {/* {!shouldHideBalanceQuery && !clientConfig?.isApp ? (*/} + {/* */} + {/* {!showUsage || loadingUsage ? (*/} + {/*
*/} + {/* ) : (*/} + {/* }*/} + {/* text={Locale.Settings.Usage.Check}*/} + {/* onClick={() => checkUsage(true)}*/} + {/* />*/} + {/* )}*/} + {/* */} + {/* ) : null}*/} - - - config.update( - (config) => (config.customModels = e.currentTarget.value), - ) - } - > - - + {/* */} + {/* */} + {/* config.update(*/} + {/* (config) => (config.customModels = e.currentTarget.value),*/} + {/* )*/} + {/* }*/} + {/* >*/} + {/* */} + {/**/} - - { - const modelConfig = { ...config.modelConfig }; - updater(modelConfig); - config.update((config) => (config.modelConfig = modelConfig)); - }} - /> - + {/**/} + {/* {*/} + {/* const modelConfig = { ...config.modelConfig };*/} + {/* updater(modelConfig);*/} + {/* config.update((config) => (config.modelConfig = modelConfig));*/} + {/* }}*/} + {/* />*/} + {/**/} {shouldShowPromptModal && ( setShowPromptModal(false)} /> diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 69b2e71f8..d62d2aa91 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -6,6 +6,7 @@ import { IconButton } from "./button"; import SettingsIcon from "../icons/settings.svg"; import GithubIcon from "../icons/github.svg"; import ChatGptIcon from "../icons/chatgpt.svg"; +import DiitIcon from "../icons/diit.svg"; import AddIcon from "../icons/add.svg"; import CloseIcon from "../icons/close.svg"; import DeleteIcon from "../icons/delete.svg"; @@ -155,38 +156,38 @@ export function SideBar(props: { className?: string }) { >
- NextChat -
-
- Build your own AI assistant. + DiitChat
+ {/*
*/} + {/* Build your own AI assistant.*/} + {/*
*/}
- +
-
- } - text={shouldNarrow ? undefined : Locale.Mask.Name} - className={styles["sidebar-bar-button"]} - onClick={() => { - if (config.dontShowMaskSplashScreen !== true) { - navigate(Path.NewChat, { state: { fromHome: true } }); - } else { - navigate(Path.Masks, { state: { fromHome: true } }); - } - }} - shadow - /> - } - text={shouldNarrow ? undefined : Locale.Plugin.Name} - className={styles["sidebar-bar-button"]} - onClick={() => showToast(Locale.WIP)} - shadow - /> -
+ {/*
*/} + {/* }*/} + {/* text={shouldNarrow ? undefined : Locale.Mask.Name}*/} + {/* className={styles["sidebar-bar-button"]}*/} + {/* onClick={() => {*/} + {/* if (config.dontShowMaskSplashScreen !== true) {*/} + {/* navigate(Path.NewChat, { state: { fromHome: true } });*/} + {/* } else {*/} + {/* navigate(Path.Masks, { state: { fromHome: true } });*/} + {/* }*/} + {/* }}*/} + {/* shadow*/} + {/* />*/} + {/* }*/} + {/* text={shouldNarrow ? undefined : Locale.Plugin.Name}*/} + {/* className={styles["sidebar-bar-button"]}*/} + {/* onClick={() => showToast(Locale.WIP)}*/} + {/* shadow*/} + {/* />*/} + {/*
*/}
} shadow />
- + {/**/}
= { }; const LANG_KEY = "lang"; -const DEFAULT_LANG = "en"; +const DEFAULT_LANG = "cn"; -const fallbackLang = en; +const fallbackLang = cn; const targetLang = ALL_LANGS[getLang()] as LocaleType; // if target lang missing some fields, it will use fallback lang string @@ -104,19 +104,19 @@ function getLanguage() { } export function getLang(): Lang { - const savedLang = getItem(LANG_KEY); - - if (AllLangs.includes((savedLang ?? "") as Lang)) { - return savedLang as Lang; - } - - const lang = getLanguage(); - - for (const option of AllLangs) { - if (lang.includes(option)) { - return option; - } - } + // const savedLang = getItem(LANG_KEY); + // + // if (AllLangs.includes((savedLang ?? "") as Lang)) { + // return savedLang as Lang; + // } + // + // const lang = getLanguage(); + // + // for (const option of AllLangs) { + // if (lang.includes(option)) { + // return option; + // } + // } return DEFAULT_LANG; } diff --git a/app/store/config.ts b/app/store/config.ts index 6f2f558a0..7f853544b 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -33,13 +33,13 @@ export const DEFAULT_CONFIG = { fontSize: 14, theme: Theme.Auto as Theme, tightBorder: !!getClientConfig()?.isApp, - sendPreviewBubble: true, + sendPreviewBubble: false, enableAutoGenerateTitle: true, sidebarWidth: DEFAULT_SIDEBAR_WIDTH, disablePromptHint: false, - dontShowMaskSplashScreen: false, // dont show splash screen when create chat + dontShowMaskSplashScreen: true, // dont show splash screen when create chat hideBuiltinMasks: false, // dont add builtin masks customModels: "",