diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 1c5809831..ac6e16944 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -472,9 +472,11 @@ export function ChatActions(props: { // switch model const currentModel = chatStore.currentSession().mask.modelConfig.model; + // 这里获取的不准确,看起来没有什么地方可以更新这个providerName const currentProviderName = chatStore.currentSession().mask.modelConfig?.providerName || ServiceProvider.OpenAI; + console.log("222222222", currentModel, currentProviderName); const allModels = useAllModels(); const models = useMemo(() => { const filteredModels = allModels.filter((m) => m.available); @@ -609,7 +611,7 @@ export function ChatActions(props: { setShowModelSelector(true)} - text={currentModel} + text={currentModelName} icon={} /> @@ -627,7 +629,7 @@ export function ChatActions(props: { {/*/>*/} {showModelSelector && ( - ({ title: `${m.displayName}${ diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 509943bb9..aa527bc4f 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -23,6 +23,7 @@ import { NARROW_SIDEBAR_WIDTH, Path, REPO_URL, + ServiceProvider, } from "../constant"; import { Link, useNavigate } from "react-router-dom"; @@ -131,6 +132,10 @@ export function SideBar(props: { className?: string }) { const chatStore = useChatStore(); const currentModel = chatStore.currentSession().mask.modelConfig.model; + const currentProviderName = + chatStore.currentSession().mask.modelConfig?.providerName || + ServiceProvider.OpenAI; + // drag side bar const { onDragStart, shouldNarrow } = useDragSideBar(); const navigate = useNavigate(); @@ -249,7 +254,11 @@ export function SideBar(props: { className?: string }) { text={shouldNarrow ? undefined : Locale.Home.NewChat} onClick={() => { if (config.dontShowMaskSplashScreen) { - chatStore.newSession(undefined, currentModel); + chatStore.newSession( + undefined, + currentModel, + currentProviderName, + ); navigate(Path.Chat); } else { navigate(Path.NewChat); diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx index 8c55f5620..19b93a7c9 100644 --- a/app/components/ui-lib.tsx +++ b/app/components/ui-lib.tsx @@ -514,7 +514,7 @@ export function ModalSelector(props: { onClose?: () => void; multiple?: boolean; }) { - // console.log("-----", props); + console.log("-----", props); const getCheckCardAvatar = (value: string): React.ReactNode => { if (value.startsWith("gpt")) { diff --git a/app/store/chat.ts b/app/store/chat.ts index 837f434e1..7d19d7e8d 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -224,14 +224,22 @@ export const useChatStore = createPersistStore( }); }, - newSession(mask?: Mask, currentModel?: Mask["modelConfig"]["model"]) { + newSession( + mask?: Mask, + currentModel?: Mask["modelConfig"]["model"], + currentProviderName?: ServiceProvider, + ) { const session = createEmptySession(); const config = useAppConfig.getState(); // console.log("------", session, "2222", config); - // 继承当前会话的模型 + // 继承当前会话的模型, + // 新增继承模型提供者 if (currentModel) { session.mask.modelConfig.model = currentModel; } + if (currentProviderName) { + session.mask.modelConfig.providerName = currentProviderName; + } if (mask) { const config = useAppConfig.getState(); const globalModelConfig = config.modelConfig; diff --git a/app/store/config.ts b/app/store/config.ts index 568fef76a..dbb845e5e 100644 --- a/app/store/config.ts +++ b/app/store/config.ts @@ -140,7 +140,7 @@ export const useAppConfig = createPersistStore( }), { name: StoreKey.Config, - version: 3.96, + version: 3.97, migrate(persistedState, version) { const state = persistedState as ChatConfig; @@ -176,7 +176,7 @@ export const useAppConfig = createPersistStore( // return { ...DEFAULT_CONFIG }; // } - if (version < 3.96) { + if (version < 3.97) { state.modelConfig = DEFAULT_CONFIG.modelConfig; // state.modelConfig.template = // state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE