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

Function installModel

apps/node/src/modules/model-manager/install-model.ts:17–41  ·  view source on GitHub ↗
(dispatch: TaskEventDispatcher, model: MarketModel)

Source from the content-addressed store, hash-verified

15 * @param model
16 */
17export async function installModel(dispatch: TaskEventDispatcher, model: MarketModel): Promise<boolean> {
18 const modelPath = getModelPath(model.type, model.save_path, model.filename);
19 if (fs.existsSync(modelPath)) {
20 dispatch({
21 message: `${modelPath} already installed`
22 });
23 return true;
24 }
25 try {
26 console.log("download info", model);
27 await downloadUrlPro(dispatch, model.download_url, modelPath, model.sha256)
28 dispatch({
29 type: ModelDownloadChannelEvents.onModelDownloadSuccess,
30 })
31 modelManager.updateModelMeta([model]);
32 return true;
33 } catch(err: any) {
34 console.log(err);
35 dispatch({
36 type: ModelDownloadChannelEvents.onModelDownloadFailed,
37 error: err.message,
38 })
39 return false;
40 }
41}
42
43/**
44 * Download a default model for user

Callers 1

ApiRouteInstallModelFunction · 0.90

Calls 3

getModelPathFunction · 0.90
downloadUrlProFunction · 0.90
logMethod · 0.80

Tested by

no test coverage detected