node-llama-cpp 2.0.0 → 2.1.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 +122 -25
- package/dist/ChatPromptWrapper.d.ts +3 -0
- package/dist/ChatPromptWrapper.js.map +1 -1
- package/dist/chatWrappers/ChatMLPromptWrapper.d.ts +11 -0
- package/dist/chatWrappers/ChatMLPromptWrapper.js +19 -0
- package/dist/chatWrappers/ChatMLPromptWrapper.js.map +1 -0
- package/dist/chatWrappers/EmptyChatPromptWrapper.d.ts +1 -0
- package/dist/chatWrappers/EmptyChatPromptWrapper.js +1 -0
- package/dist/chatWrappers/EmptyChatPromptWrapper.js.map +1 -1
- package/dist/chatWrappers/GeneralChatPromptWrapper.d.ts +11 -1
- package/dist/chatWrappers/GeneralChatPromptWrapper.js +28 -4
- package/dist/chatWrappers/GeneralChatPromptWrapper.js.map +1 -1
- package/dist/chatWrappers/LlamaChatPromptWrapper.d.ts +4 -1
- package/dist/chatWrappers/LlamaChatPromptWrapper.js +8 -4
- package/dist/chatWrappers/LlamaChatPromptWrapper.js.map +1 -1
- package/dist/chatWrappers/createChatWrapperByBos.d.ts +2 -0
- package/dist/chatWrappers/createChatWrapperByBos.js +14 -0
- package/dist/chatWrappers/createChatWrapperByBos.js.map +1 -0
- package/dist/cli/commands/BuildCommand.d.ts +3 -1
- package/dist/cli/commands/BuildCommand.js +24 -2
- package/dist/cli/commands/BuildCommand.js.map +1 -1
- package/dist/cli/commands/ChatCommand.d.ts +7 -1
- package/dist/cli/commands/ChatCommand.js +87 -12
- package/dist/cli/commands/ChatCommand.js.map +1 -1
- package/dist/cli/commands/ClearCommand.js +1 -1
- package/dist/cli/commands/ClearCommand.js.map +1 -1
- package/dist/cli/commands/DownloadCommand.d.ts +3 -1
- package/dist/cli/commands/DownloadCommand.js +60 -69
- package/dist/cli/commands/DownloadCommand.js.map +1 -1
- package/dist/cli/commands/OnPostInstallCommand.js +4 -2
- package/dist/cli/commands/OnPostInstallCommand.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- 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 +7 -2
- package/dist/llamaEvaluator/LlamaChatSession.js +51 -11
- package/dist/llamaEvaluator/LlamaChatSession.js.map +1 -1
- package/dist/llamaEvaluator/LlamaContext.d.ts +31 -2
- package/dist/llamaEvaluator/LlamaContext.js +69 -2
- package/dist/llamaEvaluator/LlamaContext.js.map +1 -1
- package/dist/llamaEvaluator/LlamaGrammar.d.ts +14 -0
- package/dist/llamaEvaluator/LlamaGrammar.js +30 -0
- package/dist/llamaEvaluator/LlamaGrammar.js.map +1 -0
- package/dist/llamaEvaluator/LlamaModel.d.ts +49 -1
- package/dist/llamaEvaluator/LlamaModel.js +25 -9
- package/dist/llamaEvaluator/LlamaModel.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/compileLLamaCpp.d.ts +3 -1
- package/dist/utils/compileLLamaCpp.js +34 -4
- package/dist/utils/compileLLamaCpp.js.map +1 -1
- package/dist/utils/getBin.d.ts +15 -2
- package/dist/utils/getBin.js +4 -2
- package/dist/utils/getBin.js.map +1 -1
- package/dist/utils/getGrammarsFolder.d.ts +1 -0
- package/dist/utils/getGrammarsFolder.js +18 -0
- package/dist/utils/getGrammarsFolder.js.map +1 -0
- package/dist/utils/getTextCompletion.d.ts +3 -0
- package/dist/utils/getTextCompletion.js +12 -0
- package/dist/utils/getTextCompletion.js.map +1 -0
- package/dist/utils/removeNullFields.d.ts +1 -0
- package/dist/utils/removeNullFields.js +9 -0
- package/dist/utils/removeNullFields.js.map +1 -0
- package/dist/utils/spawnCommand.d.ts +2 -1
- package/dist/utils/spawnCommand.js +2 -2
- package/dist/utils/spawnCommand.js.map +1 -1
- package/llama/addon.cpp +154 -19
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/binding.gyp +6 -3
- package/llama/grammars/README.md +91 -0
- package/llama/grammars/arithmetic.gbnf +6 -0
- package/llama/grammars/chess.gbnf +13 -0
- package/llama/grammars/japanese.gbnf +7 -0
- package/llama/grammars/json.gbnf +25 -0
- package/llama/grammars/list.gbnf +4 -0
- package/llamaBins/linux-arm64-16.node +0 -0
- package/llamaBins/linux-arm64-17.node +0 -0
- package/llamaBins/linux-arm64-18.node +0 -0
- package/llamaBins/linux-arm64-19.node +0 -0
- package/llamaBins/linux-arm64-20.node +0 -0
- package/llamaBins/linux-armv7l-16.node +0 -0
- package/llamaBins/linux-armv7l-17.node +0 -0
- package/llamaBins/linux-armv7l-18.node +0 -0
- package/llamaBins/linux-armv7l-19.node +0 -0
- package/llamaBins/linux-armv7l-20.node +0 -0
- package/llamaBins/linux-ppc64le-16.node +0 -0
- package/llamaBins/linux-ppc64le-17.node +0 -0
- package/llamaBins/linux-ppc64le-18.node +0 -0
- package/llamaBins/linux-ppc64le-19.node +0 -0
- package/llamaBins/linux-ppc64le-20.node +0 -0
- package/llamaBins/linux-x64-16.node +0 -0
- package/llamaBins/linux-x64-17.node +0 -0
- package/llamaBins/linux-x64-18.node +0 -0
- package/llamaBins/linux-x64-19.node +0 -0
- package/llamaBins/linux-x64-20.node +0 -0
- package/llamaBins/mac-arm64-16.node +0 -0
- package/llamaBins/mac-arm64-17.node +0 -0
- package/llamaBins/mac-arm64-18.node +0 -0
- package/llamaBins/mac-arm64-19.node +0 -0
- package/llamaBins/mac-arm64-20.node +0 -0
- package/llamaBins/mac-x64-16.node +0 -0
- package/llamaBins/mac-x64-17.node +0 -0
- package/llamaBins/mac-x64-18.node +0 -0
- package/llamaBins/mac-x64-19.node +0 -0
- package/llamaBins/mac-x64-20.node +0 -0
- package/llamaBins/win-x64-16.node +0 -0
- package/llamaBins/win-x64-17.node +0 -0
- package/llamaBins/win-x64-18.node +0 -0
- package/llamaBins/win-x64-19.node +0 -0
- package/llamaBins/win-x64-20.node +0 -0
- package/package.json +10 -6
|
@@ -5,24 +5,29 @@ import withOra from "../../utils/withOra.js";
|
|
|
5
5
|
import { defaultChatSystemPrompt } from "../../config.js";
|
|
6
6
|
import { LlamaChatPromptWrapper } from "../../chatWrappers/LlamaChatPromptWrapper.js";
|
|
7
7
|
import { GeneralChatPromptWrapper } from "../../chatWrappers/GeneralChatPromptWrapper.js";
|
|
8
|
+
import { ChatMLPromptWrapper } from "../../chatWrappers/ChatMLPromptWrapper.js";
|
|
9
|
+
import { getChatWrapperByBos } from "../../chatWrappers/createChatWrapperByBos.js";
|
|
8
10
|
export const ChatCommand = {
|
|
9
11
|
command: "chat",
|
|
10
12
|
describe: "Chat with a LLama model",
|
|
11
13
|
builder(yargs) {
|
|
12
14
|
return yargs
|
|
13
15
|
.option("model", {
|
|
16
|
+
alias: "m",
|
|
14
17
|
type: "string",
|
|
15
18
|
demandOption: true,
|
|
16
19
|
description: "LLama model file to use for the chat",
|
|
17
20
|
group: "Required:"
|
|
18
21
|
})
|
|
19
22
|
.option("systemInfo", {
|
|
23
|
+
alias: "i",
|
|
20
24
|
type: "boolean",
|
|
21
25
|
default: false,
|
|
22
26
|
description: "Print llama.cpp system info",
|
|
23
27
|
group: "Optional:"
|
|
24
28
|
})
|
|
25
29
|
.option("systemPrompt", {
|
|
30
|
+
alias: "s",
|
|
26
31
|
type: "string",
|
|
27
32
|
default: defaultChatSystemPrompt,
|
|
28
33
|
defaultDescription: "",
|
|
@@ -31,22 +36,60 @@ export const ChatCommand = {
|
|
|
31
36
|
group: "Optional:"
|
|
32
37
|
})
|
|
33
38
|
.option("wrapper", {
|
|
39
|
+
alias: "w",
|
|
34
40
|
type: "string",
|
|
35
41
|
default: "general",
|
|
36
|
-
choices: ["general", "
|
|
37
|
-
description: "Chat wrapper to use",
|
|
42
|
+
choices: ["auto", "general", "llamaChat", "chatML"],
|
|
43
|
+
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token",
|
|
38
44
|
group: "Optional:"
|
|
39
45
|
})
|
|
40
46
|
.option("contextSize", {
|
|
47
|
+
alias: "c",
|
|
41
48
|
type: "number",
|
|
42
49
|
default: 1024 * 4,
|
|
43
50
|
description: "Context size to use for the model",
|
|
44
51
|
group: "Optional:"
|
|
52
|
+
})
|
|
53
|
+
.option("grammar", {
|
|
54
|
+
alias: "g",
|
|
55
|
+
type: "string",
|
|
56
|
+
default: "text",
|
|
57
|
+
choices: ["text", "json", "list", "arithmetic", "japanese", "chess"],
|
|
58
|
+
description: "Restrict the model response to a specific grammar, like JSON for example",
|
|
59
|
+
group: "Optional:"
|
|
60
|
+
})
|
|
61
|
+
.option("temperature", {
|
|
62
|
+
alias: "t",
|
|
63
|
+
type: "number",
|
|
64
|
+
default: 0,
|
|
65
|
+
description: "Temperature is a hyperparameter that controls the randomness of the generated text. It affects the probability distribution of the model's output tokens. A higher temperature (e.g., 1.5) makes the output more random and creative, while a lower temperature (e.g., 0.5) makes the output more focused, deterministic, and conservative. The suggested temperature is 0.8, which provides a balance between randomness and determinism. At the extreme, a temperature of 0 will always pick the most likely next token, leading to identical outputs in each run. Set to `0` to disable.",
|
|
66
|
+
group: "Optional:"
|
|
67
|
+
})
|
|
68
|
+
.option("topK", {
|
|
69
|
+
alias: "k",
|
|
70
|
+
type: "number",
|
|
71
|
+
default: 40,
|
|
72
|
+
description: "Limits the model to consider only the K most likely next tokens for sampling at each step of sequence generation. An integer number between `1` and the size of the vocabulary. Set to `0` to disable (which uses the full vocabulary). Only relevant when `temperature` is set to a value greater than 0.",
|
|
73
|
+
group: "Optional:"
|
|
74
|
+
})
|
|
75
|
+
.option("topP", {
|
|
76
|
+
alias: "p",
|
|
77
|
+
type: "number",
|
|
78
|
+
default: 0.95,
|
|
79
|
+
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`.",
|
|
80
|
+
group: "Optional:"
|
|
81
|
+
})
|
|
82
|
+
.option("maxTokens", {
|
|
83
|
+
alias: "mt",
|
|
84
|
+
type: "number",
|
|
85
|
+
default: 0,
|
|
86
|
+
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size",
|
|
87
|
+
group: "Optional:"
|
|
45
88
|
});
|
|
46
89
|
},
|
|
47
|
-
async handler({ model, systemInfo, systemPrompt, wrapper, contextSize }) {
|
|
90
|
+
async handler({ model, systemInfo, systemPrompt, wrapper, contextSize, grammar, temperature, topK, topP, maxTokens }) {
|
|
48
91
|
try {
|
|
49
|
-
await RunChat({ model, systemInfo, systemPrompt, wrapper, contextSize });
|
|
92
|
+
await RunChat({ model, systemInfo, systemPrompt, wrapper, contextSize, grammar, temperature, topK, topP, maxTokens });
|
|
50
93
|
}
|
|
51
94
|
catch (err) {
|
|
52
95
|
console.error(err);
|
|
@@ -54,21 +97,36 @@ export const ChatCommand = {
|
|
|
54
97
|
}
|
|
55
98
|
}
|
|
56
99
|
};
|
|
57
|
-
async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, contextSize }) {
|
|
100
|
+
async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, contextSize, grammar: grammarArg, temperature, topK, topP, maxTokens }) {
|
|
58
101
|
const { LlamaChatSession } = await import("../../llamaEvaluator/LlamaChatSession.js");
|
|
59
102
|
const { LlamaModel } = await import("../../llamaEvaluator/LlamaModel.js");
|
|
60
103
|
const { LlamaContext } = await import("../../llamaEvaluator/LlamaContext.js");
|
|
104
|
+
const { LlamaGrammar } = await import("../../llamaEvaluator/LlamaGrammar.js");
|
|
61
105
|
const model = new LlamaModel({
|
|
62
106
|
modelPath: modelArg,
|
|
63
|
-
contextSize
|
|
107
|
+
contextSize,
|
|
108
|
+
temperature,
|
|
109
|
+
topK,
|
|
110
|
+
topP
|
|
64
111
|
});
|
|
65
|
-
const context = new LlamaContext({
|
|
112
|
+
const context = new LlamaContext({
|
|
113
|
+
model,
|
|
114
|
+
grammar: grammarArg !== "text"
|
|
115
|
+
? await LlamaGrammar.getFor(grammarArg)
|
|
116
|
+
: undefined
|
|
117
|
+
});
|
|
118
|
+
const bos = context.getBosString(); // bos = beginning of sequence
|
|
119
|
+
const eos = context.getEosString(); // eos = end of sequence
|
|
120
|
+
const promptWrapper = getChatWrapper(wrapper, bos);
|
|
66
121
|
const session = new LlamaChatSession({
|
|
67
122
|
context,
|
|
68
123
|
printLLamaSystemInfo: systemInfo,
|
|
69
124
|
systemPrompt,
|
|
70
|
-
promptWrapper
|
|
125
|
+
promptWrapper
|
|
71
126
|
});
|
|
127
|
+
console.info(`${chalk.yellow("BOS:")} ${bos}`);
|
|
128
|
+
console.info(`${chalk.yellow("EOS:")} ${eos}`);
|
|
129
|
+
console.info(`${chalk.yellow("Chat wrapper:")} ${promptWrapper.wrapperName}`);
|
|
72
130
|
await withOra({
|
|
73
131
|
loading: chalk.blue("Loading model"),
|
|
74
132
|
success: chalk.blue("Model loaded"),
|
|
@@ -90,20 +148,37 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, wrapper, con
|
|
|
90
148
|
process.stdout.write(chalk.yellow("AI: "));
|
|
91
149
|
const [startColor, endColor] = chalk.blue("MIDDLE").split("MIDDLE");
|
|
92
150
|
process.stdout.write(startColor);
|
|
93
|
-
await session.prompt(input,
|
|
94
|
-
|
|
151
|
+
await session.prompt(input, {
|
|
152
|
+
maxTokens: maxTokens === -1
|
|
153
|
+
? context.getContextSize()
|
|
154
|
+
: maxTokens <= 0
|
|
155
|
+
? undefined
|
|
156
|
+
: maxTokens,
|
|
157
|
+
onToken(chunk) {
|
|
158
|
+
process.stdout.write(session.context.decode(Uint32Array.from(chunk)));
|
|
159
|
+
}
|
|
95
160
|
});
|
|
96
161
|
process.stdout.write(endColor);
|
|
97
162
|
console.log();
|
|
98
163
|
}
|
|
99
164
|
}
|
|
100
|
-
function
|
|
165
|
+
function getChatWrapper(wrapper, bos) {
|
|
101
166
|
switch (wrapper) {
|
|
102
167
|
case "general":
|
|
103
168
|
return new GeneralChatPromptWrapper();
|
|
104
|
-
case "
|
|
169
|
+
case "llamaChat":
|
|
105
170
|
return new LlamaChatPromptWrapper();
|
|
171
|
+
case "chatML":
|
|
172
|
+
return new ChatMLPromptWrapper();
|
|
173
|
+
default:
|
|
174
|
+
}
|
|
175
|
+
if (wrapper === "auto") {
|
|
176
|
+
const chatWrapper = getChatWrapperByBos(bos);
|
|
177
|
+
if (chatWrapper != null)
|
|
178
|
+
return new chatWrapper();
|
|
179
|
+
return new GeneralChatPromptWrapper();
|
|
106
180
|
}
|
|
181
|
+
void (wrapper);
|
|
107
182
|
throw new Error("Unknown wrapper: " + wrapper);
|
|
108
183
|
}
|
|
109
184
|
//# sourceMappingURL=ChatCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ChatCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,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;
|
|
1
|
+
{"version":3,"file":"ChatCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ChatCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,MAAM,O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;QACpB,MAAM,WAAW,GAAG,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"}
|
|
@@ -6,7 +6,7 @@ import { clearLlamaBuild } from "../../utils/clearLlamaBuild.js";
|
|
|
6
6
|
import { setUsedBinFlag } from "../../utils/usedBinFlag.js";
|
|
7
7
|
export const ClearCommand = {
|
|
8
8
|
command: "clear [type]",
|
|
9
|
-
describe: "Clear files created by llama-
|
|
9
|
+
describe: "Clear files created by node-llama-cpp",
|
|
10
10
|
builder(yargs) {
|
|
11
11
|
return yargs
|
|
12
12
|
.option("type", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClearCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ClearCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAM1D,MAAM,CAAC,MAAM,YAAY,GAAwC;IAC7D,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"ClearCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/ClearCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,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AAE,KAAK,IAAI,EAAE;YACV,MAAM,eAAe,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;KACN;IAED,MAAM,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -4,9 +4,11 @@ type DownloadCommandArgs = {
|
|
|
4
4
|
release: "latest" | string;
|
|
5
5
|
arch?: string;
|
|
6
6
|
nodeTarget?: string;
|
|
7
|
+
metal: boolean;
|
|
8
|
+
cuda: boolean;
|
|
7
9
|
skipBuild?: boolean;
|
|
8
10
|
updateBinariesReleaseMetadata?: boolean;
|
|
9
11
|
};
|
|
10
12
|
export declare const DownloadCommand: CommandModule<object, DownloadCommandArgs>;
|
|
11
|
-
export declare function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, skipBuild, updateBinariesReleaseMetadata }: DownloadCommandArgs): Promise<void>;
|
|
13
|
+
export declare function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadata }: DownloadCommandArgs): Promise<void>;
|
|
12
14
|
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import process from "process";
|
|
2
|
+
import path from "path";
|
|
2
3
|
import { Octokit } from "octokit";
|
|
3
|
-
import
|
|
4
|
+
import fs from "fs-extra";
|
|
4
5
|
import chalk from "chalk";
|
|
5
|
-
import { DownloaderHelper } from "node-downloader-helper";
|
|
6
6
|
import cliProgress from "cli-progress";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { defaultLlamaCppGitHubRepo, defaultLlamaCppRelease, llamaCppDirectory, tempDownloadDirectory } from "../../config.js";
|
|
7
|
+
import simpleGit from "simple-git";
|
|
8
|
+
import { defaultLlamaCppCudaSupport, defaultLlamaCppGitHubRepo, defaultLlamaCppMetalSupport, defaultLlamaCppRelease, llamaCppDirectory } from "../../config.js";
|
|
10
9
|
import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js";
|
|
11
10
|
import withOra from "../../utils/withOra.js";
|
|
12
11
|
import { clearTempFolder } from "../../utils/clearTempFolder.js";
|
|
@@ -27,14 +26,28 @@ export const DownloadCommand = {
|
|
|
27
26
|
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
27
|
})
|
|
29
28
|
.option("arch", {
|
|
29
|
+
alias: "a",
|
|
30
30
|
type: "string",
|
|
31
31
|
description: "The architecture to compile llama.cpp for"
|
|
32
32
|
})
|
|
33
33
|
.option("nodeTarget", {
|
|
34
|
+
alias: "t",
|
|
34
35
|
type: "string",
|
|
35
36
|
description: "The Node.js version to compile llama.cpp for. Example: v18.0.0"
|
|
37
|
+
})
|
|
38
|
+
.option("metal", {
|
|
39
|
+
type: "boolean",
|
|
40
|
+
default: defaultLlamaCppMetalSupport,
|
|
41
|
+
hidden: process.platform !== "darwin",
|
|
42
|
+
description: "Compile llama.cpp with Metal support. Can also be set via the NODE_LLAMA_CPP_METAL environment variable"
|
|
43
|
+
})
|
|
44
|
+
.option("cuda", {
|
|
45
|
+
type: "boolean",
|
|
46
|
+
default: defaultLlamaCppCudaSupport,
|
|
47
|
+
description: "Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP_CUDA environment variable"
|
|
36
48
|
})
|
|
37
49
|
.option("skipBuild", {
|
|
50
|
+
alias: "sb",
|
|
38
51
|
type: "boolean",
|
|
39
52
|
default: false,
|
|
40
53
|
description: "Skip building llama.cpp after downloading it"
|
|
@@ -48,14 +61,21 @@ export const DownloadCommand = {
|
|
|
48
61
|
},
|
|
49
62
|
handler: DownloadLlamaCppCommand
|
|
50
63
|
};
|
|
51
|
-
export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, skipBuild, updateBinariesReleaseMetadata }) {
|
|
64
|
+
export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget, metal, cuda, skipBuild, updateBinariesReleaseMetadata }) {
|
|
52
65
|
const octokit = new Octokit();
|
|
53
66
|
const [githubOwner, githubRepo] = repo.split("/");
|
|
54
67
|
console.log(`${chalk.yellow("Repo:")} ${repo}`);
|
|
55
68
|
console.log(`${chalk.yellow("Release:")} ${release}`);
|
|
69
|
+
if (!skipBuild) {
|
|
70
|
+
if (metal && process.platform === "darwin") {
|
|
71
|
+
console.log(`${chalk.yellow("Metal:")} enabled`);
|
|
72
|
+
}
|
|
73
|
+
if (cuda) {
|
|
74
|
+
console.log(`${chalk.yellow("CUDA:")} enabled`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
56
77
|
console.log();
|
|
57
78
|
let githubRelease = null;
|
|
58
|
-
let zipUrl;
|
|
59
79
|
await withOra({
|
|
60
80
|
loading: chalk.blue("Fetching llama.cpp info"),
|
|
61
81
|
success: chalk.blue("Fetched llama.cpp info"),
|
|
@@ -82,22 +102,11 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
82
102
|
if (githubRelease == null) {
|
|
83
103
|
throw new Error(`Failed to find release "${release}" of "${repo}"`);
|
|
84
104
|
}
|
|
85
|
-
if (githubRelease.data
|
|
86
|
-
throw new Error(`Failed to find
|
|
105
|
+
if (githubRelease.data.tag_name == null) {
|
|
106
|
+
throw new Error(`Failed to find tag of release "${release}" of "${repo}"`);
|
|
87
107
|
}
|
|
88
|
-
const zipUrlResponse = await octokit.rest.repos.downloadZipballArchive({
|
|
89
|
-
owner: githubOwner,
|
|
90
|
-
repo: githubRepo,
|
|
91
|
-
ref: githubRelease.data.target_commitish
|
|
92
|
-
});
|
|
93
|
-
if (zipUrlResponse.url == null)
|
|
94
|
-
throw new Error(`Failed to get zip archive url for release "${release}" of "${repo}"`);
|
|
95
|
-
zipUrl = zipUrlResponse.url;
|
|
96
108
|
});
|
|
97
109
|
await clearTempFolder();
|
|
98
|
-
console.log(chalk.blue("Downloading zip file"));
|
|
99
|
-
await fs.ensureDir(tempDownloadDirectory);
|
|
100
|
-
await downloadFile(zipUrl, "llama.cpp.zip", tempDownloadDirectory);
|
|
101
110
|
await withOra({
|
|
102
111
|
loading: chalk.blue("Removing existing llama.cpp directory"),
|
|
103
112
|
success: chalk.blue("Removed existing llama.cpp directory"),
|
|
@@ -105,26 +114,29 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
105
114
|
}, async () => {
|
|
106
115
|
await fs.remove(llamaCppDirectory);
|
|
107
116
|
});
|
|
117
|
+
console.log(chalk.blue("Cloning llama.cpp"));
|
|
118
|
+
await cloneTag(githubOwner, githubRepo, githubRelease.data.tag_name, llamaCppDirectory);
|
|
108
119
|
await withOra({
|
|
109
|
-
loading: chalk.blue("
|
|
110
|
-
success: chalk.blue("
|
|
111
|
-
fail: chalk.blue("Failed to
|
|
120
|
+
loading: chalk.blue("Generating required files"),
|
|
121
|
+
success: chalk.blue("Generated required files"),
|
|
122
|
+
fail: chalk.blue("Failed to generate required files")
|
|
112
123
|
}, async () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await clearTempFolder();
|
|
124
|
+
const buildInfoTemplateFilePath = path.join(llamaCppDirectory, "scripts", "build-info.h.in");
|
|
125
|
+
const buildInfoResultFilePath = path.join(llamaCppDirectory, "build-info.h");
|
|
126
|
+
const buildInfoTemplateFile = await fs.readFile(buildInfoTemplateFilePath, "utf8");
|
|
127
|
+
const finalFile = buildInfoTemplateFile
|
|
128
|
+
.replaceAll("@BUILD_NUMBER@", "1")
|
|
129
|
+
.replaceAll("@BUILD_COMMIT@", githubRelease.data.tag_name);
|
|
130
|
+
await fs.writeFile(buildInfoResultFilePath, finalFile, "utf8");
|
|
121
131
|
});
|
|
122
132
|
if (!skipBuild) {
|
|
123
133
|
console.log(chalk.blue("Compiling llama.cpp"));
|
|
124
134
|
await compileLlamaCpp({
|
|
125
135
|
arch: arch ? arch : undefined,
|
|
126
136
|
nodeTarget: nodeTarget ? nodeTarget : undefined,
|
|
127
|
-
setUsedBingFlag: true
|
|
137
|
+
setUsedBingFlag: true,
|
|
138
|
+
metal,
|
|
139
|
+
cuda
|
|
128
140
|
});
|
|
129
141
|
}
|
|
130
142
|
if (updateBinariesReleaseMetadata) {
|
|
@@ -137,53 +149,32 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
137
149
|
console.log();
|
|
138
150
|
console.log(chalk.green("Done"));
|
|
139
151
|
}
|
|
140
|
-
async function
|
|
141
|
-
const download = new DownloaderHelper(url, directory, {
|
|
142
|
-
fileName: fileName,
|
|
143
|
-
retry: {
|
|
144
|
-
maxRetries: 10,
|
|
145
|
-
delay: 1000 * 6
|
|
146
|
-
}
|
|
147
|
-
});
|
|
152
|
+
async function cloneTag(githubOwner, githubRepo, tag, directory) {
|
|
148
153
|
const progressBar = new cliProgress.Bar({
|
|
149
154
|
clearOnComplete: false,
|
|
150
155
|
hideCursor: true,
|
|
151
156
|
autopadding: true,
|
|
152
|
-
format: `${chalk.bold("{
|
|
157
|
+
format: `${chalk.bold("Clone {repo}")} ${chalk.yellow("{percentage}%")} ${chalk.cyan("{bar}")} ${chalk.grey("{eta_formatted}")}`
|
|
153
158
|
}, cliProgress.Presets.shades_classic);
|
|
154
159
|
progressBar.start(100, 0, {
|
|
155
160
|
speed: "",
|
|
156
|
-
|
|
161
|
+
repo: `${githubOwner}/${githubRepo}`
|
|
157
162
|
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
try {
|
|
164
|
+
await simpleGit({
|
|
165
|
+
progress({ progress, total, processed }) {
|
|
166
|
+
const totalProgress = (processed / 100) + (progress / total);
|
|
167
|
+
progressBar.update(Math.floor(totalProgress * 10000) / 100);
|
|
168
|
+
}
|
|
169
|
+
}).clone(`https://github.com/${githubOwner}/${githubRepo}.git`, directory, {
|
|
170
|
+
"--depth": 1,
|
|
171
|
+
"--branch": tag,
|
|
172
|
+
"--quiet": null
|
|
161
173
|
});
|
|
162
|
-
}
|
|
163
|
-
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
164
176
|
progressBar.update(100);
|
|
165
177
|
progressBar.stop();
|
|
166
|
-
});
|
|
167
|
-
// errors are handled by the .start() method
|
|
168
|
-
// this listener is here to not get an unhandled error exception
|
|
169
|
-
download.on("error", () => { });
|
|
170
|
-
await download.start();
|
|
171
|
-
}
|
|
172
|
-
async function unzipLlamaReleaseZipFile(zipFilePath, directory) {
|
|
173
|
-
const zip = new StreamZip.async({ file: zipFilePath });
|
|
174
|
-
const entires = await zip.entries();
|
|
175
|
-
const rootFolderEntries = new Map();
|
|
176
|
-
for (const entry of Object.values(entires)) {
|
|
177
|
-
const entryPath = entry.name.split("/");
|
|
178
|
-
const rootFolderName = entryPath[0];
|
|
179
|
-
const rootFolderEntryCount = rootFolderEntries.get(rootFolderName) ?? 0;
|
|
180
|
-
rootFolderEntries.set(rootFolderName, rootFolderEntryCount + 1);
|
|
181
178
|
}
|
|
182
|
-
const mostUsedRootFolderName = [...rootFolderEntries.keys()]
|
|
183
|
-
.sort((a, b) => rootFolderEntries.get(b) - rootFolderEntries.get(a))
|
|
184
|
-
.shift();
|
|
185
|
-
if (mostUsedRootFolderName == null)
|
|
186
|
-
throw new Error("Failed to find the root folder of the llama.cpp release zip file");
|
|
187
|
-
await zip.extract(mostUsedRootFolderName, directory);
|
|
188
179
|
}
|
|
189
180
|
//# sourceMappingURL=DownloadCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/DownloadCommand.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"DownloadCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/DownloadCommand.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAA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AK,EAAE,EAAE;QACT,IAAI,EAAE,GAAG,WAAW,IAAI,UAAU,EAAE;KACvC,CAAC,CAAC;IAEH,IAAI;QACA,MAAM,SAAS,CAAC;YACZ,QAAQ,CAAC,EAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAC;gBACjC,MAAM,aAAa,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC;gBAE7D,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;YAChE,CAAC;SACJ,CAAC,CAAC,KAAK,CAAC,sBAAsB,WAAW,IAAI,UAAU,MAAM,EAAE,SAAS,EAAE;YACvE,SAAS,EAAE,CAAC;YACZ,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;KACN;YAAS;QACN,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxB,WAAW,CAAC,IAAI,EAAE,CAAC;KACtB;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultLlamaCppGitHubRepo, defaultLlamaCppRelease, defaultSkipDownload } from "../../config.js";
|
|
1
|
+
import { defaultLlamaCppCudaSupport, defaultLlamaCppGitHubRepo, defaultLlamaCppMetalSupport, defaultLlamaCppRelease, defaultSkipDownload } from "../../config.js";
|
|
2
2
|
import { getPrebuildBinPath } from "../../utils/getBin.js";
|
|
3
3
|
import { DownloadLlamaCppCommand } from "./DownloadCommand.js";
|
|
4
4
|
export const OnPostInstallCommand = {
|
|
@@ -12,7 +12,9 @@ export const OnPostInstallCommand = {
|
|
|
12
12
|
try {
|
|
13
13
|
await DownloadLlamaCppCommand({
|
|
14
14
|
repo: defaultLlamaCppGitHubRepo,
|
|
15
|
-
release: defaultLlamaCppRelease
|
|
15
|
+
release: defaultLlamaCppRelease,
|
|
16
|
+
metal: defaultLlamaCppMetalSupport,
|
|
17
|
+
cuda: defaultLlamaCppCudaSupport
|
|
16
18
|
});
|
|
17
19
|
}
|
|
18
20
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnPostInstallCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/OnPostInstallCommand.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"OnPostInstallCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/OnPostInstallCommand.ts"],"names":[],"mappings":"AACA,OAAO,EACH,0BAA0B,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,mBAAmB,EAClI,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,uBAAuB,EAAC,MAAM,sBAAsB,CAAC;AAI7D,MAAM,CAAC,MAAM,oBAAoB,GAAgD;IAC7E,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,KAAK;IACf,KAAK,CAAC,OAAO;QACT,IAAI,mBAAmB;YACnB,OAAO;QAEX,IAAI,MAAM,kBAAkB,EAAE,IAAI,IAAI;YAClC,OAAO;QAEX,IAAI;YACA,MAAM,uBAAuB,CAAC;gBAC1B,IAAI,EAAE,yBAAyB;gBAC/B,OAAO,EAAE,sBAAsB;gBAC/B,KAAK,EAAE,2BAA2B;gBAClC,IAAI,EAAE,0BAA0B;aACnC,CAAC,CAAC;SACN;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;IACL,CAAC;CACJ,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export declare const llamaDirectory: string;
|
|
2
2
|
export declare const llamaBinsDirectory: string;
|
|
3
|
+
export declare const llamaBinsGrammarsDirectory: string;
|
|
3
4
|
export declare const llamaCppDirectory: string;
|
|
5
|
+
export declare const llamaCppGrammarsDirectory: string;
|
|
4
6
|
export declare const tempDownloadDirectory: string;
|
|
5
7
|
export declare const usedBinFlagJsonPath: string;
|
|
6
8
|
export declare const binariesGithubReleasePath: string;
|
|
7
9
|
export declare const defaultLlamaCppGitHubRepo: string;
|
|
8
10
|
export declare const defaultLlamaCppRelease: string;
|
|
11
|
+
export declare const defaultLlamaCppMetalSupport: boolean;
|
|
12
|
+
export declare const defaultLlamaCppCudaSupport: boolean;
|
|
9
13
|
export declare const defaultSkipDownload: boolean;
|
|
10
14
|
export declare const defaultChatSystemPrompt: string;
|
package/dist/config.js
CHANGED
|
@@ -8,7 +8,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
8
8
|
const env = envVar.from(process.env);
|
|
9
9
|
export const llamaDirectory = path.join(__dirname, "..", "llama");
|
|
10
10
|
export const llamaBinsDirectory = path.join(__dirname, "..", "llamaBins");
|
|
11
|
+
export const llamaBinsGrammarsDirectory = path.join(__dirname, "..", "llama", "grammars");
|
|
11
12
|
export const llamaCppDirectory = path.join(llamaDirectory, "llama.cpp");
|
|
13
|
+
export const llamaCppGrammarsDirectory = path.join(llamaDirectory, "llama.cpp", "grammars");
|
|
12
14
|
export const tempDownloadDirectory = path.join(os.tmpdir(), "node-llama-cpp", uuid.v4());
|
|
13
15
|
export const usedBinFlagJsonPath = path.join(llamaDirectory, "usedBin.json");
|
|
14
16
|
export const binariesGithubReleasePath = path.join(llamaDirectory, "binariesGithubRelease.json");
|
|
@@ -18,6 +20,12 @@ export const defaultLlamaCppGitHubRepo = env.get("NODE_LLAMA_CPP_REPO")
|
|
|
18
20
|
export const defaultLlamaCppRelease = env.get("NODE_LLAMA_CPP_REPO_RELEASE")
|
|
19
21
|
.default(await getBinariesGithubRelease())
|
|
20
22
|
.asString();
|
|
23
|
+
export const defaultLlamaCppMetalSupport = env.get("NODE_LLAMA_CPP_METAL")
|
|
24
|
+
.default("false")
|
|
25
|
+
.asBool();
|
|
26
|
+
export const defaultLlamaCppCudaSupport = env.get("NODE_LLAMA_CPP_CUDA")
|
|
27
|
+
.default("false")
|
|
28
|
+
.asBool();
|
|
21
29
|
export const defaultSkipDownload = env.get("NODE_LLAMA_CPP_SKIP_DOWNLOAD")
|
|
22
30
|
.default("false")
|
|
23
31
|
.asBool();
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,wBAAwB,EAAC,MAAM,kCAAkC,CAAC;AAE1E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAGrC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC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,MAAM,EAAE,CAAC;AACd,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC;KACnE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,EAAE,CAAC;AACd,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC,GAAG,CAAC,8BAA8B,CAAC;KACrE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,EAAE,CAAC;AACd,MAAM,CAAC,MAAM,uBAAuB,GAAG,+FAA+F;IAClI,+HAA+H;IAC/H,mFAAmF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LlamaGrammar } from "llamaEvaluator/LlamaGrammar.js";
|
|
1
2
|
import { LlamaChatSession } from "./llamaEvaluator/LlamaChatSession.js";
|
|
2
3
|
import { LlamaModel } from "./llamaEvaluator/LlamaModel.js";
|
|
3
4
|
import { AbortError } from "./AbortError.js";
|
|
@@ -6,4 +7,7 @@ import { EmptyChatPromptWrapper } from "./chatWrappers/EmptyChatPromptWrapper.js
|
|
|
6
7
|
import { LlamaChatPromptWrapper } from "./chatWrappers/LlamaChatPromptWrapper.js";
|
|
7
8
|
import { GeneralChatPromptWrapper } from "./chatWrappers/GeneralChatPromptWrapper.js";
|
|
8
9
|
import { LlamaContext } from "./llamaEvaluator/LlamaContext.js";
|
|
9
|
-
|
|
10
|
+
import { ChatMLPromptWrapper } from "./chatWrappers/ChatMLPromptWrapper.js";
|
|
11
|
+
import { getChatWrapperByBos } from "./chatWrappers/createChatWrapperByBos.js";
|
|
12
|
+
import { type Token } from "./types.js";
|
|
13
|
+
export { LlamaModel, LlamaGrammar, LlamaContext, LlamaChatSession, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper, ChatMLPromptWrapper, getChatWrapperByBos, type Token };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LlamaGrammar } from "llamaEvaluator/LlamaGrammar.js";
|
|
1
2
|
import { LlamaChatSession } from "./llamaEvaluator/LlamaChatSession.js";
|
|
2
3
|
import { LlamaModel } from "./llamaEvaluator/LlamaModel.js";
|
|
3
4
|
import { AbortError } from "./AbortError.js";
|
|
@@ -6,5 +7,7 @@ import { EmptyChatPromptWrapper } from "./chatWrappers/EmptyChatPromptWrapper.js
|
|
|
6
7
|
import { LlamaChatPromptWrapper } from "./chatWrappers/LlamaChatPromptWrapper.js";
|
|
7
8
|
import { GeneralChatPromptWrapper } from "./chatWrappers/GeneralChatPromptWrapper.js";
|
|
8
9
|
import { LlamaContext } from "./llamaEvaluator/LlamaContext.js";
|
|
9
|
-
|
|
10
|
+
import { ChatMLPromptWrapper } from "./chatWrappers/ChatMLPromptWrapper.js";
|
|
11
|
+
import { getChatWrapperByBos } from "./chatWrappers/createChatWrapperByBos.js";
|
|
12
|
+
export { LlamaModel, LlamaGrammar, LlamaContext, LlamaChatSession, AbortError, ChatPromptWrapper, EmptyChatPromptWrapper, LlamaChatPromptWrapper, GeneralChatPromptWrapper, ChatMLPromptWrapper, getChatWrapperByBos };
|
|
10
13
|
//# 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,gBAAgB,EAAC,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAC;AAC1D,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,YAAY,EAAC,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAC;AAC1D,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,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAC,mBAAmB,EAAC,MAAM,0CAA0C,CAAC;AAK7E,OAAO,EACH,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EAEtB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type LLAMAModel, type LLAMAContext } from "../utils/getBin.js";
|
|
1
|
+
import { type LLAMAModel, type LLAMAContext, type LLAMAGrammar } from "../utils/getBin.js";
|
|
2
2
|
export declare const llamaCppNode: import("../utils/getBin.js").LlamaCppNodeModule;
|
|
3
|
-
declare const LLAMAModel: LLAMAModel, LLAMAContext: LLAMAContext;
|
|
4
|
-
export { LLAMAModel, LLAMAContext };
|
|
3
|
+
declare const LLAMAModel: LLAMAModel, LLAMAContext: LLAMAContext, LLAMAGrammar: LLAMAGrammar;
|
|
4
|
+
export { LLAMAModel, LLAMAContext, LLAMAGrammar };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadBin } from "../utils/getBin.js";
|
|
2
2
|
export const llamaCppNode = await loadBin();
|
|
3
|
-
const { LLAMAModel, LLAMAContext } = llamaCppNode;
|
|
4
|
-
export { LLAMAModel, LLAMAContext };
|
|
3
|
+
const { LLAMAModel, LLAMAContext, LLAMAGrammar } = llamaCppNode;
|
|
4
|
+
export { LLAMAModel, LLAMAContext, LLAMAGrammar };
|
|
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,EAAwD,MAAM,oBAAoB,CAAC;AAElG,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,OAAO,EAAE,CAAC;AAC5C,MAAM,EAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAC,GAAG,YAAY,CAAC;AAE9D,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,YAAY,EAAC,CAAC"}
|