MCPcopy Create free account
hub / github.com/6174/comflowyspace / getModelDir

Function getModelDir

apps/node/src/modules/model-manager/model-paths.ts:117–156  ·  view source on GitHub ↗
(type: ModelType, save_path: string = "default")

Source from the content-addressed store, hash-verified

115}
116
117export function getModelDir(type: ModelType, save_path: string = "default"): string {
118 const { BASE_PATH, MODELS_DIR, FOLDER_NAMES_AND_PATHS } = getFolderNamesAndPaths();
119 if (save_path !== 'default') {
120 if (save_path.includes('..') || save_path.startsWith('/')) {
121 console.warn(`[WARN] '${save_path}' is not allowed path. So it will be saved into 'models/etc'.`);
122 return 'etc';
123 } else {
124 if (save_path.startsWith('custom_nodes')) {
125 return `${BASE_PATH}/${save_path}`;
126 } else {
127 return `${MODELS_DIR}/${save_path}`;
128 }
129 }
130 } else {
131 const model_type = type;
132 switch (model_type) {
133 case 'checkpoints':
134 case 'unclip':
135 return FOLDER_NAMES_AND_PATHS.checkpoints[0][0];
136 case 'VAE':
137 return FOLDER_NAMES_AND_PATHS.vae[0][0];
138 case 'lora':
139 return FOLDER_NAMES_AND_PATHS.loras[0][0];
140 case 'T2I-Adapter':
141 case 'T2I-Style':
142 case 'controlnet':
143 return FOLDER_NAMES_AND_PATHS.controlnet[0][0];
144 case 'clip_vision':
145 return FOLDER_NAMES_AND_PATHS.clip_vision[0][0];
146 case 'gligen':
147 return FOLDER_NAMES_AND_PATHS.gligen[0][0];
148 case 'upscale':
149 return FOLDER_NAMES_AND_PATHS.upscale_models[0][0];
150 case 'embeddings':
151 return FOLDER_NAMES_AND_PATHS.embeddings[0][0];
152 default:
153 return 'etc';
154 }
155 }
156}
157
158export function getModelPath(type: string, save_path: string, file_name: string): string {
159 const modelDir = getModelDir(type as any, save_path);

Callers 2

ModelManagerClass · 0.90
getModelPathFunction · 0.85

Calls 1

getFolderNamesAndPathsFunction · 0.85

Tested by

no test coverage detected