diff --git a/src/createClient.ts b/src/createClient.ts index 418c9cb..8828460 100644 --- a/src/createClient.ts +++ b/src/createClient.ts @@ -1,4 +1,4 @@ -import { makePrettyError, text, type SimpleLogger } from "@lmstudio/lms-common"; +import { text, type SimpleLogger } from "@lmstudio/lms-common"; import { LMStudioClient } from "@lmstudio/sdk"; import chalk from "chalk"; import { checkHttpServer, getServerLastStatus } from "./subcommands/server"; @@ -13,14 +13,15 @@ export async function createClient(logger: SimpleLogger) { port = 1234; } if (!(await checkHttpServer(logger, port))) { - logger.errorWithoutPrefix( - makePrettyError(text` - ${chalk.redBright(text` - LM Studio server is not running. To start the server, run the following command: - `)} + logger.error( + text` + LM Studio needs to be running in server mode to perform this operation. - ${chalk.yellow("lms server start ")}${chalk.gray("[--port ] [--cors=true|false]")} - `).message, + To start the server, run the following command: + + ${chalk.yellow("lms server start ")} + + `, ); process.exit(1); } diff --git a/src/subcommands/list.ts b/src/subcommands/list.ts index b8c9952..3245bde 100644 --- a/src/subcommands/list.ts +++ b/src/subcommands/list.ts @@ -245,12 +245,12 @@ export const ls = command({ console.info(); console.info(text` You have ${chalk.greenBright(downloadedModels.length)} models, - total size: ${chalk.greenBright(formatSizeBytes1000(totalSizeBytes))} + taking up ${chalk.greenBright(formatSizeBytes1000(totalSizeBytes))} of disk space. `); } else { console.info(text` You have ${downloadedModels.length} models, - total size: ${formatSizeBytes1000(totalSizeBytes)} + taking up ${formatSizeBytes1000(totalSizeBytes)} of disk space. `); } console.info(); @@ -306,7 +306,15 @@ export const ps = command({ } if (loadedModels.length === 0) { - console.info(chalk.redBright("You have not loaded any models yet.")); + logger.error( + text` + No models are currently loaded + + To load a model, run: + + ${chalk.yellow("lms load")} + `, + ); return; } diff --git a/src/subcommands/load.ts b/src/subcommands/load.ts index 5b597ed..95ff034 100644 --- a/src/subcommands/load.ts +++ b/src/subcommands/load.ts @@ -170,8 +170,10 @@ export const load = command({ let model: DownloadedModel; if (initialFilteredModels.length !== 1 && !yes) { if (path === undefined) { - model = await selectModelToLoad(models, modelPaths, "", 3, lastLoadedMap); + 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 @@ -179,14 +181,15 @@ export const load = command({ `), ); path = ""; - model = await selectModelToLoad(models, modelPaths, path, 4, lastLoadedMap); + model = await selectModelToLoad(models, modelPaths, path, 5, lastLoadedMap); } else { + console.info(); console.info( chalk.gray(text` ! Multiple models match the provided path. Please select one. `), ); - model = await selectModelToLoad(models, modelPaths, path ?? "", 4, lastLoadedMap); + model = await selectModelToLoad(models, modelPaths, path ?? "", 5, lastLoadedMap); } } else { if (initialFilteredModels.length === 0) { @@ -238,6 +241,7 @@ async function selectModelToLoad( console.info( chalk.gray("! Use the arrow keys to navigate, type to filter, and press enter to select."), ); + console.info(); const { selected } = await inquirer.prompt({ type: "autocomplete", name: "selected", diff --git a/src/subcommands/status.ts b/src/subcommands/status.ts index 729f613..8ac55dd 100644 --- a/src/subcommands/status.ts +++ b/src/subcommands/status.ts @@ -54,7 +54,7 @@ export const status = command({ ${chalk.gray("\n(i) To start the server, run the following command:")} - ${chalk.yellow("lms server start ")}${chalk.gray("[--port ] [--cors=true|false]")} + ${chalk.yellow("lms server start ")} `; } console.info( diff --git a/src/subcommands/unload.ts b/src/subcommands/unload.ts index ca22f16..9b178b0 100644 --- a/src/subcommands/unload.ts +++ b/src/subcommands/unload.ts @@ -98,17 +98,19 @@ export const unload = command({ process.exit(1); } inquirer.registerPrompt("autocomplete", inquirerPrompt); + console.info(); console.info( chalk.gray("! Use the arrow keys to navigate, type to filter, and press enter to select."), ); console.info(chalk.gray("! To unload all models, use the --all flag.")); + console.info(); const { selected } = await inquirer.prompt({ type: "autocomplete", name: "selected", message: chalk.greenBright("Select a model to unload") + chalk.gray(" |"), initialSearch: "", loop: false, - pageSize: terminalSize().rows - 3, + pageSize: terminalSize().rows - 5, emptyText: "No loaded model matched the filter", source: async (_: any, input: string) => { input = input.split("?").join(""); // Strip the question mark to prevent issues