node-llama-cpp 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -301
- package/dist/chatWrappers/{ChatMLPromptWrapper.d.ts → ChatMLChatPromptWrapper.d.ts} +1 -1
- package/dist/chatWrappers/{ChatMLPromptWrapper.js → ChatMLChatPromptWrapper.js} +2 -2
- package/dist/chatWrappers/ChatMLChatPromptWrapper.js.map +1 -0
- package/dist/chatWrappers/createChatWrapperByBos.js +2 -2
- package/dist/chatWrappers/createChatWrapperByBos.js.map +1 -1
- package/dist/cli/commands/BuildCommand.js +3 -1
- package/dist/cli/commands/BuildCommand.js.map +1 -1
- package/dist/cli/commands/ChatCommand.d.ts +8 -1
- package/dist/cli/commands/ChatCommand.js +88 -21
- package/dist/cli/commands/ChatCommand.js.map +1 -1
- package/dist/cli/commands/DownloadCommand.d.ts +3 -2
- package/dist/cli/commands/DownloadCommand.js +19 -38
- package/dist/cli/commands/DownloadCommand.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/llamaEvaluator/LlamaBins.d.ts +3 -3
- package/dist/llamaEvaluator/LlamaBins.js +2 -2
- package/dist/llamaEvaluator/LlamaBins.js.map +1 -1
- package/dist/llamaEvaluator/LlamaChatSession.d.ts +79 -2
- package/dist/llamaEvaluator/LlamaChatSession.js +52 -8
- package/dist/llamaEvaluator/LlamaChatSession.js.map +1 -1
- package/dist/llamaEvaluator/LlamaContext.d.ts +60 -3
- package/dist/llamaEvaluator/LlamaContext.js +36 -4
- package/dist/llamaEvaluator/LlamaContext.js.map +1 -1
- package/dist/llamaEvaluator/LlamaGrammar.d.ts +16 -3
- package/dist/llamaEvaluator/LlamaGrammar.js +23 -4
- package/dist/llamaEvaluator/LlamaGrammar.js.map +1 -1
- package/dist/llamaEvaluator/LlamaGrammarEvaluationState.d.ts +14 -0
- package/dist/llamaEvaluator/LlamaGrammarEvaluationState.js +16 -0
- package/dist/llamaEvaluator/LlamaGrammarEvaluationState.js.map +1 -0
- package/dist/llamaEvaluator/LlamaModel.d.ts +46 -14
- package/dist/llamaEvaluator/LlamaModel.js +23 -16
- package/dist/llamaEvaluator/LlamaModel.js.map +1 -1
- package/dist/state.d.ts +2 -0
- package/dist/state.js +8 -0
- package/dist/state.js.map +1 -0
- package/dist/utils/cloneLlamaCppRepo.d.ts +1 -0
- package/dist/utils/cloneLlamaCppRepo.js +59 -0
- package/dist/utils/cloneLlamaCppRepo.js.map +1 -0
- package/dist/utils/compileLLamaCpp.js +23 -5
- package/dist/utils/compileLLamaCpp.js.map +1 -1
- package/dist/utils/getBin.d.ts +21 -13
- package/dist/utils/gitReleaseBundles.d.ts +2 -0
- package/dist/utils/gitReleaseBundles.js +64 -0
- package/dist/utils/gitReleaseBundles.js.map +1 -0
- package/llama/addon.cpp +184 -110
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/gitRelease.bundle +0 -0
- package/llama/toolchains/darwin.host-x64.target-arm64.cmake +8 -0
- package/llama/toolchains/linux.host-arm64.target-x64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm71.cmake +5 -0
- package/llamaBins/linux-arm64/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l/llama-addon.node +0 -0
- package/llamaBins/linux-x64/llama-addon.node +0 -0
- package/llamaBins/mac-arm64/ggml-metal.metal +258 -85
- package/llamaBins/mac-arm64/llama-addon.node +0 -0
- package/llamaBins/mac-x64/ggml-metal.metal +258 -85
- package/llamaBins/mac-x64/llama-addon.node +0 -0
- package/llamaBins/win-x64/llama-addon.node +0 -0
- package/package.json +10 -4
- package/dist/chatWrappers/ChatMLPromptWrapper.js.map +0 -1
- package/llamaBins/linux-ppc64le/llama-addon.node +0 -0
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import * as readline from "readline
|
|
1
|
+
import * as readline from "readline";
|
|
2
2
|
import process from "process";
|
|
3
|
+
import path from "path";
|
|
3
4
|
import chalk from "chalk";
|
|
4
5
|
import withOra from "../../utils/withOra.js";
|
|
5
6
|
import { defaultChatSystemPrompt } from "../../config.js";
|
|
6
7
|
import { LlamaChatPromptWrapper } from "../../chatWrappers/LlamaChatPromptWrapper.js";
|
|
7
8
|
import { GeneralChatPromptWrapper } from "../../chatWrappers/GeneralChatPromptWrapper.js";
|
|
8
|
-
import {
|
|
9
|
+
import { ChatMLChatPromptWrapper } from "../../chatWrappers/ChatMLChatPromptWrapper.js";
|
|
9
10
|
import { getChatWrapperByBos } from "../../chatWrappers/createChatWrapperByBos.js";
|
|
10
11
|
import { FalconChatPromptWrapper } from "../../chatWrappers/FalconChatPromptWrapper.js";
|
|
12
|
+
import { getIsInDocumentationMode } from "../../state.js";
|
|
13
|
+
const modelWrappers = ["auto", "general", "llamaChat", "chatML", "falconChat"];
|
|
11
14
|
export const ChatCommand = {
|
|
12
15
|
command: "chat",
|
|
13
16
|
describe: "Chat with a Llama model",
|
|
14
17
|
builder(yargs) {
|
|
18
|
+
const isInDocumentationMode = getIsInDocumentationMode();
|
|
15
19
|
return yargs
|
|
16
20
|
.option("model", {
|
|
17
21
|
alias: "m",
|
|
@@ -31,16 +35,21 @@ export const ChatCommand = {
|
|
|
31
35
|
alias: "s",
|
|
32
36
|
type: "string",
|
|
33
37
|
default: defaultChatSystemPrompt,
|
|
34
|
-
defaultDescription: "",
|
|
35
|
-
description: "System prompt to use against the model
|
|
36
|
-
"[default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]",
|
|
38
|
+
defaultDescription: " ",
|
|
39
|
+
description: "System prompt to use against the model" +
|
|
40
|
+
(isInDocumentationMode ? "" : (". [default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]")),
|
|
41
|
+
group: "Optional:"
|
|
42
|
+
})
|
|
43
|
+
.option("prompt", {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "First prompt to automatically send to the model when starting the chat",
|
|
37
46
|
group: "Optional:"
|
|
38
47
|
})
|
|
39
48
|
.option("wrapper", {
|
|
40
49
|
alias: "w",
|
|
41
50
|
type: "string",
|
|
42
51
|
default: "general",
|
|
43
|
-
choices:
|
|
52
|
+
choices: modelWrappers,
|
|
44
53
|
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token",
|
|
45
54
|
group: "Optional:"
|
|
46
55
|
})
|
|
@@ -85,6 +94,39 @@ export const ChatCommand = {
|
|
|
85
94
|
default: 0.95,
|
|
86
95
|
description: "Dynamically selects the smallest set of tokens whose cumulative probability exceeds the threshold P, and samples the next token only from this set. A float number between `0` and `1`. Set to `1` to disable. Only relevant when `temperature` is set to a value greater than `0`.",
|
|
87
96
|
group: "Optional:"
|
|
97
|
+
})
|
|
98
|
+
.option("repeatPenalty", {
|
|
99
|
+
alias: "rp",
|
|
100
|
+
type: "number",
|
|
101
|
+
default: 1.1,
|
|
102
|
+
description: "Prevent the model from repeating the same token too much. Set to `1` to disable.",
|
|
103
|
+
group: "Optional:"
|
|
104
|
+
})
|
|
105
|
+
.option("lastTokensRepeatPenalty", {
|
|
106
|
+
alias: "rpn",
|
|
107
|
+
type: "number",
|
|
108
|
+
default: 64,
|
|
109
|
+
description: "Number of recent tokens generated by the model to apply penalties to repetition of",
|
|
110
|
+
group: "Optional:"
|
|
111
|
+
})
|
|
112
|
+
.option("penalizeRepeatingNewLine", {
|
|
113
|
+
alias: "rpnl",
|
|
114
|
+
type: "boolean",
|
|
115
|
+
default: true,
|
|
116
|
+
description: "Penalize new line tokens. set \"--no-penalizeRepeatingNewLine\" or \"--no-rpnl\" to disable",
|
|
117
|
+
group: "Optional:"
|
|
118
|
+
})
|
|
119
|
+
.option("repeatFrequencyPenalty", {
|
|
120
|
+
alias: "rfp",
|
|
121
|
+
type: "number",
|
|
122
|
+
description: "For n time a token is in the `punishTokens` array, lower its probability by `n * repeatFrequencyPenalty`. Set to a value between `0` and `1` to enable.",
|
|
123
|
+
group: "Optional:"
|
|
124
|
+
})
|
|
125
|
+
.option("repeatPresencePenalty", {
|
|
126
|
+
alias: "rpp",
|
|
127
|
+
type: "number",
|
|
128
|
+
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable.",
|
|
129
|
+
group: "Optional:"
|
|
88
130
|
})
|
|
89
131
|
.option("maxTokens", {
|
|
90
132
|
alias: "mt",
|
|
@@ -94,9 +136,12 @@ export const ChatCommand = {
|
|
|
94
136
|
group: "Optional:"
|
|
95
137
|
});
|
|
96
138
|
},
|
|
97
|
-
async handler({ model, systemInfo, systemPrompt, wrapper, contextSize, grammar, threads, temperature, topK, topP, maxTokens }) {
|
|
139
|
+
async handler({ model, systemInfo, systemPrompt, prompt, wrapper, contextSize, grammar, threads, temperature, topK, topP, repeatPenalty, lastTokensRepeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens }) {
|
|
98
140
|
try {
|
|
99
|
-
await RunChat({
|
|
141
|
+
await RunChat({
|
|
142
|
+
model, systemInfo, systemPrompt, prompt, wrapper, contextSize, grammar, threads, temperature, topK, topP,
|
|
143
|
+
lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens
|
|
144
|
+
});
|
|
100
145
|
}
|
|
101
146
|
catch (err) {
|
|
102
147
|
console.error(err);
|
|
@@ -104,25 +149,23 @@ export const ChatCommand = {
|
|
|
104
149
|
}
|
|
105
150
|
}
|
|
106
151
|
};
|
|
107
|
-
async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, contextSize, grammar: grammarArg, threads, temperature, topK, topP, maxTokens }) {
|
|
152
|
+
async function RunChat({ model: modelArg, systemInfo, systemPrompt, prompt, wrapper, contextSize, grammar: grammarArg, threads, temperature, topK, topP, lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens }) {
|
|
108
153
|
const { LlamaChatSession } = await import("../../llamaEvaluator/LlamaChatSession.js");
|
|
109
154
|
const { LlamaModel } = await import("../../llamaEvaluator/LlamaModel.js");
|
|
110
155
|
const { LlamaContext } = await import("../../llamaEvaluator/LlamaContext.js");
|
|
111
156
|
const { LlamaGrammar } = await import("../../llamaEvaluator/LlamaGrammar.js");
|
|
157
|
+
let initialPrompt = prompt ?? null;
|
|
112
158
|
const model = new LlamaModel({
|
|
113
|
-
modelPath: modelArg
|
|
114
|
-
contextSize,
|
|
115
|
-
threads,
|
|
116
|
-
temperature,
|
|
117
|
-
topK,
|
|
118
|
-
topP
|
|
159
|
+
modelPath: path.resolve(process.cwd(), modelArg)
|
|
119
160
|
});
|
|
120
161
|
const context = new LlamaContext({
|
|
121
162
|
model,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
: undefined
|
|
163
|
+
contextSize,
|
|
164
|
+
threads
|
|
125
165
|
});
|
|
166
|
+
const grammar = grammarArg !== "text"
|
|
167
|
+
? await LlamaGrammar.getFor(grammarArg)
|
|
168
|
+
: undefined;
|
|
126
169
|
const bos = context.getBosString(); // bos = beginning of sequence
|
|
127
170
|
const eos = context.getEosString(); // eos = end of sequence
|
|
128
171
|
const promptWrapper = getChatWrapper(wrapper, bos);
|
|
@@ -135,6 +178,13 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, con
|
|
|
135
178
|
console.info(`${chalk.yellow("BOS:")} ${bos}`);
|
|
136
179
|
console.info(`${chalk.yellow("EOS:")} ${eos}`);
|
|
137
180
|
console.info(`${chalk.yellow("Chat wrapper:")} ${promptWrapper.wrapperName}`);
|
|
181
|
+
console.info(`${chalk.yellow("Repeat penalty:")} ${repeatPenalty} (apply to last ${lastTokensRepeatPenalty} tokens)`);
|
|
182
|
+
if (repeatFrequencyPenalty != null)
|
|
183
|
+
console.info(`${chalk.yellow("Repeat frequency penalty:")} ${repeatFrequencyPenalty}`);
|
|
184
|
+
if (repeatPresencePenalty != null)
|
|
185
|
+
console.info(`${chalk.yellow("Repeat presence penalty:")} ${repeatPresencePenalty}`);
|
|
186
|
+
if (!penalizeRepeatingNewLine)
|
|
187
|
+
console.info(`${chalk.yellow("Penalize repeating new line:")} disabled`);
|
|
138
188
|
await withOra({
|
|
139
189
|
loading: chalk.blue("Loading model"),
|
|
140
190
|
success: chalk.blue("Model loaded"),
|
|
@@ -150,20 +200,37 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, con
|
|
|
150
200
|
});
|
|
151
201
|
// eslint-disable-next-line no-constant-condition
|
|
152
202
|
while (true) {
|
|
153
|
-
const input =
|
|
203
|
+
const input = initialPrompt != null
|
|
204
|
+
? initialPrompt
|
|
205
|
+
: await new Promise((accept) => rl.question(chalk.yellow("> "), accept));
|
|
206
|
+
if (initialPrompt != null) {
|
|
207
|
+
console.log(chalk.green("> ") + initialPrompt);
|
|
208
|
+
initialPrompt = null;
|
|
209
|
+
}
|
|
154
210
|
if (input === ".exit")
|
|
155
211
|
break;
|
|
156
212
|
process.stdout.write(chalk.yellow("AI: "));
|
|
157
213
|
const [startColor, endColor] = chalk.blue("MIDDLE").split("MIDDLE");
|
|
158
214
|
process.stdout.write(startColor);
|
|
159
215
|
await session.prompt(input, {
|
|
216
|
+
grammar,
|
|
217
|
+
temperature,
|
|
218
|
+
topK,
|
|
219
|
+
topP,
|
|
220
|
+
repeatPenalty: {
|
|
221
|
+
penalty: repeatPenalty,
|
|
222
|
+
frequencyPenalty: repeatFrequencyPenalty != null ? repeatFrequencyPenalty : undefined,
|
|
223
|
+
presencePenalty: repeatPresencePenalty != null ? repeatPresencePenalty : undefined,
|
|
224
|
+
penalizeNewLine: penalizeRepeatingNewLine,
|
|
225
|
+
lastTokens: lastTokensRepeatPenalty
|
|
226
|
+
},
|
|
160
227
|
maxTokens: maxTokens === -1
|
|
161
228
|
? context.getContextSize()
|
|
162
229
|
: maxTokens <= 0
|
|
163
230
|
? undefined
|
|
164
231
|
: maxTokens,
|
|
165
232
|
onToken(chunk) {
|
|
166
|
-
process.stdout.write(session.context.decode(
|
|
233
|
+
process.stdout.write(session.context.decode(chunk));
|
|
167
234
|
}
|
|
168
235
|
});
|
|
169
236
|
process.stdout.write(endColor);
|
|
@@ -177,7 +244,7 @@ function getChatWrapper(wrapper, bos) {
|
|
|
177
244
|
case "llamaChat":
|
|
178
245
|
return new LlamaChatPromptWrapper();
|
|
179
246
|
case "chatML":
|
|
180
|
-
return new
|
|
247
|
+
return new ChatMLChatPromptWrapper();
|
|
181
248
|
case "falconChat":
|
|
182
249
|
return new FalconChatPromptWrapper();
|
|
183
250
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ChatCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"ChatCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ChatCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,sBAAsB,EAAC,MAAM,8CAA8C,CAAC;AACpF,OAAO,EAAC,wBAAwB,EAAC,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAC,uBAAuB,EAAC,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAC,mBAAmB,EAAC,MAAM,8CAA8C,CAAC;AAEjF,OAAO,EAAC,uBAAuB,EAAC,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAC,wBAAwB,EAAC,MAAM,gBAAgB,C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G,mBAAmB,CAAC,GAAG,CAAC,CAAC;QAE7C,IAAI,WAAW,IAAI,IAAI;YACnB,OAAO,IAAI,WAAW,EAAE,CAAC;QAE7B,OAAO,IAAI,wBAAwB,EAAE,CAAC;KACzC;IAED,KAAK,CAAC,OAAuB,CAAC,CAAC;IAE/B,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,OAAO,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -7,8 +7,9 @@ type DownloadCommandArgs = {
|
|
|
7
7
|
metal: boolean;
|
|
8
8
|
cuda: boolean;
|
|
9
9
|
skipBuild?: boolean;
|
|
10
|
-
|
|
10
|
+
noBundle?: boolean;
|
|
11
|
+
updateBinariesReleaseMetadataAndSaveGitBundle?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export declare const DownloadCommand: CommandModule<object, DownloadCommandArgs>;
|
|
13
|
-
export declare function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild,
|
|
14
|
+
export declare function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild, noBundle, updateBinariesReleaseMetadataAndSaveGitBundle }: DownloadCommandArgs): Promise<void>;
|
|
14
15
|
export {};
|
|
@@ -2,19 +2,21 @@ import process from "process";
|
|
|
2
2
|
import { Octokit } from "octokit";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import
|
|
6
|
-
import simpleGit from "simple-git";
|
|
7
|
-
import { defaultLlamaCppCudaSupport, defaultLlamaCppGitHubRepo, defaultLlamaCppMetalSupport, defaultLlamaCppRelease, llamaCppDirectory } from "../../config.js";
|
|
5
|
+
import { defaultLlamaCppCudaSupport, defaultLlamaCppGitHubRepo, defaultLlamaCppMetalSupport, defaultLlamaCppRelease, isCI, llamaCppDirectory } from "../../config.js";
|
|
8
6
|
import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js";
|
|
9
7
|
import withOra from "../../utils/withOra.js";
|
|
10
8
|
import { clearTempFolder } from "../../utils/clearTempFolder.js";
|
|
11
9
|
import { setBinariesGithubRelease } from "../../utils/binariesGithubRelease.js";
|
|
12
10
|
import { downloadCmakeIfNeeded } from "../../utils/cmake.js";
|
|
13
11
|
import withStatusLogs from "../../utils/withStatusLogs.js";
|
|
12
|
+
import { getIsInDocumentationMode } from "../../state.js";
|
|
13
|
+
import { unshallowAndSquashCurrentRepoAndSaveItAsReleaseBundle } from "../../utils/gitReleaseBundles.js";
|
|
14
|
+
import { cloneLlamaCppRepo } from "../../utils/cloneLlamaCppRepo.js";
|
|
14
15
|
export const DownloadCommand = {
|
|
15
16
|
command: "download",
|
|
16
17
|
describe: "Download a release of llama.cpp and compile it",
|
|
17
18
|
builder(yargs) {
|
|
19
|
+
const isInDocumentationMode = getIsInDocumentationMode();
|
|
18
20
|
return yargs
|
|
19
21
|
.option("repo", {
|
|
20
22
|
type: "string",
|
|
@@ -23,7 +25,7 @@ export const DownloadCommand = {
|
|
|
23
25
|
})
|
|
24
26
|
.option("release", {
|
|
25
27
|
type: "string",
|
|
26
|
-
default: defaultLlamaCppRelease,
|
|
28
|
+
default: isInDocumentationMode ? "<current build>" : defaultLlamaCppRelease,
|
|
27
29
|
description: "The tag of the llama.cpp release to download. Set to \"latest\" to download the latest release. Can also be set via the NODE_LLAMA_CPP_REPO_RELEASE environment variable"
|
|
28
30
|
})
|
|
29
31
|
.option("arch", {
|
|
@@ -38,8 +40,8 @@ export const DownloadCommand = {
|
|
|
38
40
|
})
|
|
39
41
|
.option("metal", {
|
|
40
42
|
type: "boolean",
|
|
41
|
-
default: defaultLlamaCppMetalSupport,
|
|
42
|
-
hidden: process.platform !== "darwin",
|
|
43
|
+
default: defaultLlamaCppMetalSupport || isInDocumentationMode,
|
|
44
|
+
hidden: process.platform !== "darwin" && !isInDocumentationMode,
|
|
43
45
|
description: "Compile llama.cpp with Metal support. Enabled by default on macOS. Can be disabled with \"--no-metal\". Can also be set via the NODE_LLAMA_CPP_METAL environment variable"
|
|
44
46
|
})
|
|
45
47
|
.option("cuda", {
|
|
@@ -53,7 +55,13 @@ export const DownloadCommand = {
|
|
|
53
55
|
default: false,
|
|
54
56
|
description: "Skip building llama.cpp after downloading it"
|
|
55
57
|
})
|
|
56
|
-
.option("
|
|
58
|
+
.option("noBundle", {
|
|
59
|
+
alias: "nb",
|
|
60
|
+
type: "boolean",
|
|
61
|
+
default: false,
|
|
62
|
+
description: "Download a llama.cpp only from GitHub, even if a local git bundle exists for the release"
|
|
63
|
+
})
|
|
64
|
+
.option("updateBinariesReleaseMetadataAndSaveGitBundle", {
|
|
57
65
|
type: "boolean",
|
|
58
66
|
hidden: true,
|
|
59
67
|
default: false,
|
|
@@ -62,7 +70,7 @@ export const DownloadCommand = {
|
|
|
62
70
|
},
|
|
63
71
|
handler: DownloadLlamaCppCommand
|
|
64
72
|
};
|
|
65
|
-
export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild,
|
|
73
|
+
export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild, noBundle, updateBinariesReleaseMetadataAndSaveGitBundle }) {
|
|
66
74
|
const octokit = new Octokit();
|
|
67
75
|
const [githubOwner, githubRepo] = repo.split("/");
|
|
68
76
|
console.log(`${chalk.yellow("Repo:")} ${repo}`);
|
|
@@ -116,7 +124,7 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
116
124
|
await fs.remove(llamaCppDirectory);
|
|
117
125
|
});
|
|
118
126
|
console.log(chalk.blue("Cloning llama.cpp"));
|
|
119
|
-
await
|
|
127
|
+
await cloneLlamaCppRepo(githubOwner, githubRepo, githubRelease.data.tag_name, noBundle != true);
|
|
120
128
|
if (!skipBuild) {
|
|
121
129
|
await downloadCmakeIfNeeded(true);
|
|
122
130
|
await withStatusLogs({
|
|
@@ -133,8 +141,9 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
133
141
|
});
|
|
134
142
|
});
|
|
135
143
|
}
|
|
136
|
-
if (
|
|
144
|
+
if (isCI && updateBinariesReleaseMetadataAndSaveGitBundle) {
|
|
137
145
|
await setBinariesGithubRelease(githubRelease.data.tag_name);
|
|
146
|
+
await unshallowAndSquashCurrentRepoAndSaveItAsReleaseBundle();
|
|
138
147
|
}
|
|
139
148
|
console.log();
|
|
140
149
|
console.log();
|
|
@@ -143,32 +152,4 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
143
152
|
console.log();
|
|
144
153
|
console.log(chalk.green("Done"));
|
|
145
154
|
}
|
|
146
|
-
async function cloneTag(githubOwner, githubRepo, tag, directory) {
|
|
147
|
-
const progressBar = new cliProgress.Bar({
|
|
148
|
-
clearOnComplete: false,
|
|
149
|
-
hideCursor: true,
|
|
150
|
-
autopadding: true,
|
|
151
|
-
format: `${chalk.bold("Clone {repo}")} ${chalk.yellow("{percentage}%")} ${chalk.cyan("{bar}")} ${chalk.grey("{eta_formatted}")}`
|
|
152
|
-
}, cliProgress.Presets.shades_classic);
|
|
153
|
-
progressBar.start(100, 0, {
|
|
154
|
-
speed: "",
|
|
155
|
-
repo: `${githubOwner}/${githubRepo}`
|
|
156
|
-
});
|
|
157
|
-
try {
|
|
158
|
-
await simpleGit({
|
|
159
|
-
progress({ progress, total, processed }) {
|
|
160
|
-
const totalProgress = (processed / 100) + (progress / total);
|
|
161
|
-
progressBar.update(Math.floor(totalProgress * 10000) / 100);
|
|
162
|
-
}
|
|
163
|
-
}).clone(`https://github.com/${githubOwner}/${githubRepo}.git`, directory, {
|
|
164
|
-
"--depth": 1,
|
|
165
|
-
"--branch": tag,
|
|
166
|
-
"--quiet": null
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
finally {
|
|
170
|
-
progressBar.update(100);
|
|
171
|
-
progressBar.stop();
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
155
|
//# sourceMappingURL=DownloadCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/DownloadCommand.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"DownloadCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/DownloadCommand.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACH,0BAA0B,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,IAAI,EAAE,iBAAiB,EACtI,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,wBAAwB,EAAC,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAC3D,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,wBAAwB,EAAC,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAC,qDAAqD,EAAC,MAAM,kCAAkC,CAAC;AACvG,OAAO,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAcnE,MAAM,CAAC,MAAM,eAAe,GAA+C;IACvE,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,gDAAgD;IAC1D,OAAO,CAAC,KAAK;QACT,MAAM,qBAAqB,GAAG,wBAAwB,EAAE,CAAC;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: string;
|
|
2
|
+
export declare const llamaToolchainsDirectory: string;
|
|
2
3
|
export declare const llamaBinsDirectory: string;
|
|
3
4
|
export declare const llamaBinsGrammarsDirectory: string;
|
|
4
5
|
export declare const llamaCppDirectory: string;
|
|
@@ -6,10 +7,12 @@ export declare const llamaCppGrammarsDirectory: string;
|
|
|
6
7
|
export declare const tempDownloadDirectory: string;
|
|
7
8
|
export declare const usedBinFlagJsonPath: string;
|
|
8
9
|
export declare const binariesGithubReleasePath: string;
|
|
10
|
+
export declare const currentReleaseGitBundlePath: string;
|
|
9
11
|
export declare const xpackDirectory: string;
|
|
10
12
|
export declare const localXpacksStoreDirectory: string;
|
|
11
13
|
export declare const localXpacksCacheDirectory: string;
|
|
12
14
|
export declare const xpmVersion = "^0.16.3";
|
|
15
|
+
export declare const isCI: boolean;
|
|
13
16
|
export declare const defaultLlamaCppGitHubRepo: string;
|
|
14
17
|
export declare const defaultLlamaCppRelease: string;
|
|
15
18
|
export declare const defaultLlamaCppMetalSupport: boolean;
|
|
@@ -19,3 +22,5 @@ export declare const defaultXpacksStoreDirectory: string;
|
|
|
19
22
|
export declare const defaultXpacksCacheDirectory: string;
|
|
20
23
|
export declare const customCmakeOptionsEnvVarPrefix = "NODE_LLAMA_CPP_CMAKE_OPTION_";
|
|
21
24
|
export declare const defaultChatSystemPrompt: string;
|
|
25
|
+
export declare const cliBinName = "node-llama-cpp";
|
|
26
|
+
export declare const npxRunPrefix = "npx --no ";
|
package/dist/config.js
CHANGED
|
@@ -8,6 +8,7 @@ import { getBinariesGithubRelease } from "./utils/binariesGithubRelease.js";
|
|
|
8
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
const env = envVar.from(process.env);
|
|
10
10
|
export const llamaDirectory = path.join(__dirname, "..", "llama");
|
|
11
|
+
export const llamaToolchainsDirectory = path.join(llamaDirectory, "toolchains");
|
|
11
12
|
export const llamaBinsDirectory = path.join(__dirname, "..", "llamaBins");
|
|
12
13
|
export const llamaBinsGrammarsDirectory = path.join(__dirname, "..", "llama", "grammars");
|
|
13
14
|
export const llamaCppDirectory = path.join(llamaDirectory, "llama.cpp");
|
|
@@ -15,10 +16,14 @@ export const llamaCppGrammarsDirectory = path.join(llamaDirectory, "llama.cpp",
|
|
|
15
16
|
export const tempDownloadDirectory = path.join(os.tmpdir(), "node-llama-cpp", uuid.v4());
|
|
16
17
|
export const usedBinFlagJsonPath = path.join(llamaDirectory, "usedBin.json");
|
|
17
18
|
export const binariesGithubReleasePath = path.join(llamaDirectory, "binariesGithubRelease.json");
|
|
19
|
+
export const currentReleaseGitBundlePath = path.join(llamaDirectory, "gitRelease.bundle");
|
|
18
20
|
export const xpackDirectory = path.join(llamaDirectory, "xpack");
|
|
19
21
|
export const localXpacksStoreDirectory = path.join(xpackDirectory, "store");
|
|
20
22
|
export const localXpacksCacheDirectory = path.join(xpackDirectory, "cache");
|
|
21
23
|
export const xpmVersion = "^0.16.3";
|
|
24
|
+
export const isCI = env.get("CI")
|
|
25
|
+
.default("false")
|
|
26
|
+
.asBool();
|
|
22
27
|
export const defaultLlamaCppGitHubRepo = env.get("NODE_LLAMA_CPP_REPO")
|
|
23
28
|
.default("ggerganov/llama.cpp")
|
|
24
29
|
.asString();
|
|
@@ -44,4 +49,6 @@ export const customCmakeOptionsEnvVarPrefix = "NODE_LLAMA_CPP_CMAKE_OPTION_";
|
|
|
44
49
|
export const defaultChatSystemPrompt = "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible.\n" +
|
|
45
50
|
"If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. " +
|
|
46
51
|
"If you don't know the answer to a question, please don't share false information.";
|
|
52
|
+
export const cliBinName = "node-llama-cpp";
|
|
53
|
+
export const npxRunPrefix = "npx --no ";
|
|
47
54
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAA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d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { LlamaModel, type LlamaModelOptions } from "./llamaEvaluator/LlamaModel.js";
|
|
2
2
|
import { LlamaGrammar, type LlamaGrammarOptions } from "./llamaEvaluator/LlamaGrammar.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { LlamaGrammarEvaluationState, LlamaGrammarEvaluationStateOptions } from "./llamaEvaluator/LlamaGrammarEvaluationState.js";
|
|
4
|
+
import { LlamaContext, type LlamaContextOptions, type LlamaContextRepeatPenalty } from "./llamaEvaluator/LlamaContext.js";
|
|
5
|
+
import { LlamaChatSession, type LlamaChatSessionOptions, type LlamaChatSessionRepeatPenalty } from "./llamaEvaluator/LlamaChatSession.js";
|
|
5
6
|
import { AbortError } from "./AbortError.js";
|
|
6
7
|
import { ChatPromptWrapper } from "./ChatPromptWrapper.js";
|
|
7
8
|
import { EmptyChatPromptWrapper } from "./chatWrappers/EmptyChatPromptWrapper.js";
|
|
8
9
|
import { LlamaChatPromptWrapper } from "./chatWrappers/LlamaChatPromptWrapper.js";
|
|
9
10
|
import { GeneralChatPromptWrapper } from "./chatWrappers/GeneralChatPromptWrapper.js";
|
|
10
|
-
import {
|
|
11
|
+
import { ChatMLChatPromptWrapper } from "./chatWrappers/ChatMLChatPromptWrapper.js";
|
|
11
12
|
import { FalconChatPromptWrapper } from "./chatWrappers/FalconChatPromptWrapper.js";
|
|
12
13
|
import { getChatWrapperByBos } from "./chatWrappers/createChatWrapperByBos.js";
|
|
13
14
|
import { type ConversationInteraction, type Token } from "./types.js";
|
|
14
|
-
export { LlamaModel, type LlamaModelOptions, LlamaGrammar, type LlamaGrammarOptions, LlamaContext, type LlamaContextOptions, LlamaChatSession, type LlamaChatSessionOptions, type ConversationInteraction, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper,
|
|
15
|
+
export { LlamaModel, type LlamaModelOptions, LlamaGrammar, type LlamaGrammarOptions, LlamaGrammarEvaluationState, type LlamaGrammarEvaluationStateOptions, LlamaContext, type LlamaContextOptions, type LlamaContextRepeatPenalty, LlamaChatSession, type LlamaChatSessionOptions, type LlamaChatSessionRepeatPenalty, type ConversationInteraction, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper, ChatMLChatPromptWrapper, FalconChatPromptWrapper, getChatWrapperByBos, type Token };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LlamaModel } from "./llamaEvaluator/LlamaModel.js";
|
|
2
2
|
import { LlamaGrammar } from "./llamaEvaluator/LlamaGrammar.js";
|
|
3
|
+
import { LlamaGrammarEvaluationState } from "./llamaEvaluator/LlamaGrammarEvaluationState.js";
|
|
3
4
|
import { LlamaContext } from "./llamaEvaluator/LlamaContext.js";
|
|
4
5
|
import { LlamaChatSession } from "./llamaEvaluator/LlamaChatSession.js";
|
|
5
6
|
import { AbortError } from "./AbortError.js";
|
|
@@ -7,8 +8,8 @@ import { ChatPromptWrapper } from "./ChatPromptWrapper.js";
|
|
|
7
8
|
import { EmptyChatPromptWrapper } from "./chatWrappers/EmptyChatPromptWrapper.js";
|
|
8
9
|
import { LlamaChatPromptWrapper } from "./chatWrappers/LlamaChatPromptWrapper.js";
|
|
9
10
|
import { GeneralChatPromptWrapper } from "./chatWrappers/GeneralChatPromptWrapper.js";
|
|
10
|
-
import {
|
|
11
|
+
import { ChatMLChatPromptWrapper } from "./chatWrappers/ChatMLChatPromptWrapper.js";
|
|
11
12
|
import { FalconChatPromptWrapper } from "./chatWrappers/FalconChatPromptWrapper.js";
|
|
12
13
|
import { getChatWrapperByBos } from "./chatWrappers/createChatWrapperByBos.js";
|
|
13
|
-
export { LlamaModel, LlamaGrammar, LlamaContext, LlamaChatSession, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper,
|
|
14
|
+
export { LlamaModel, LlamaGrammar, LlamaGrammarEvaluationState, LlamaContext, LlamaChatSession, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper, ChatMLChatPromptWrapper, FalconChatPromptWrapper, getChatWrapperByBos };
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAyB,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAC,YAAY,EAA2B,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAyB,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAC,YAAY,EAA2B,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAC,2BAA2B,EAAqC,MAAM,iDAAiD,CAAC;AAChI,OAAO,EAAC,YAAY,EAA2D,MAAM,kCAAkC,CAAC;AACxH,OAAO,EAAC,gBAAgB,EAAmE,MAAM,sCAAsC,CAAC;AACxI,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,sBAAsB,EAAC,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAC,sBAAsB,EAAC,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAC,wBAAwB,EAAC,MAAM,4CAA4C,CAAC;AACpF,OAAO,EAAC,uBAAuB,EAAC,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAC,uBAAuB,EAAC,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAK7E,OAAO,EACH,UAAU,EAEV,YAAY,EAEZ,2BAA2B,EAE3B,YAAY,EAGZ,gBAAgB,EAIhB,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EAEtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LLAMAModel, type LLAMAContext, type LLAMAGrammar } from "../utils/getBin.js";
|
|
1
|
+
import { type LLAMAModel, type LLAMAContext, type LLAMAGrammar, type LLAMAGrammarEvaluationState } from "../utils/getBin.js";
|
|
2
2
|
export declare const llamaCppNode: import("../utils/getBin.js").LlamaCppNodeModule;
|
|
3
|
-
declare const LLAMAModel: LLAMAModel, LLAMAContext: LLAMAContext, LLAMAGrammar: LLAMAGrammar;
|
|
4
|
-
export { LLAMAModel, LLAMAContext, LLAMAGrammar };
|
|
3
|
+
declare const LLAMAModel: LLAMAModel, LLAMAContext: LLAMAContext, LLAMAGrammar: LLAMAGrammar, LLAMAGrammarEvaluationState: LLAMAGrammarEvaluationState;
|
|
4
|
+
export { LLAMAModel, LLAMAContext, LLAMAGrammar, LLAMAGrammarEvaluationState };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadBin } from "../utils/getBin.js";
|
|
2
2
|
export const llamaCppNode = await loadBin();
|
|
3
|
-
const { LLAMAModel, LLAMAContext, LLAMAGrammar } = llamaCppNode;
|
|
4
|
-
export { LLAMAModel, LLAMAContext, LLAMAGrammar };
|
|
3
|
+
const { LLAMAModel, LLAMAContext, LLAMAGrammar, LLAMAGrammarEvaluationState } = llamaCppNode;
|
|
4
|
+
export { LLAMAModel, LLAMAContext, LLAMAGrammar, LLAMAGrammarEvaluationState };
|
|
5
5
|
//# sourceMappingURL=LlamaBins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlamaBins.js","sourceRoot":"","sources":["../../src/llamaEvaluator/LlamaBins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"LlamaBins.js","sourceRoot":"","sources":["../../src/llamaEvaluator/LlamaBins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAA0F,MAAM,oBAAoB,CAAC;AAEpI,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,OAAO,EAAE,CAAC;AAC5C,MAAM,EAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,2BAA2B,EAAC,GAAG,YAAY,CAAC;AAE3F,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,2BAA2B,EAAC,CAAC"}
|