CLIP Skip zod schema created

This commit is contained in:
Attila Cseh
2025-08-12 13:18:45 +02:00
committed by psychedelicious
parent 8329533848
commit 6e32c7993c

View File

@@ -4,6 +4,8 @@ import { buildZodTypeGuard } from 'common/util/zodUtils';
import { zModelIdentifierField, zSchedulerField } from 'features/nodes/types/common';
import { z } from 'zod';
import { CLIP_SKIP_MAP } from './constants';
/**
* Schemas, types and type guards for parameters.
*
@@ -193,3 +195,21 @@ export type ParameterCanvasCoherenceMode = z.infer<typeof zParameterCanvasCohere
export const [zLoRAWeight, isParameterLoRAWeight] = buildParameter(z.number());
export type ParameterLoRAWeight = z.infer<typeof zLoRAWeight>;
// #endregion
// #region Max. CLIP
export const [zParameterMaxCLIP, isParameterMaxCLIP] = buildParameter(
z.union([
z.discriminatedUnion('model', [
z.object({ model: z.literal('sd-1'), maxClip: z.number().min(0).max(CLIP_SKIP_MAP['sd-1'].maxClip) }),
z.object({ model: z.literal('sd-2'), maxClip: z.number().min(0).max(CLIP_SKIP_MAP['sd-2'].maxClip) }),
z.object({ model: z.literal('sdxl'), maxClip: z.number().min(0).max(CLIP_SKIP_MAP['sdxl'].maxClip) }),
z.object({
model: z.literal('sdxl-refiner'),
maxClip: z.number().min(0).max(CLIP_SKIP_MAP['sdxl-refiner'].maxClip),
}),
]),
z.object({ model: z.string(), maxClip: z.number().min(0).max(0) }),
])
);
export type ParameterMaxCLIP = z.infer<typeof zParameterMaxCLIP>;
// #endregion