node-llama-cpp 2.3.2 → 2.4.0
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 +29 -23
- package/dist/cli/commands/BuildCommand.js +5 -2
- package/dist/cli/commands/BuildCommand.js.map +1 -1
- package/dist/cli/commands/ChatCommand.js +2 -2
- package/dist/cli/commands/ClearCommand.d.ts +1 -1
- package/dist/cli/commands/ClearCommand.js +13 -1
- package/dist/cli/commands/ClearCommand.js.map +1 -1
- package/dist/cli/commands/DownloadCommand.js +16 -22
- package/dist/cli/commands/DownloadCommand.js.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.js +13 -1
- package/dist/config.js.map +1 -1
- package/dist/llamaEvaluator/LlamaModel.js +3 -1
- package/dist/llamaEvaluator/LlamaModel.js.map +1 -1
- package/dist/utils/cmake.d.ts +10 -0
- package/dist/utils/cmake.js +80 -0
- package/dist/utils/cmake.js.map +1 -0
- package/dist/utils/compileLLamaCpp.js +59 -31
- package/dist/utils/compileLLamaCpp.js.map +1 -1
- package/dist/utils/getBin.js +1 -1
- package/dist/utils/getBin.js.map +1 -1
- package/dist/utils/withStatusLogs.d.ts +5 -0
- package/dist/utils/withStatusLogs.js +22 -0
- package/dist/utils/withStatusLogs.js.map +1 -0
- package/llama/CMakeLists.txt +36 -0
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/grammars/json_arr.gbnf +34 -0
- package/llama/xpack/package.json +10 -0
- package/llamaBins/linux-arm64-16/llama-addon.node +0 -0
- package/llamaBins/linux-arm64-17/llama-addon.node +0 -0
- package/llamaBins/linux-arm64-18/llama-addon.node +0 -0
- package/llamaBins/linux-arm64-19/llama-addon.node +0 -0
- package/llamaBins/linux-arm64-20/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l-16/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l-17/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l-18/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l-19/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l-20/llama-addon.node +0 -0
- package/llamaBins/linux-ppc64le-16/llama-addon.node +0 -0
- package/llamaBins/linux-ppc64le-17/llama-addon.node +0 -0
- package/llamaBins/linux-ppc64le-18/llama-addon.node +0 -0
- package/llamaBins/linux-ppc64le-19/llama-addon.node +0 -0
- package/llamaBins/linux-ppc64le-20/llama-addon.node +0 -0
- package/llamaBins/linux-x64-16/llama-addon.node +0 -0
- package/llamaBins/linux-x64-17/llama-addon.node +0 -0
- package/llamaBins/linux-x64-18/llama-addon.node +0 -0
- package/llamaBins/linux-x64-19/llama-addon.node +0 -0
- package/llamaBins/linux-x64-20/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-16/ggml-metal.metal +2120 -0
- package/llamaBins/mac-arm64-16/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-17/ggml-metal.metal +2120 -0
- package/llamaBins/mac-arm64-17/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-18/ggml-metal.metal +2120 -0
- package/llamaBins/mac-arm64-18/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-19/ggml-metal.metal +2120 -0
- package/llamaBins/mac-arm64-19/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-20/ggml-metal.metal +2120 -0
- package/llamaBins/mac-arm64-20/llama-addon.node +0 -0
- package/llamaBins/mac-x64-16/ggml-metal.metal +2120 -0
- package/llamaBins/mac-x64-16/llama-addon.node +0 -0
- package/llamaBins/mac-x64-17/ggml-metal.metal +2120 -0
- package/llamaBins/mac-x64-17/llama-addon.node +0 -0
- package/llamaBins/mac-x64-18/ggml-metal.metal +2120 -0
- package/llamaBins/mac-x64-18/llama-addon.node +0 -0
- package/llamaBins/mac-x64-19/ggml-metal.metal +2120 -0
- package/llamaBins/mac-x64-19/llama-addon.node +0 -0
- package/llamaBins/mac-x64-20/ggml-metal.metal +2120 -0
- package/llamaBins/mac-x64-20/llama-addon.node +0 -0
- package/llamaBins/win-x64-16/llama-addon.node +0 -0
- package/llamaBins/win-x64-17/llama-addon.exp +0 -0
- package/llamaBins/win-x64-17/llama-addon.lib +0 -0
- package/llamaBins/win-x64-17/llama-addon.node +0 -0
- package/llamaBins/win-x64-18/llama-addon.exp +0 -0
- package/llamaBins/win-x64-18/llama-addon.lib +0 -0
- package/llamaBins/win-x64-18/llama-addon.node +0 -0
- package/llamaBins/win-x64-19/llama-addon.exp +0 -0
- package/llamaBins/win-x64-19/llama-addon.lib +0 -0
- package/llamaBins/win-x64-19/llama-addon.node +0 -0
- package/llamaBins/win-x64-20/llama-addon.exp +0 -0
- package/llamaBins/win-x64-20/llama-addon.lib +0 -0
- package/llamaBins/win-x64-20/llama-addon.node +0 -0
- package/package.json +11 -7
- package/llama/binding.gyp +0 -27
- 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/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img alt="node-llama-cpp Logo" src="https://media.githubusercontent.com/media/withcatai/node-llama-cpp/master/assets/logo.roundEdges.png" width="360px" />
|
|
3
3
|
<h1>Node Llama.cpp</h1>
|
|
4
4
|
<p>Node.js bindings for llama.cpp</p>
|
|
5
|
-
<sub>Pre-built bindings are provided with a fallback to building from source with
|
|
5
|
+
<sub>Pre-built bindings are provided with a fallback to building from source with cmake</sub>
|
|
6
6
|
<p></p>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ npm install --save node-llama-cpp
|
|
|
22
22
|
|
|
23
23
|
This package comes with pre-built binaries for macOS, Linux and Windows.
|
|
24
24
|
|
|
25
|
-
If binaries are not available for your platform, it'll fallback to download the latest version of `llama.cpp` and build it from source with `
|
|
25
|
+
If binaries are not available for your platform, it'll fallback to download the latest version of `llama.cpp` and build it from source with `cmake`.
|
|
26
26
|
To disable this behavior set the environment variable `NODE_LLAMA_CPP_SKIP_DOWNLOAD` to `true`.
|
|
27
27
|
|
|
28
28
|
## Documentation
|
|
@@ -81,11 +81,13 @@ export class MyCustomChatPromptWrapper extends ChatPromptWrapper {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const model = new LlamaModel({
|
|
84
|
-
modelPath: path.join(__dirname, "models", "codellama-13b.Q3_K_M.gguf")
|
|
85
|
-
promptWrapper: new MyCustomChatPromptWrapper() // by default, LlamaChatPromptWrapper is used
|
|
84
|
+
modelPath: path.join(__dirname, "models", "codellama-13b.Q3_K_M.gguf")
|
|
86
85
|
})
|
|
87
86
|
const context = new LlamaContext({model});
|
|
88
|
-
const session = new LlamaChatSession({
|
|
87
|
+
const session = new LlamaChatSession({
|
|
88
|
+
context,
|
|
89
|
+
promptWrapper: new MyCustomChatPromptWrapper() // by default, GeneralChatPromptWrapper is used
|
|
90
|
+
});
|
|
89
91
|
|
|
90
92
|
|
|
91
93
|
const q1 = "Hi there, how are you?";
|
|
@@ -170,7 +172,7 @@ console.log("AI: " + a1);
|
|
|
170
172
|
console.log(JSON.parse(a1));
|
|
171
173
|
|
|
172
174
|
|
|
173
|
-
const q2 = 'Add another field to the JSON with the key being "author" and the value being "
|
|
175
|
+
const q2 = 'Add another field to the JSON with the key being "author" and the value being "Llama"';
|
|
174
176
|
console.log("User: " + q2);
|
|
175
177
|
|
|
176
178
|
const a2 = await session.prompt(q2, {maxTokens: context.getContextSize()});
|
|
@@ -179,21 +181,19 @@ console.log(JSON.parse(a2));
|
|
|
179
181
|
```
|
|
180
182
|
|
|
181
183
|
### Metal and CUDA support
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
**Metal:** `llama.cpp` is built with Metal support by default on macOS.
|
|
185
|
+
|
|
186
|
+
**CUDA:** To load a version of `llama.cpp` that was compiled to use CUDA,
|
|
187
|
+
you have to build it from source with the `--cuda` flag before running your code that imports `node-llama-cpp`.
|
|
184
188
|
|
|
185
189
|
To do this, run this command inside of your project directory:
|
|
186
190
|
```bash
|
|
187
|
-
# For Metal support on macOS
|
|
188
|
-
npx node-llama-cpp download --metal
|
|
189
|
-
|
|
190
|
-
# For CUDA support
|
|
191
191
|
npx node-llama-cpp download --cuda
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
>
|
|
194
|
+
> If `cmake` is not installed on your machine, `node-llama-cpp` will automatically download `cmake` to an internal directory and try to use it to build `llama.cpp` from source.
|
|
195
195
|
>
|
|
196
|
-
> More info is available [here](https://github.com/
|
|
196
|
+
> If the build fails, make sure you have the required dependencies of `cmake` installed on your machine. More info is available [here](https://github.com/cmake-js/cmake-js#installation:~:text=projectRoot/build%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5Bstring%5D-,Requirements%3A,-CMake) (you don't have to install `cmake` or `cmake-js`, just the dependencies).
|
|
197
197
|
|
|
198
198
|
### CLI
|
|
199
199
|
```
|
|
@@ -202,8 +202,8 @@ Usage: node-llama-cpp <command> [options]
|
|
|
202
202
|
Commands:
|
|
203
203
|
node-llama-cpp download Download a release of llama.cpp and compile it
|
|
204
204
|
node-llama-cpp build Compile the currently downloaded llama.cpp
|
|
205
|
-
node-llama-cpp clear [type] Clear files created by node-llama-cpp
|
|
206
|
-
node-llama-cpp chat Chat with a
|
|
205
|
+
node-llama-cpp clear [type] Clear files created by node-llama-cpp [aliases: clean]
|
|
206
|
+
node-llama-cpp chat Chat with a Llama model
|
|
207
207
|
|
|
208
208
|
Options:
|
|
209
209
|
-h, --help Show help [boolean]
|
|
@@ -226,8 +226,9 @@ Options:
|
|
|
226
226
|
ronment variable [string] [default: "latest"]
|
|
227
227
|
-a, --arch The architecture to compile llama.cpp for [string]
|
|
228
228
|
-t, --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
|
|
229
|
-
--metal Compile llama.cpp with Metal support.
|
|
230
|
-
|
|
229
|
+
--metal Compile llama.cpp with Metal support. Enabled by default on macOS. Can be d
|
|
230
|
+
isabled with "--no-metal". Can also be set via the NODE_LLAMA_CPP_METAL env
|
|
231
|
+
ironment variable [boolean] [default: true]
|
|
231
232
|
--cuda Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP
|
|
232
233
|
_CUDA environment variable [boolean] [default: false]
|
|
233
234
|
--skipBuild, --sb Skip building llama.cpp after downloading it [boolean] [default: false]
|
|
@@ -244,13 +245,17 @@ Options:
|
|
|
244
245
|
-h, --help Show help [boolean]
|
|
245
246
|
-a, --arch The architecture to compile llama.cpp for [string]
|
|
246
247
|
-t, --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
|
|
247
|
-
--metal Compile llama.cpp with Metal support.
|
|
248
|
-
|
|
248
|
+
--metal Compile llama.cpp with Metal support. Enabled by default on macOS. Can be disabl
|
|
249
|
+
ed with "--no-metal". Can also be set via the NODE_LLAMA_CPP_METAL environment v
|
|
250
|
+
ariable [boolean] [default: true]
|
|
249
251
|
--cuda Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP_CUDA
|
|
250
252
|
environment variable [boolean] [default: false]
|
|
251
253
|
-v, --version Show version number [boolean]
|
|
252
254
|
```
|
|
253
255
|
|
|
256
|
+
> To set custom cmake options that are supported by `llama.cpp`'s cmake build,
|
|
257
|
+
> set an environment variable of the option prefixed with `NODE_LLAMA_CPP_CMAKE_OPTION_`.
|
|
258
|
+
|
|
254
259
|
#### `clear` command
|
|
255
260
|
```
|
|
256
261
|
node-llama-cpp clear [type]
|
|
@@ -259,7 +264,8 @@ Clear files created by node-llama-cpp
|
|
|
259
264
|
|
|
260
265
|
Options:
|
|
261
266
|
-h, --help Show help [boolean]
|
|
262
|
-
--type Files to clear
|
|
267
|
+
--type Files to clear
|
|
268
|
+
[string] [choices: "source", "build", "cmake", "all"] [default: "all"]
|
|
263
269
|
-v, --version Show version number [boolean]
|
|
264
270
|
```
|
|
265
271
|
|
|
@@ -267,10 +273,10 @@ Options:
|
|
|
267
273
|
```
|
|
268
274
|
node-llama-cpp chat
|
|
269
275
|
|
|
270
|
-
Chat with a
|
|
276
|
+
Chat with a Llama model
|
|
271
277
|
|
|
272
278
|
Required:
|
|
273
|
-
-m, --model
|
|
279
|
+
-m, --model Llama model file to use for the chat [string] [required]
|
|
274
280
|
|
|
275
281
|
Optional:
|
|
276
282
|
-i, --systemInfo Print llama.cpp system info [boolean] [default: false]
|
|
@@ -5,6 +5,8 @@ import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js";
|
|
|
5
5
|
import withOra from "../../utils/withOra.js";
|
|
6
6
|
import { clearTempFolder } from "../../utils/clearTempFolder.js";
|
|
7
7
|
import { defaultLlamaCppCudaSupport, defaultLlamaCppMetalSupport, llamaCppDirectory } from "../../config.js";
|
|
8
|
+
import { downloadCmakeIfNeeded } from "../../utils/cmake.js";
|
|
9
|
+
import withStatusLogs from "../../utils/withStatusLogs.js";
|
|
8
10
|
export const BuildCommand = {
|
|
9
11
|
command: "build",
|
|
10
12
|
describe: "Compile the currently downloaded llama.cpp",
|
|
@@ -23,7 +25,7 @@ export const BuildCommand = {
|
|
|
23
25
|
.option("metal", {
|
|
24
26
|
type: "boolean",
|
|
25
27
|
default: defaultLlamaCppMetalSupport,
|
|
26
|
-
description: "Compile llama.cpp with Metal support. Can also be set via the NODE_LLAMA_CPP_METAL environment variable"
|
|
28
|
+
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"
|
|
27
29
|
})
|
|
28
30
|
.option("cuda", {
|
|
29
31
|
type: "boolean",
|
|
@@ -44,7 +46,8 @@ export async function BuildLlamaCppCommand({ arch, nodeTarget, metal, cuda }) {
|
|
|
44
46
|
if (cuda) {
|
|
45
47
|
console.log(`${chalk.yellow("CUDA:")} enabled`);
|
|
46
48
|
}
|
|
47
|
-
await
|
|
49
|
+
await downloadCmakeIfNeeded(true);
|
|
50
|
+
await withStatusLogs({
|
|
48
51
|
loading: chalk.blue("Compiling llama.cpp"),
|
|
49
52
|
success: chalk.blue("Compiled llama.cpp"),
|
|
50
53
|
fail: chalk.blue("Failed to compile llama.cpp")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/BuildCommand.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;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YACL,IAAI;SACP,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC;QACV,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC;QAC/C,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC;QAC9C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,kCAAkC,CAAC;KACvD,EAAE,KAAK,IAAI,EAAE;QACV,MAAM,eAAe,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -9,14 +9,14 @@ import { ChatMLPromptWrapper } from "../../chatWrappers/ChatMLPromptWrapper.js";
|
|
|
9
9
|
import { getChatWrapperByBos } from "../../chatWrappers/createChatWrapperByBos.js";
|
|
10
10
|
export const ChatCommand = {
|
|
11
11
|
command: "chat",
|
|
12
|
-
describe: "Chat with a
|
|
12
|
+
describe: "Chat with a Llama model",
|
|
13
13
|
builder(yargs) {
|
|
14
14
|
return yargs
|
|
15
15
|
.option("model", {
|
|
16
16
|
alias: "m",
|
|
17
17
|
type: "string",
|
|
18
18
|
demandOption: true,
|
|
19
|
-
description: "
|
|
19
|
+
description: "Llama model file to use for the chat",
|
|
20
20
|
group: "Required:"
|
|
21
21
|
})
|
|
22
22
|
.option("systemInfo", {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandModule } from "yargs";
|
|
2
2
|
type ClearCommand = {
|
|
3
|
-
type: "source" | "build" | "all";
|
|
3
|
+
type: "source" | "build" | "cmake" | "all";
|
|
4
4
|
};
|
|
5
5
|
export declare const ClearCommand: CommandModule<object, ClearCommand>;
|
|
6
6
|
export declare function ClearLlamaCppBuildCommand({ type }: ClearCommand): Promise<void>;
|
|
@@ -4,14 +4,16 @@ import { llamaCppDirectory } from "../../config.js";
|
|
|
4
4
|
import withOra from "../../utils/withOra.js";
|
|
5
5
|
import { clearLlamaBuild } from "../../utils/clearLlamaBuild.js";
|
|
6
6
|
import { setUsedBinFlag } from "../../utils/usedBinFlag.js";
|
|
7
|
+
import { clearLocalCmake, fixXpackPermissions } from "../../utils/cmake.js";
|
|
7
8
|
export const ClearCommand = {
|
|
8
9
|
command: "clear [type]",
|
|
10
|
+
aliases: ["clean"],
|
|
9
11
|
describe: "Clear files created by node-llama-cpp",
|
|
10
12
|
builder(yargs) {
|
|
11
13
|
return yargs
|
|
12
14
|
.option("type", {
|
|
13
15
|
type: "string",
|
|
14
|
-
choices: ["source", "build", "all"],
|
|
16
|
+
choices: ["source", "build", "cmake", "all"],
|
|
15
17
|
default: "all",
|
|
16
18
|
description: "Files to clear"
|
|
17
19
|
});
|
|
@@ -37,6 +39,16 @@ export async function ClearLlamaCppBuildCommand({ type }) {
|
|
|
37
39
|
await clearLlamaBuild();
|
|
38
40
|
});
|
|
39
41
|
}
|
|
42
|
+
if (type === "cmake" || type === "all") {
|
|
43
|
+
await withOra({
|
|
44
|
+
loading: chalk.blue("Clearing internal cmake"),
|
|
45
|
+
success: chalk.blue("Cleared internal cmake"),
|
|
46
|
+
fail: chalk.blue("Failed to clear internal cmake")
|
|
47
|
+
}, async () => {
|
|
48
|
+
await fixXpackPermissions();
|
|
49
|
+
await clearLocalCmake();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
40
52
|
await setUsedBinFlag("prebuiltBinaries");
|
|
41
53
|
}
|
|
42
54
|
//# sourceMappingURL=ClearCommand.js.map
|
|
@@ -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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,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;KACN;IAED,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE;QACpC,MAAM,OAAO,CAAC;YACV,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;YACrC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;YACpC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC;SAC5C,EAAE,KAAK,IAAI,EAAE;YACV,MAAM,eAAe,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;KACN;IAED,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE;QACpC,MAAM,OAAO,CAAC;YACV,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC;YAC9C,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;YAC7C,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC;SACrD,EAAE,KAAK,IAAI,EAAE;YACV,MAAM,mBAAmB,EAAE,CAAC;YAC5B,MAAM,eAAe,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;KACN;IAED,MAAM,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import process from "process";
|
|
2
|
-
import path from "path";
|
|
3
2
|
import { Octokit } from "octokit";
|
|
4
3
|
import fs from "fs-extra";
|
|
5
4
|
import chalk from "chalk";
|
|
@@ -10,6 +9,8 @@ import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js";
|
|
|
10
9
|
import withOra from "../../utils/withOra.js";
|
|
11
10
|
import { clearTempFolder } from "../../utils/clearTempFolder.js";
|
|
12
11
|
import { setBinariesGithubRelease } from "../../utils/binariesGithubRelease.js";
|
|
12
|
+
import { downloadCmakeIfNeeded } from "../../utils/cmake.js";
|
|
13
|
+
import withStatusLogs from "../../utils/withStatusLogs.js";
|
|
13
14
|
export const DownloadCommand = {
|
|
14
15
|
command: "download",
|
|
15
16
|
describe: "Download a release of llama.cpp and compile it",
|
|
@@ -39,7 +40,7 @@ export const DownloadCommand = {
|
|
|
39
40
|
type: "boolean",
|
|
40
41
|
default: defaultLlamaCppMetalSupport,
|
|
41
42
|
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
|
+
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"
|
|
43
44
|
})
|
|
44
45
|
.option("cuda", {
|
|
45
46
|
type: "boolean",
|
|
@@ -116,27 +117,20 @@ export async function DownloadLlamaCppCommand({ repo, release, arch, nodeTarget,
|
|
|
116
117
|
});
|
|
117
118
|
console.log(chalk.blue("Cloning llama.cpp"));
|
|
118
119
|
await cloneTag(githubOwner, githubRepo, githubRelease.data.tag_name, llamaCppDirectory);
|
|
119
|
-
await withOra({
|
|
120
|
-
loading: chalk.blue("Generating required files"),
|
|
121
|
-
success: chalk.blue("Generated required files"),
|
|
122
|
-
fail: chalk.blue("Failed to generate required files")
|
|
123
|
-
}, async () => {
|
|
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");
|
|
131
|
-
});
|
|
132
120
|
if (!skipBuild) {
|
|
133
|
-
|
|
134
|
-
await
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
121
|
+
await downloadCmakeIfNeeded(true);
|
|
122
|
+
await withStatusLogs({
|
|
123
|
+
loading: chalk.blue("Compiling llama.cpp"),
|
|
124
|
+
success: chalk.blue("Compiled llama.cpp"),
|
|
125
|
+
fail: chalk.blue("Failed to compile llama.cpp")
|
|
126
|
+
}, async () => {
|
|
127
|
+
await compileLlamaCpp({
|
|
128
|
+
arch: arch ? arch : undefined,
|
|
129
|
+
nodeTarget: nodeTarget ? nodeTarget : undefined,
|
|
130
|
+
setUsedBinFlag: true,
|
|
131
|
+
metal,
|
|
132
|
+
cuda
|
|
133
|
+
});
|
|
140
134
|
});
|
|
141
135
|
}
|
|
142
136
|
if (updateBinariesReleaseMetadata) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/DownloadCommand.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
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,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EACH,0BAA0B,EAAE,yBAAyB,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,iBAAiB,EAChI,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,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,WAAW,CAAC,GAAG,CAAC;QACpC,eAAe,EAAE,KAAK;QACtB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;KACpI,EAAE,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAEvC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE;QACtB,KAAK,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"}
|
package/dist/config.d.ts
CHANGED
|
@@ -6,9 +6,16 @@ export declare const llamaCppGrammarsDirectory: string;
|
|
|
6
6
|
export declare const tempDownloadDirectory: string;
|
|
7
7
|
export declare const usedBinFlagJsonPath: string;
|
|
8
8
|
export declare const binariesGithubReleasePath: string;
|
|
9
|
+
export declare const xpackDirectory: string;
|
|
10
|
+
export declare const localXpacksStoreDirectory: string;
|
|
11
|
+
export declare const localXpacksCacheDirectory: string;
|
|
12
|
+
export declare const xpmVersion = "^0.16.3";
|
|
9
13
|
export declare const defaultLlamaCppGitHubRepo: string;
|
|
10
14
|
export declare const defaultLlamaCppRelease: string;
|
|
11
15
|
export declare const defaultLlamaCppMetalSupport: boolean;
|
|
12
16
|
export declare const defaultLlamaCppCudaSupport: boolean;
|
|
13
17
|
export declare const defaultSkipDownload: boolean;
|
|
18
|
+
export declare const defaultXpacksStoreDirectory: string;
|
|
19
|
+
export declare const defaultXpacksCacheDirectory: string;
|
|
20
|
+
export declare const customCmakeOptionsEnvVarPrefix = "NODE_LLAMA_CPP_CMAKE_OPTION_";
|
|
14
21
|
export declare const defaultChatSystemPrompt: string;
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from "url";
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import * as os from "os";
|
|
4
|
+
import process from "process";
|
|
4
5
|
import envVar from "env-var";
|
|
5
6
|
import * as uuid from "uuid";
|
|
6
7
|
import { getBinariesGithubRelease } from "./utils/binariesGithubRelease.js";
|
|
@@ -14,6 +15,10 @@ export const llamaCppGrammarsDirectory = path.join(llamaDirectory, "llama.cpp",
|
|
|
14
15
|
export const tempDownloadDirectory = path.join(os.tmpdir(), "node-llama-cpp", uuid.v4());
|
|
15
16
|
export const usedBinFlagJsonPath = path.join(llamaDirectory, "usedBin.json");
|
|
16
17
|
export const binariesGithubReleasePath = path.join(llamaDirectory, "binariesGithubRelease.json");
|
|
18
|
+
export const xpackDirectory = path.join(llamaDirectory, "xpack");
|
|
19
|
+
export const localXpacksStoreDirectory = path.join(xpackDirectory, "store");
|
|
20
|
+
export const localXpacksCacheDirectory = path.join(xpackDirectory, "cache");
|
|
21
|
+
export const xpmVersion = "^0.16.3";
|
|
17
22
|
export const defaultLlamaCppGitHubRepo = env.get("NODE_LLAMA_CPP_REPO")
|
|
18
23
|
.default("ggerganov/llama.cpp")
|
|
19
24
|
.asString();
|
|
@@ -21,7 +26,7 @@ export const defaultLlamaCppRelease = env.get("NODE_LLAMA_CPP_REPO_RELEASE")
|
|
|
21
26
|
.default(await getBinariesGithubRelease())
|
|
22
27
|
.asString();
|
|
23
28
|
export const defaultLlamaCppMetalSupport = env.get("NODE_LLAMA_CPP_METAL")
|
|
24
|
-
.default("false")
|
|
29
|
+
.default(process.platform === "darwin" ? "true" : "false")
|
|
25
30
|
.asBool();
|
|
26
31
|
export const defaultLlamaCppCudaSupport = env.get("NODE_LLAMA_CPP_CUDA")
|
|
27
32
|
.default("false")
|
|
@@ -29,6 +34,13 @@ export const defaultLlamaCppCudaSupport = env.get("NODE_LLAMA_CPP_CUDA")
|
|
|
29
34
|
export const defaultSkipDownload = env.get("NODE_LLAMA_CPP_SKIP_DOWNLOAD")
|
|
30
35
|
.default("false")
|
|
31
36
|
.asBool();
|
|
37
|
+
export const defaultXpacksStoreDirectory = env.get("NODE_LLAMA_CPP_XPACKS_STORE_FOLDER")
|
|
38
|
+
.default(localXpacksStoreDirectory)
|
|
39
|
+
.asString();
|
|
40
|
+
export const defaultXpacksCacheDirectory = env.get("NODE_LLAMA_CPP_XPACKS_CACHE_FOLDER")
|
|
41
|
+
.default(localXpacksCacheDirectory)
|
|
42
|
+
.asString();
|
|
43
|
+
export const customCmakeOptionsEnvVarPrefix = "NODE_LLAMA_CPP_CMAKE_OPTION_";
|
|
32
44
|
export const defaultChatSystemPrompt = "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible.\n" +
|
|
33
45
|
"If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. " +
|
|
34
46
|
"If you don't know the answer to a question, please don't share false information.";
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"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ACd,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC,GAAG,CAAC,8BAA8B,CAAC;KACrE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,EAAE,CAAC;AACd,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC,GAAG,CAAC,oCAAoC,CAAC;KACnF,OAAO,CAAC,yBAAyB,CAAC;KAClC,QAAQ,EAAE,CAAC;AAChB,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC,GAAG,CAAC,oCAAoC,CAAC;KACnF,OAAO,CAAC,yBAAyB,CAAC;KAClC,QAAQ,EAAE,CAAC;AAChB,MAAM,CAAC,MAAM,8BAA8B,GAAG,8BAA8B,CAAC;AAC7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,+FAA+F;IAClI,+HAA+H;IAC/H,mFAAmF,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import process from "process";
|
|
2
|
+
import path from "path";
|
|
1
3
|
import { removeNullFields } from "../utils/removeNullFields.js";
|
|
2
4
|
import { llamaCppNode, LLAMAModel } from "./LlamaBins.js";
|
|
3
5
|
export class LlamaModel {
|
|
@@ -42,7 +44,7 @@ export class LlamaModel {
|
|
|
42
44
|
* @param {boolean} [options.embedding] - embedding mode only
|
|
43
45
|
*/
|
|
44
46
|
constructor({ modelPath, seed = null, contextSize = 1024 * 4, batchSize, gpuLayers, lowVram, threads = 6, temperature = 0, topK = 40, topP = 0.95, f16Kv, logitsAll, vocabOnly, useMmap, useMlock, embedding }) {
|
|
45
|
-
this._model = new LLAMAModel(modelPath, removeNullFields({
|
|
47
|
+
this._model = new LLAMAModel(path.resolve(process.cwd(), modelPath), removeNullFields({
|
|
46
48
|
seed: seed != null ? Math.max(-1, seed) : undefined,
|
|
47
49
|
contextSize,
|
|
48
50
|
batchSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LlamaModel.js","sourceRoot":"","sources":["../../src/llamaEvaluator/Llama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IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EACxG;QAChB,IAAI,CAAC,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,EAAE,gBAAgB,CAAC;YAClF,IAAI,EAAE,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACnD,WAAW;YACX,SAAS;YACT,SAAS;YACT,OAAO;YACP,OAAO;YACP,WAAW;YACX,IAAI;YACJ,IAAI;YACJ,KAAK;YACL,SAAS;YACT,SAAS;YACT,OAAO;YACP,QAAQ;YACR,SAAS;SACZ,CAAC,CAAC,CAAC;IACR,CAAC;IAEM,MAAM,KAAK,UAAU;QACxB,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function hasBuiltinCmake(): Promise<boolean>;
|
|
2
|
+
export declare function getCmakePath(): Promise<string>;
|
|
3
|
+
export declare function downloadCmakeIfNeeded(wrapWithStatusLogs?: boolean): Promise<void>;
|
|
4
|
+
export declare function clearLocalCmake(): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* There's an issue where after a compilation, the cmake binaries have permissions that don't allow them to be deleted.
|
|
7
|
+
* This function fixes that.
|
|
8
|
+
* It should be run after each compilation.
|
|
9
|
+
*/
|
|
10
|
+
export declare function fixXpackPermissions(): Promise<void>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import * as fs from "fs-extra";
|
|
3
|
+
import which from "which";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { chmodr } from "chmodrp";
|
|
6
|
+
import { defaultXpacksCacheDirectory, defaultXpacksStoreDirectory, llamaDirectory, localXpacksCacheDirectory, localXpacksStoreDirectory, xpackDirectory, xpmVersion } from "../config.js";
|
|
7
|
+
import { spawnCommand } from "./spawnCommand.js";
|
|
8
|
+
import withStatusLogs from "./withStatusLogs.js";
|
|
9
|
+
export async function hasBuiltinCmake() {
|
|
10
|
+
try {
|
|
11
|
+
const resolvedPath = await which("cmake");
|
|
12
|
+
return resolvedPath !== "";
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function getCmakePath() {
|
|
19
|
+
try {
|
|
20
|
+
const resolvedPath = await which("cmake");
|
|
21
|
+
if (resolvedPath !== "")
|
|
22
|
+
return resolvedPath;
|
|
23
|
+
}
|
|
24
|
+
catch (err) { }
|
|
25
|
+
try {
|
|
26
|
+
const resolvedPath = await which("cmake", {
|
|
27
|
+
path: path.join(llamaDirectory, "xpack", "xpacks", ".bin")
|
|
28
|
+
});
|
|
29
|
+
if (resolvedPath !== "")
|
|
30
|
+
return resolvedPath;
|
|
31
|
+
}
|
|
32
|
+
catch (err) { }
|
|
33
|
+
throw new Error("cmake not found");
|
|
34
|
+
}
|
|
35
|
+
export async function downloadCmakeIfNeeded(wrapWithStatusLogs = false) {
|
|
36
|
+
try {
|
|
37
|
+
await getCmakePath();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
catch (err) { }
|
|
41
|
+
if (!wrapWithStatusLogs)
|
|
42
|
+
await downloadCmake();
|
|
43
|
+
else
|
|
44
|
+
await withStatusLogs({
|
|
45
|
+
loading: chalk.blue("Downloading cmake"),
|
|
46
|
+
success: chalk.blue("Downloaded cmake"),
|
|
47
|
+
fail: chalk.blue("Failed to download cmake")
|
|
48
|
+
}, async () => {
|
|
49
|
+
await downloadCmake();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export async function clearLocalCmake() {
|
|
53
|
+
await fs.remove(localXpacksStoreDirectory);
|
|
54
|
+
await fs.remove(localXpacksCacheDirectory);
|
|
55
|
+
await fs.remove(path.join(xpackDirectory, "xpacks"));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* There's an issue where after a compilation, the cmake binaries have permissions that don't allow them to be deleted.
|
|
59
|
+
* This function fixes that.
|
|
60
|
+
* It should be run after each compilation.
|
|
61
|
+
*/
|
|
62
|
+
export async function fixXpackPermissions() {
|
|
63
|
+
try {
|
|
64
|
+
await chmodr(localXpacksStoreDirectory, 0o777);
|
|
65
|
+
await chmodr(localXpacksCacheDirectory, 0o777);
|
|
66
|
+
await chmodr(path.join(xpackDirectory, "xpacks"), 0o777);
|
|
67
|
+
}
|
|
68
|
+
catch (err) { }
|
|
69
|
+
}
|
|
70
|
+
async function downloadCmake() {
|
|
71
|
+
const xpmEnv = {
|
|
72
|
+
...process.env,
|
|
73
|
+
XPACKS_STORE_FOLDER: defaultXpacksStoreDirectory,
|
|
74
|
+
XPACKS_CACHE_FOLDER: defaultXpacksCacheDirectory
|
|
75
|
+
};
|
|
76
|
+
await spawnCommand("npm", ["exec", "--yes", "--", `xpm@${xpmVersion}`, "install", "@xpack-dev-tools/cmake@latest", "--no-save"], xpackDirectory, xpmEnv);
|
|
77
|
+
await fs.remove(localXpacksCacheDirectory);
|
|
78
|
+
await fixXpackPermissions();
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=cmake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cmake.js","sourceRoot":"","sources":["../../src/utils/cmake.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAC/B,OAAO,EACH,2BAA2B,EAAE,2BAA2B,EAAE,cAAc,EAAE,yBAAyB,EAAE,yBAAyB,EAC9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