UNPKG

node-llama-cpp

Version:

Run AI models locally on your machine with node.js bindings for llama.cpp. Enforce a JSON schema on the model output on the generation level

54 lines 2.18 kB
import fs from "fs-extra"; import chalk from "chalk"; import { documentationPageUrls, llamaCppDirectory, llamaCppDirectoryInfoFilePath } from "../../../../config.js"; import withOra from "../../../../utils/withOra.js"; import { clearAllLocalBuilds } from "../../../../bindings/utils/clearAllLocalBuilds.js"; import { clearLocalCmake, fixXpackPermissions } from "../../../../utils/cmake.js"; import { withCliCommandDescriptionDocsUrl } from "../../../utils/withCliCommandDescriptionDocsUrl.js"; export const ClearCommand = { command: "clear [type]", aliases: ["clean"], describe: withCliCommandDescriptionDocsUrl("Clear files created by `node-llama-cpp`", documentationPageUrls.CLI.Source.Clear), builder(yargs) { return yargs .option("type", { type: "string", choices: ["source", "builds", "cmake", "all"], default: "all", description: "Files to clear" }); }, handler: ClearLlamaCppBuildCommand }; export async function ClearLlamaCppBuildCommand({ type }) { if (type === "source" || type === "all") { await withOra({ loading: chalk.blue("Clearing source"), success: chalk.blue("Cleared source"), fail: chalk.blue("Failed to clear source") }, async () => { await fs.remove(llamaCppDirectory); await fs.remove(llamaCppDirectoryInfoFilePath); }); } if (type === "builds" || type === "all") { await withOra({ loading: chalk.blue("Clearing all builds"), success: chalk.blue("Cleared all builds"), fail: chalk.blue("Failed to clear all builds") }, async () => { await clearAllLocalBuilds(); }); } if (type === "cmake" || type === "all") { await withOra({ loading: chalk.blue("Clearing internal cmake"), success: chalk.blue("Cleared internal cmake"), fail: chalk.blue("Failed to clear internal cmake") }, async () => { await fixXpackPermissions(); await clearLocalCmake(); }); } } //# sourceMappingURL=ClearCommand.js.map