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

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

@@ -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;