优化新建窗口可以继承模型配置

This commit is contained in:
sijinhui 2024-05-17 13:15:22 +08:00
parent 1b1ad3201a
commit 941f40afb5
3 changed files with 17 additions and 10 deletions

View File

@ -130,6 +130,7 @@ function useDragSideBar() {
export function SideBar(props: { className?: string }) {
const chatStore = useChatStore();
const currentModel = chatStore.currentSession().mask.modelConfig.model;
// drag side bar
const { onDragStart, shouldNarrow } = useDragSideBar();
const navigate = useNavigate();
@ -248,7 +249,7 @@ export function SideBar(props: { className?: string }) {
text={shouldNarrow ? undefined : Locale.Home.NewChat}
onClick={() => {
if (config.dontShowMaskSplashScreen) {
chatStore.newSession();
chatStore.newSession(undefined, currentModel);
navigate(Path.Chat);
} else {
navigate(Path.NewChat);

View File

@ -221,9 +221,14 @@ export const useChatStore = createPersistStore(
});
},
newSession(mask?: Mask) {
newSession(mask?: Mask, currentModel?: Mask["modelConfig"]["model"]) {
const session = createEmptySession();
const config = useAppConfig.getState();
console.log("------", session, "2222", config);
// 继承当前会话的模型
if (currentModel) {
session.mask.modelConfig.model = currentModel;
}
if (mask) {
const config = useAppConfig.getState();
const globalModelConfig = config.modelConfig;

View File

@ -52,7 +52,7 @@ export const DEFAULT_CONFIG = {
dontUseModel: DISABLE_MODELS,
modelConfig: {
model: "gpt-35-turbo-0125" as ModelType,
model: "gpt-3.5-turbo-0125" as ModelType,
temperature: 0.8,
top_p: 1,
max_tokens: 2000,
@ -138,7 +138,7 @@ export const useAppConfig = createPersistStore(
}),
{
name: StoreKey.Config,
version: 3.9,
version: 3.91,
migrate(persistedState, version) {
const state = persistedState as ChatConfig;
@ -174,11 +174,12 @@ export const useAppConfig = createPersistStore(
// return { ...DEFAULT_CONFIG };
// }
if (version < 3.9) {
state.modelConfig.template =
state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE
? state.modelConfig.template
: config?.template ?? DEFAULT_INPUT_TEMPLATE;
if (version < 3.91) {
state.modelConfig = DEFAULT_CONFIG.modelConfig;
// state.modelConfig.template =
// state.modelConfig.template !== DEFAULT_INPUT_TEMPLATE
// ? state.modelConfig.template
// : config?.template ?? DEFAULT_INPUT_TEMPLATE;
}
return state as any;