feat(ui): add defaultModel to config

This commit is contained in:
psychedelicious 2023-05-30 22:12:21 +10:00 committed by Kent Keirsey
parent 9687fe7bac
commit e1ae7842ff
2 changed files with 10 additions and 1 deletions

View File

@ -351,6 +351,7 @@ export type AppConfig = {
disabledSDFeatures: SDFeature[]; disabledSDFeatures: SDFeature[];
canRestoreDeletedImagesFromBin: boolean; canRestoreDeletedImagesFromBin: boolean;
sd: { sd: {
defaultModel?: string;
iterations: { iterations: {
initial: number; initial: number;
min: number; min: number;

View File

@ -2,11 +2,12 @@ import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit';
import * as InvokeAI from 'app/types/invokeai'; import * as InvokeAI from 'app/types/invokeai';
import promptToString from 'common/util/promptToString'; import promptToString from 'common/util/promptToString';
import { clamp, sample, sortBy } from 'lodash-es'; import { clamp, sortBy } from 'lodash-es';
import { setAllParametersReducer } from './setAllParametersReducer'; import { setAllParametersReducer } from './setAllParametersReducer';
import { receivedModels } from 'services/thunks/model'; import { receivedModels } from 'services/thunks/model';
import { Scheduler } from 'app/constants'; import { Scheduler } from 'app/constants';
import { ImageDTO } from 'services/api'; import { ImageDTO } from 'services/api';
import { configChanged } from 'features/system/store/configSlice';
export interface GenerationState { export interface GenerationState {
cfgScale: number; cfgScale: number;
@ -231,6 +232,13 @@ export const generationSlice = createSlice({
state.model = firstModel.name; state.model = firstModel.name;
} }
}); });
builder.addCase(configChanged, (state, action) => {
const defaultModel = action.payload.sd?.defaultModel;
if (defaultModel && !state.model) {
state.model = defaultModel;
}
});
}, },
}); });