mirror of
https://github.com/lmstudio-ai/lms.git
synced 2025-09-19 21:40:02 +08:00
bootstrap
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@lmstudio/lms-common": "^0.5.1",
|
||||
"@lmstudio/lms-lmstudio": "^0.0.3",
|
||||
"@lmstudio/sdk": "^0.0.4",
|
||||
"boxen": "^5.1.2",
|
||||
"chalk": "^4.1.2",
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { run, subcommands } from "cmd-ts";
|
||||
import { bootstrap } from "./subcommands/bootstrap";
|
||||
import { create } from "./subcommands/create";
|
||||
import { ls, ps } from "./subcommands/list";
|
||||
import { load } from "./subcommands/load";
|
||||
@ -24,6 +25,7 @@ const cli = subcommands({
|
||||
unload,
|
||||
create,
|
||||
version,
|
||||
bootstrap,
|
||||
},
|
||||
});
|
||||
|
||||
|
11
src/subcommands/bootstrap.ts
Normal file
11
src/subcommands/bootstrap.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { installCli } from "@lmstudio/lms-lmstudio/dist/installCli";
|
||||
import { command } from "cmd-ts";
|
||||
|
||||
export const bootstrap = command({
|
||||
name: "bootstrap",
|
||||
description: "Bootstrap the CLI",
|
||||
args: {},
|
||||
handler: async () => {
|
||||
await installCli({ skipConfirmation: true });
|
||||
},
|
||||
});
|
@ -140,14 +140,14 @@ function printDownloadedModelsTable(
|
||||
if (models.length === 1) {
|
||||
const model = models[0];
|
||||
return {
|
||||
path: group,
|
||||
sizeBytes: formatSizeBytes1000(model.sizeBytes),
|
||||
arch: architecture(model.architecture),
|
||||
path: chalk.cyanBright(group),
|
||||
sizeBytes: chalk.cyanBright(formatSizeBytes1000(model.sizeBytes)),
|
||||
arch: chalk.cyanBright(architecture(model.architecture)),
|
||||
loaded: loadedCheck(model.loadedIdentifiers.length),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
path: group,
|
||||
path: chalk.cyanBright(group),
|
||||
arch: chalk.gray(`(...${models.length} options)`),
|
||||
loaded: loadedCheck(
|
||||
models.reduce((acc, model) => acc + model.loadedIdentifiers.length, 0),
|
||||
@ -166,14 +166,14 @@ function printDownloadedModelsTable(
|
||||
align: "left",
|
||||
},
|
||||
path: {
|
||||
headingTransform: () => chalk.greenBright(title),
|
||||
headingTransform: () => chalk(title),
|
||||
},
|
||||
sizeBytes: {
|
||||
headingTransform: () => chalk.greenBright("SIZE"),
|
||||
headingTransform: () => chalk("SIZE"),
|
||||
align: "right",
|
||||
},
|
||||
arch: {
|
||||
headingTransform: () => chalk.greenBright("ARCHITECTURE"),
|
||||
headingTransform: () => chalk("ARCHITECTURE"),
|
||||
align: "center",
|
||||
},
|
||||
},
|
||||
|
@ -168,30 +168,7 @@ export const load = command({
|
||||
logger.debug("Initial filtered models length:", initialFilteredModels.length);
|
||||
|
||||
let model: DownloadedModel;
|
||||
if (initialFilteredModels.length !== 1 && !yes) {
|
||||
if (path === undefined) {
|
||||
console.info();
|
||||
model = await selectModelToLoad(models, modelPaths, "", 4, lastLoadedMap);
|
||||
} else if (initialFilteredModels.length === 0) {
|
||||
console.info();
|
||||
console.info(
|
||||
chalk.redBright(text`
|
||||
! Cannot find a model matching the provided path (${chalk.yellowBright(path)}). Please
|
||||
select one from the list below.
|
||||
`),
|
||||
);
|
||||
path = "";
|
||||
model = await selectModelToLoad(models, modelPaths, path, 5, lastLoadedMap);
|
||||
} else {
|
||||
console.info();
|
||||
console.info(
|
||||
text`
|
||||
! Multiple models match the provided path. Please select one.
|
||||
`,
|
||||
);
|
||||
model = await selectModelToLoad(models, modelPaths, path ?? "", 5, lastLoadedMap);
|
||||
}
|
||||
} else {
|
||||
if (yes) {
|
||||
if (initialFilteredModels.length === 0) {
|
||||
logger.errorWithoutPrefix(
|
||||
makeTitledPrettyError(
|
||||
@ -212,6 +189,34 @@ export const load = command({
|
||||
process.exit(1);
|
||||
}
|
||||
model = models[initialFilteredModels[0].index];
|
||||
} else {
|
||||
console.info();
|
||||
if (path === undefined) {
|
||||
model = await selectModelToLoad(models, modelPaths, "", 4, lastLoadedMap);
|
||||
} else if (initialFilteredModels.length === 0) {
|
||||
console.info(
|
||||
chalk.redBright(text`
|
||||
! Cannot find a model matching the provided path (${chalk.yellowBright(path)}). Please
|
||||
select one from the list below.
|
||||
`),
|
||||
);
|
||||
path = "";
|
||||
model = await selectModelToLoad(models, modelPaths, path, 5, lastLoadedMap);
|
||||
} else if (initialFilteredModels.length === 1) {
|
||||
console.info(
|
||||
text`
|
||||
! Confirm model selection, or select a different model.
|
||||
`,
|
||||
);
|
||||
model = await selectModelToLoad(models, modelPaths, path ?? "", 5, lastLoadedMap);
|
||||
} else {
|
||||
console.info(
|
||||
text`
|
||||
! Multiple models match the provided path. Please select one.
|
||||
`,
|
||||
);
|
||||
model = await selectModelToLoad(models, modelPaths, path ?? "", 5, lastLoadedMap);
|
||||
}
|
||||
}
|
||||
|
||||
const modelInLastLoadedModelsIndex = lastLoadedModels.indexOf(model.path);
|
||||
|
Reference in New Issue
Block a user