mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix: Revert scheduler back to zod validation
This commit is contained in:
parent
59b5dfc3e0
commit
06428fac67
@ -41,9 +41,9 @@ export const SCHEDULER_ITEMS = [
|
||||
'heun',
|
||||
'heun_k',
|
||||
'unipc',
|
||||
];
|
||||
] as const;
|
||||
|
||||
export type Scheduler = typeof SCHEDULERS;
|
||||
export type Scheduler = (typeof SCHEDULER_ITEMS)[number];
|
||||
|
||||
// Valid upscaling levels
|
||||
export const UPSCALING_LEVELS: Array<{ label: string; value: string }> = [
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { SCHEDULER_ITEMS } from 'app/constants';
|
||||
import { SCHEDULER_ITEMS, Scheduler } from 'app/constants';
|
||||
import { RootState } from 'app/store/store';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import IAIMantineSelect from 'common/components/IAIMantineSelect';
|
||||
@ -25,12 +25,13 @@ const ParamScheduler = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedSchedulers.length === 0)
|
||||
dispatch(setSelectedSchedulers(SCHEDULER_ITEMS));
|
||||
dispatch(setSelectedSchedulers([...SCHEDULER_ITEMS]));
|
||||
|
||||
const schedulerFound = activeSchedulers.find(
|
||||
(activeSchedulers) => activeSchedulers.label === scheduler
|
||||
);
|
||||
if (!schedulerFound) dispatch(setScheduler(activeSchedulers[0].value));
|
||||
if (!schedulerFound)
|
||||
dispatch(setScheduler(activeSchedulers[0].value as Scheduler));
|
||||
}, [dispatch, selectedSchedulers, scheduler, activeSchedulers]);
|
||||
|
||||
const handleChange = useCallback(
|
||||
@ -38,7 +39,7 @@ const ParamScheduler = () => {
|
||||
if (!v) {
|
||||
return;
|
||||
}
|
||||
dispatch(setScheduler(v));
|
||||
dispatch(setScheduler(v as Scheduler));
|
||||
},
|
||||
[dispatch]
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
import { Scheduler } from 'app/constants';
|
||||
import { configChanged } from 'features/system/store/configSlice';
|
||||
import { clamp, sortBy } from 'lodash-es';
|
||||
import { ImageDTO } from 'services/api';
|
||||
@ -132,7 +133,7 @@ export const generationSlice = createSlice({
|
||||
setWidth: (state, action: PayloadAction<number>) => {
|
||||
state.width = action.payload;
|
||||
},
|
||||
setScheduler: (state, action: PayloadAction<string>) => {
|
||||
setScheduler: (state, action: PayloadAction<Scheduler>) => {
|
||||
state.scheduler = action.payload;
|
||||
},
|
||||
setSeed: (state, action: PayloadAction<number>) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { NUMPY_RAND_MAX } from 'app/constants';
|
||||
import { NUMPY_RAND_MAX, SCHEDULER_ITEMS } from 'app/constants';
|
||||
import { z } from 'zod';
|
||||
|
||||
/**
|
||||
@ -73,7 +73,7 @@ export const isValidCfgScale = (val: unknown): val is CfgScaleParam =>
|
||||
/**
|
||||
* Zod schema for scheduler parameter
|
||||
*/
|
||||
export const zScheduler = z.string();
|
||||
export const zScheduler = z.enum(SCHEDULER_ITEMS);
|
||||
/**
|
||||
* Type alias for scheduler parameter, inferred from its zod schema
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user