mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): add zod schemas for precision parameters
This commit is contained in:
parent
61291ea105
commit
e5a660930c
@ -11,6 +11,7 @@ import {
|
|||||||
MainModelParam,
|
MainModelParam,
|
||||||
NegativePromptParam,
|
NegativePromptParam,
|
||||||
PositivePromptParam,
|
PositivePromptParam,
|
||||||
|
PrecisionParam,
|
||||||
SchedulerParam,
|
SchedulerParam,
|
||||||
SeedParam,
|
SeedParam,
|
||||||
StepsParam,
|
StepsParam,
|
||||||
@ -51,7 +52,7 @@ export interface GenerationState {
|
|||||||
verticalSymmetrySteps: number;
|
verticalSymmetrySteps: number;
|
||||||
model: MainModelField | null;
|
model: MainModelField | null;
|
||||||
vae: VaeModelParam | null;
|
vae: VaeModelParam | null;
|
||||||
vaePrecision: 'fp16' | 'fp32';
|
vaePrecision: PrecisionParam;
|
||||||
seamlessXAxis: boolean;
|
seamlessXAxis: boolean;
|
||||||
seamlessYAxis: boolean;
|
seamlessYAxis: boolean;
|
||||||
clipSkip: number;
|
clipSkip: number;
|
||||||
@ -243,7 +244,7 @@ export const generationSlice = createSlice({
|
|||||||
// null is a valid VAE!
|
// null is a valid VAE!
|
||||||
state.vae = action.payload;
|
state.vae = action.payload;
|
||||||
},
|
},
|
||||||
vaePrecisionChanged: (state, action: PayloadAction<'fp16' | 'fp32'>) => {
|
vaePrecisionChanged: (state, action: PayloadAction<PrecisionParam>) => {
|
||||||
state.vaePrecision = action.payload;
|
state.vaePrecision = action.payload;
|
||||||
},
|
},
|
||||||
setClipSkip: (state, action: PayloadAction<number>) => {
|
setClipSkip: (state, action: PayloadAction<number>) => {
|
||||||
|
@ -296,6 +296,20 @@ export type StrengthParam = z.infer<typeof zStrength>;
|
|||||||
export const isValidStrength = (val: unknown): val is StrengthParam =>
|
export const isValidStrength = (val: unknown): val is StrengthParam =>
|
||||||
zStrength.safeParse(val).success;
|
zStrength.safeParse(val).success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zod schema for a precision parameter
|
||||||
|
*/
|
||||||
|
export const zPrecision = z.enum(['fp16', 'fp32']);
|
||||||
|
/**
|
||||||
|
* Type alias for precision parameter, inferred from its zod schema
|
||||||
|
*/
|
||||||
|
export type PrecisionParam = z.infer<typeof zPrecision>;
|
||||||
|
/**
|
||||||
|
* Validates/type-guards a value as a precision parameter
|
||||||
|
*/
|
||||||
|
export const isValidPrecision = (val: unknown): val is PrecisionParam =>
|
||||||
|
zPrecision.safeParse(val).success;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Zod schema for BaseModelType
|
// * Zod schema for BaseModelType
|
||||||
// */
|
// */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user