diff --git a/invokeai/frontend/web/src/app/store/store.ts b/invokeai/frontend/web/src/app/store/store.ts index dd80e1e378..d71a147913 100644 --- a/invokeai/frontend/web/src/app/store/store.ts +++ b/invokeai/frontend/web/src/app/store/store.ts @@ -15,6 +15,7 @@ import loraReducer from 'features/lora/store/loraSlice'; import nodesReducer from 'features/nodes/store/nodesSlice'; import generationReducer from 'features/parameters/store/generationSlice'; import postprocessingReducer from 'features/parameters/store/postprocessingSlice'; +import sdxlReducer from 'features/sdxl/store/sdxlSlice'; import configReducer from 'features/system/store/configSlice'; import systemReducer from 'features/system/store/systemSlice'; import modelmanagerReducer from 'features/ui/components/tabs/ModelManager/store/modelManagerSlice'; @@ -47,6 +48,7 @@ const allReducers = { imageDeletion: imageDeletionReducer, lora: loraReducer, modelmanager: modelmanagerReducer, + sdxl: sdxlReducer, [api.reducerPath]: api.reducer, }; @@ -58,6 +60,7 @@ const rememberedKeys: (keyof typeof allReducers)[] = [ 'canvas', 'gallery', 'generation', + 'sdxl', 'nodes', 'postprocessing', 'system', diff --git a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts index cea5fb9987..bae683d7fb 100644 --- a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts +++ b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts @@ -42,6 +42,42 @@ export const isValidNegativePrompt = ( val: unknown ): val is NegativePromptParam => zNegativePrompt.safeParse(val).success; +/** + * Zod schema for SDXL positive style prompt parameter + */ +export const zPositiveStylePromptSDXL = z.string(); +/** + * Type alias for SDXL positive style prompt parameter, inferred from its zod schema + */ +export type PositiveStylePromptSDXLParam = z.infer< + typeof zPositiveStylePromptSDXL +>; +/** + * Validates/type-guards a value as a SDXL positive style prompt parameter + */ +export const isValidSDXLPositiveStylePrompt = ( + val: unknown +): val is PositiveStylePromptSDXLParam => + zPositiveStylePromptSDXL.safeParse(val).success; + +/** + * Zod schema for SDXL negative style prompt parameter + */ +export const zNegativeStylePromptSDXL = z.string(); +/** + * Type alias for SDXL negative style prompt parameter, inferred from its zod schema + */ +export type NegativeStylePromptSDXLParam = z.infer< + typeof zNegativeStylePromptSDXL +>; +/** + * Validates/type-guards a value as a SDXL negative style prompt parameter + */ +export const isValidSDXLNegativeStylePrompt = ( + val: unknown +): val is NegativeStylePromptSDXLParam => + zNegativeStylePromptSDXL.safeParse(val).success; + /** * Zod schema for steps parameter */ diff --git a/invokeai/frontend/web/src/features/sdxl/store/sdxlSlice.ts b/invokeai/frontend/web/src/features/sdxl/store/sdxlSlice.ts new file mode 100644 index 0000000000..95a0ac0de8 --- /dev/null +++ b/invokeai/frontend/web/src/features/sdxl/store/sdxlSlice.ts @@ -0,0 +1,41 @@ +import { PayloadAction, createSlice } from '@reduxjs/toolkit'; +import { + NegativeStylePromptSDXLParam, + PositiveStylePromptSDXLParam, +} from 'features/parameters/types/parameterSchemas'; + +type SDXLInitialState = { + shouldUseSDXLRefiner: boolean; + positiveStylePrompt: PositiveStylePromptSDXLParam; + negativeStylePrompt: NegativeStylePromptSDXLParam; +}; + +const sdxlInitialState: SDXLInitialState = { + shouldUseSDXLRefiner: false, + positiveStylePrompt: '', + negativeStylePrompt: '', +}; + +const sdxlSlice = createSlice({ + name: 'sdxl', + initialState: sdxlInitialState, + reducers: { + setPositiveStylePromptSDXL: (state, action: PayloadAction) => { + state.positiveStylePrompt = action.payload; + }, + setNegativeStylePromptSDXL: (state, action: PayloadAction) => { + state.negativeStylePrompt = action.payload; + }, + setShouldUseSDXLRefiner: (state, action: PayloadAction) => { + state.shouldUseSDXLRefiner = action.payload; + }, + }, +}); + +export const { + setPositiveStylePromptSDXL, + setNegativeStylePromptSDXL, + setShouldUseSDXLRefiner, +} = sdxlSlice.actions; + +export default sdxlSlice.reducer;