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.
Files changed (118) hide show
  1. package/README.md +122 -25
  2. package/dist/ChatPromptWrapper.d.ts +3 -0
  3. package/dist/ChatPromptWrapper.js.map +1 -1
  4. package/dist/chatWrappers/ChatMLPromptWrapper.d.ts +11 -0
  5. package/dist/chatWrappers/ChatMLPromptWrapper.js +19 -0
  6. package/dist/chatWrappers/ChatMLPromptWrapper.js.map +1 -0
  7. package/dist/chatWrappers/EmptyChatPromptWrapper.d.ts +1 -0
  8. package/dist/chatWrappers/EmptyChatPromptWrapper.js +1 -0
  9. package/dist/chatWrappers/EmptyChatPromptWrapper.js.map +1 -1
  10. package/dist/chatWrappers/GeneralChatPromptWrapper.d.ts +11 -1
  11. package/dist/chatWrappers/GeneralChatPromptWrapper.js +28 -4
  12. package/dist/chatWrappers/GeneralChatPromptWrapper.js.map +1 -1
  13. package/dist/chatWrappers/LlamaChatPromptWrapper.d.ts +4 -1
  14. package/dist/chatWrappers/LlamaChatPromptWrapper.js +8 -4
  15. package/dist/chatWrappers/LlamaChatPromptWrapper.js.map +1 -1
  16. package/dist/chatWrappers/createChatWrapperByBos.d.ts +2 -0
  17. package/dist/chatWrappers/createChatWrapperByBos.js +14 -0
  18. package/dist/chatWrappers/createChatWrapperByBos.js.map +1 -0
  19. package/dist/cli/commands/BuildCommand.d.ts +3 -1
  20. package/dist/cli/commands/BuildCommand.js +24 -2
  21. package/dist/cli/commands/BuildCommand.js.map +1 -1
  22. package/dist/cli/commands/ChatCommand.d.ts +7 -1
  23. package/dist/cli/commands/ChatCommand.js +87 -12
  24. package/dist/cli/commands/ChatCommand.js.map +1 -1
  25. package/dist/cli/commands/ClearCommand.js +1 -1
  26. package/dist/cli/commands/ClearCommand.js.map +1 -1
  27. package/dist/cli/commands/DownloadCommand.d.ts +3 -1
  28. package/dist/cli/commands/DownloadCommand.js +60 -69
  29. package/dist/cli/commands/DownloadCommand.js.map +1 -1
  30. package/dist/cli/commands/OnPostInstallCommand.js +4 -2
  31. package/dist/cli/commands/OnPostInstallCommand.js.map +1 -1
  32. package/dist/config.d.ts +4 -0
  33. package/dist/config.js +8 -0
  34. package/dist/config.js.map +1 -1
  35. package/dist/index.d.ts +5 -1
  36. package/dist/index.js +4 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/llamaEvaluator/LlamaBins.d.ts +3 -3
  39. package/dist/llamaEvaluator/LlamaBins.js +2 -2
  40. package/dist/llamaEvaluator/LlamaBins.js.map +1 -1
  41. package/dist/llamaEvaluator/LlamaChatSession.d.ts +7 -2
  42. package/dist/llamaEvaluator/LlamaChatSession.js +51 -11
  43. package/dist/llamaEvaluator/LlamaChatSession.js.map +1 -1
  44. package/dist/llamaEvaluator/LlamaContext.d.ts +31 -2
  45. package/dist/llamaEvaluator/LlamaContext.js +69 -2
  46. package/dist/llamaEvaluator/LlamaContext.js.map +1 -1
  47. package/dist/llamaEvaluator/LlamaGrammar.d.ts +14 -0
  48. package/dist/llamaEvaluator/LlamaGrammar.js +30 -0
  49. package/dist/llamaEvaluator/LlamaGrammar.js.map +1 -0
  50. package/dist/llamaEvaluator/LlamaModel.d.ts +49 -1
  51. package/dist/llamaEvaluator/LlamaModel.js +25 -9
  52. package/dist/llamaEvaluator/LlamaModel.js.map +1 -1
  53. package/dist/types.d.ts +1 -0
  54. package/dist/types.js +2 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/utils/compileLLamaCpp.d.ts +3 -1
  57. package/dist/utils/compileLLamaCpp.js +34 -4
  58. package/dist/utils/compileLLamaCpp.js.map +1 -1
  59. package/dist/utils/getBin.d.ts +15 -2
  60. package/dist/utils/getBin.js +4 -2
  61. package/dist/utils/getBin.js.map +1 -1
  62. package/dist/utils/getGrammarsFolder.d.ts +1 -0
  63. package/dist/utils/getGrammarsFolder.js +18 -0
  64. package/dist/utils/getGrammarsFolder.js.map +1 -0
  65. package/dist/utils/getTextCompletion.d.ts +3 -0
  66. package/dist/utils/getTextCompletion.js +12 -0
  67. package/dist/utils/getTextCompletion.js.map +1 -0
  68. package/dist/utils/removeNullFields.d.ts +1 -0
  69. package/dist/utils/removeNullFields.js +9 -0
  70. package/dist/utils/removeNullFields.js.map +1 -0
  71. package/dist/utils/spawnCommand.d.ts +2 -1
  72. package/dist/utils/spawnCommand.js +2 -2
  73. package/dist/utils/spawnCommand.js.map +1 -1
  74. package/llama/addon.cpp +154 -19
  75. package/llama/binariesGithubRelease.json +1 -1
  76. package/llama/binding.gyp +6 -3
  77. package/llama/grammars/README.md +91 -0
  78. package/llama/grammars/arithmetic.gbnf +6 -0
  79. package/llama/grammars/chess.gbnf +13 -0
  80. package/llama/grammars/japanese.gbnf +7 -0
  81. package/llama/grammars/json.gbnf +25 -0
  82. package/llama/grammars/list.gbnf +4 -0
  83. package/llamaBins/linux-arm64-16.node +0 -0
  84. package/llamaBins/linux-arm64-17.node +0 -0
  85. package/llamaBins/linux-arm64-18.node +0 -0
  86. package/llamaBins/linux-arm64-19.node +0 -0
  87. package/llamaBins/linux-arm64-20.node +0 -0
  88. package/llamaBins/linux-armv7l-16.node +0 -0
  89. package/llamaBins/linux-armv7l-17.node +0 -0
  90. package/llamaBins/linux-armv7l-18.node +0 -0
  91. package/llamaBins/linux-armv7l-19.node +0 -0
  92. package/llamaBins/linux-armv7l-20.node +0 -0
  93. package/llamaBins/linux-ppc64le-16.node +0 -0
  94. package/llamaBins/linux-ppc64le-17.node +0 -0
  95. package/llamaBins/linux-ppc64le-18.node +0 -0
  96. package/llamaBins/linux-ppc64le-19.node +0 -0
  97. package/llamaBins/linux-ppc64le-20.node +0 -0
  98. package/llamaBins/linux-x64-16.node +0 -0
  99. package/llamaBins/linux-x64-17.node +0 -0
  100. package/llamaBins/linux-x64-18.node +0 -0
  101. package/llamaBins/linux-x64-19.node +0 -0
  102. package/llamaBins/linux-x64-20.node +0 -0
  103. package/llamaBins/mac-arm64-16.node +0 -0
  104. package/llamaBins/mac-arm64-17.node +0 -0
  105. package/llamaBins/mac-arm64-18.node +0 -0
  106. package/llamaBins/mac-arm64-19.node +0 -0
  107. package/llamaBins/mac-arm64-20.node +0 -0
  108. package/llamaBins/mac-x64-16.node +0 -0
  109. package/llamaBins/mac-x64-17.node +0 -0
  110. package/llamaBins/mac-x64-18.node +0 -0
  111. package/llamaBins/mac-x64-19.node +0 -0
  112. package/llamaBins/mac-x64-20.node +0 -0
  113. package/llamaBins/win-x64-16.node +0 -0
  114. package/llamaBins/win-x64-17.node +0 -0
  115. package/llamaBins/win-x64-18.node +0 -0
  116. package/llamaBins/win-x64-19.node +0 -0
  117. package/llamaBins/win-x64-20.node +0 -0
  118. package/package.json +10 -6
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
+ <div align="center">
2
+
1
3
  # Node Llama.cpp
2
4
  Node.js bindings for llama.cpp.
3
5
 
4
- Pre-built bindings are provided with a fallback to building from source with `node-gyp`.
6
+ <sub>Pre-built bindings are provided with a fallback to building from source with `node-gyp`.<sub>
5
7
 
6
8
  [![Build](https://github.com/withcatai/node-llama-cpp/actions/workflows/build.yml/badge.svg)](https://github.com/withcatai/node-llama-cpp/actions/workflows/build.yml)
9
+ [![License](https://badgen.net/badge/color/MIT/green?label=license)](https://www.npmjs.com/package/node-llama-cpp)
10
+ [![License](https://badgen.net/badge/color/TypeScript/blue?label=types)](https://www.npmjs.com/package/node-llama-cpp)
7
11
  [![Version](https://badgen.net/npm/v/node-llama-cpp)](https://www.npmjs.com/package/node-llama-cpp)
8
12
 
13
+ </div>
9
14
 
10
15
  ## Installation
11
16
  ```bash
@@ -113,8 +118,8 @@ console.log("AI: " + q1);
113
118
 
114
119
  const tokens = context.encode(q1);
115
120
  const res: number[] = [];
116
- for await (const chunk of context.evaluate(tokens)) {
117
- res.push(chunk);
121
+ for await (const modelToken of context.evaluate(tokens)) {
122
+ res.push(modelToken);
118
123
 
119
124
  // it's important to not concatinate the results as strings,
120
125
  // as doing so will break some characters (like some emojis) that are made of multiple tokens.
@@ -130,15 +135,72 @@ const a1 = context.decode(Uint32Array.from(res)).split("USER:")[0];
130
135
  console.log("AI: " + a1);
131
136
  ```
132
137
 
138
+ #### With grammar
139
+ Use this to direct the model to generate a specific format of text, like `JSON` for example.
140
+
141
+ > **Note:** there's an issue with some grammars where the model won't stop generating output,
142
+ > so it's advised to use it together with `maxTokens` set to the context size of the model
143
+
144
+ ```typescript
145
+ import {fileURLToPath} from "url";
146
+ import path from "path";
147
+ import {LlamaModel, LlamaGrammar, LlamaContext, LlamaChatSession} from "node-llama-cpp";
148
+
149
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
150
+
151
+ const model = new LlamaModel({
152
+ modelPath: path.join(__dirname, "models", "codellama-13b.Q3_K_M.gguf")
153
+ })
154
+ const grammar = await LlamaGrammar.getFor("json");
155
+ const context = new LlamaContext({
156
+ model,
157
+ grammar
158
+ });
159
+ const session = new LlamaChatSession({context});
160
+
161
+
162
+ const q1 = 'Create a JSON that contains a message saying "hi there"';
163
+ console.log("User: " + q1);
164
+
165
+ const a1 = await session.prompt(q1, {maxTokens: context.getContextSize()});
166
+ console.log("AI: " + a1);
167
+ console.log(JSON.parse(a1));
168
+
169
+
170
+ const q2 = 'Add another field to the JSON with the key being "author" and the value being "LLama"';
171
+ console.log("User: " + q2);
172
+
173
+ const a2 = await session.prompt(q2, {maxTokens: context.getContextSize()});
174
+ console.log("AI: " + a2);
175
+ console.log(JSON.parse(a2));
176
+ ```
177
+
178
+ ### Metal and CUDA support
179
+ To load a version of `llama.cpp` that was compiled to use Metal or CUDA,
180
+ you have to build it from source with the `--metal` or `--cuda` flag before running your code that imports `node-llama-cpp`.
181
+
182
+ To do this, run this command inside of your project directory:
183
+ ```bash
184
+ # For Metal support on macOS
185
+ npx node-llama-cpp download --metal
186
+
187
+ # For CUDA support
188
+ npx node-llama-cpp download --cuda
189
+ ```
190
+
191
+ > In order for `node-llama-cpp` to be able to build `llama.cpp` from source, make sure you have the required dependencies of `node-gyp` installed.
192
+ >
193
+ > More info is available [here](https://github.com/nodejs/node-gyp#on-unix) (you don't have to install `node-gyp` itself, just the dependencies).
194
+
133
195
  ### CLI
134
196
  ```
135
197
  Usage: node-llama-cpp <command> [options]
136
198
 
137
199
  Commands:
138
- node-llama-cpp download Download a release of llama.cpp and compile it
139
- node-llama-cpp build Compile the currently downloaded llama.cpp
140
- node-llama-cpp clear [type] Clear files created by llama-cli
141
- node-llama-cpp chat Chat with a LLama model
200
+ node-llama-cpp download Download a release of llama.cpp and compile it
201
+ node-llama-cpp build Compile the currently downloaded llama.cpp
202
+ node-llama-cpp clear [type] Clear files created by node-llama-cpp
203
+ node-llama-cpp chat Chat with a LLama model
142
204
 
143
205
  Options:
144
206
  -h, --help Show help [boolean]
@@ -152,15 +214,21 @@ node-llama-cpp download
152
214
  Download a release of llama.cpp and compile it
153
215
 
154
216
  Options:
155
- -h, --help Show help [boolean]
156
- --repo The GitHub repository to download a release of llama.cpp from. Can also be set v
157
- ia the NODE_LLAMA_CPP_REPO environment variable
217
+ -h, --help Show help [boolean]
218
+ --repo The GitHub repository to download a release of llama.cpp from. Can also be
219
+ set via the NODE_LLAMA_CPP_REPO environment variable
158
220
  [string] [default: "ggerganov/llama.cpp"]
159
- --release The tag of the llama.cpp release to download. Can also be set via the NODE_LLAMA
160
- _CPP_REPO_RELEASE environment variable [string] [default: "latest"]
161
- --arch The architecture to compile llama.cpp for [string]
162
- --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
163
- -v, --version Show version number [boolean]
221
+ --release The tag of the llama.cpp release to download. Set to "latest" to download t
222
+ he latest release. Can also be set via the NODE_LLAMA_CPP_REPO_RELEASE envi
223
+ ronment variable [string] [default: "latest"]
224
+ -a, --arch The architecture to compile llama.cpp for [string]
225
+ -t, --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
226
+ --metal Compile llama.cpp with Metal support. Can also be set via the NODE_LLAMA_CP
227
+ P_METAL environment variable [boolean] [default: false]
228
+ --cuda Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP
229
+ _CUDA environment variable [boolean] [default: false]
230
+ --skipBuild, --sb Skip building llama.cpp after downloading it [boolean] [default: false]
231
+ -v, --version Show version number [boolean]
164
232
  ```
165
233
 
166
234
  #### `build` command
@@ -171,8 +239,12 @@ Compile the currently downloaded llama.cpp
171
239
 
172
240
  Options:
173
241
  -h, --help Show help [boolean]
174
- --arch The architecture to compile llama.cpp for [string]
175
- --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
242
+ -a, --arch The architecture to compile llama.cpp for [string]
243
+ -t, --nodeTarget The Node.js version to compile llama.cpp for. Example: v18.0.0 [string]
244
+ --metal Compile llama.cpp with Metal support. Can also be set via the NODE_LLAMA_CPP_MET
245
+ AL environment variable [boolean] [default: false]
246
+ --cuda Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP_CUDA
247
+ environment variable [boolean] [default: false]
176
248
  -v, --version Show version number [boolean]
177
249
  ```
178
250
 
@@ -180,7 +252,7 @@ Options:
180
252
  ```
181
253
  node-llama-cpp clear [type]
182
254
 
183
- Clear files created by llama-cli
255
+ Clear files created by node-llama-cpp
184
256
 
185
257
  Options:
186
258
  -h, --help Show help [boolean]
@@ -195,20 +267,45 @@ node-llama-cpp chat
195
267
  Chat with a LLama model
196
268
 
197
269
  Required:
198
- --model LLama model file to use for the chat [string] [required]
270
+ -m, --model LLama model file to use for the chat [string] [required]
199
271
 
200
272
  Optional:
201
- --systemInfo Print llama.cpp system info [boolean] [default: false]
202
- --systemPrompt System prompt to use against the model. [default value: You are a helpful, res
203
- pectful and honest assistant. Always answer as helpfully as possible. If a que
204
- stion does not make any sense, or is not factually coherent, explain why inste
205
- ad of answering something not correct. If you don't know the answer to a quest
206
- ion, please don't share false information.]
273
+ -i, --systemInfo Print llama.cpp system info [boolean] [default: false]
274
+ -s, --systemPrompt System prompt to use against the model. [default value: You are a helpful,
275
+ respectful and honest assistant. Always answer as helpfully as possible. If
276
+ a question does not make any sense, or is not factually coherent, explain
277
+ why instead of answering something not correct. If you don't know the answe
278
+ r to a question, please don't share false information.]
207
279
  [string] [default: "You are a helpful, respectful and honest assistant. Always answer as helpfully
208
280
  as possible.
209
281
  If a question does not make any sense, or is not factually coherent, explain why ins
210
282
  tead of answering something not correct. If you don't know the answer to a question, please don't
211
283
  share false information."]
284
+ -w, --wrapper Chat wrapper to use. Use `auto` to automatically select a wrapper based on
285
+ the model's BOS token
286
+ [string] [choices: "auto", "general", "llamaChat", "chatML"] [default: "general"]
287
+ -c, --contextSize Context size to use for the model [number] [default: 4096]
288
+ -g, --grammar Restrict the model response to a specific grammar, like JSON for example
289
+ [string] [choices: "text", "json", "list", "arithmetic", "japanese", "chess"] [default: "text"]
290
+ -t, --temperature Temperature is a hyperparameter that controls the randomness of the generat
291
+ ed text. It affects the probability distribution of the model's output toke
292
+ ns. A higher temperature (e.g., 1.5) makes the output more random and creat
293
+ ive, while a lower temperature (e.g., 0.5) makes the output more focused, d
294
+ eterministic, and conservative. The suggested temperature is 0.8, which pro
295
+ vides a balance between randomness and determinism. At the extreme, a tempe
296
+ rature of 0 will always pick the most likely next token, leading to identic
297
+ al outputs in each run. Set to `0` to disable. [number] [default: 0]
298
+ -k, --topK Limits the model to consider only the K most likely next tokens for samplin
299
+ g at each step of sequence generation. An integer number between `1` and th
300
+ e size of the vocabulary. Set to `0` to disable (which uses the full vocabu
301
+ lary). Only relevant when `temperature` is set to a value greater than 0.
302
+ [number] [default: 40]
303
+ -p, --topP Dynamically selects the smallest set of tokens whose cumulative probability
304
+ exceeds the threshold P, and samples the next token only from this set. A
305
+ float number between `0` and `1`. Set to `1` to disable. Only relevant when
306
+ `temperature` is set to a value greater than `0`. [number] [default: 0.95]
307
+ --maxTokens, --mt Maximum number of tokens to generate in responses. Set to `0` to disable. S
308
+ et to `-1` to set to the context size [number] [default: 0]
212
309
 
213
310
  Options:
214
311
  -h, --help Show help [boolean]
@@ -1,7 +1,10 @@
1
1
  export declare abstract class ChatPromptWrapper {
2
+ abstract readonly wrapperName: string;
2
3
  wrapPrompt(prompt: string, { systemPrompt, promptIndex }: {
3
4
  systemPrompt: string;
4
5
  promptIndex: number;
6
+ lastStopString: string | null;
7
+ lastStopStringSuffix: string | null;
5
8
  }): string;
6
9
  getStopStrings(): string[];
7
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChatPromptWrapper.js","sourceRoot":"","sources":["../src/ChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,iBAAiB;IAC5B,UAAU,CAAC,MAAc,EAAE,EAAC,YAAY,EAAE,WAAW,EAA8C;QACtG,IAAI,WAAW,KAAK,CAAC,EAAE;YACnB,OAAO,YAAY,GAAG,IAAI,GAAG,MAAM,CAAC;SACvC;aAAM;YACH,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAEM,cAAc;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
1
+ {"version":3,"file":"ChatPromptWrapper.js","sourceRoot":"","sources":["../src/ChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,iBAAiB;IAG5B,UAAU,CAAC,MAAc,EAAE,EAAC,YAAY,EAAE,WAAW,EAE3D;QACG,IAAI,WAAW,KAAK,CAAC,EAAE;YACnB,OAAO,YAAY,GAAG,IAAI,GAAG,MAAM,CAAC;SACvC;aAAM;YACH,OAAO,MAAM,CAAC;SACjB;IACL,CAAC;IAEM,cAAc;QACjB,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
@@ -0,0 +1,11 @@
1
+ import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
+ export declare class ChatMLPromptWrapper extends ChatPromptWrapper {
3
+ readonly wrapperName: string;
4
+ wrapPrompt(prompt: string, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }: {
5
+ systemPrompt: string;
6
+ promptIndex: number;
7
+ lastStopString: string | null;
8
+ lastStopStringSuffix: string | null;
9
+ }): string;
10
+ getStopStrings(): string[];
11
+ }
@@ -0,0 +1,19 @@
1
+ import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
+ import { getTextCompletion } from "../utils/getTextCompletion.js";
3
+ // source: https://github.com/openai/openai-python/blob/120d225b91a8453e15240a49fb1c6794d8119326/chatml.md
4
+ export class ChatMLPromptWrapper extends ChatPromptWrapper {
5
+ wrapperName = "ChatML";
6
+ wrapPrompt(prompt, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }) {
7
+ const previousCompletionEnd = (lastStopString ?? "") + (lastStopStringSuffix ?? "");
8
+ if (promptIndex === 0 && systemPrompt != "")
9
+ return (getTextCompletion(previousCompletionEnd, "<|im_start|>system\n") ?? "<|im_start|>system\n") +
10
+ systemPrompt + "<|im_end|>\n<|im_start|>user\n" + prompt + "<|im_end|>\n<|im_start|>assistant\n";
11
+ else
12
+ return (getTextCompletion(previousCompletionEnd, "<|im_end|>\n<|im_start|>user\n") ?? "<|im_end|>\n<|im_start|>user\n") +
13
+ prompt + "<|im_end|>\n<|im_start|>assistant\n";
14
+ }
15
+ getStopStrings() {
16
+ return ["<|im_end|>"];
17
+ }
18
+ }
19
+ //# sourceMappingURL=ChatMLPromptWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatMLPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/ChatMLPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAEhE,0GAA0G;AAC1G,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtC,WAAW,GAAW,QAAQ,CAAC;IAE/B,UAAU,CAAC,MAAc,EAAE,EAAC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAE1G;QACG,MAAM,qBAAqB,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;QAEpF,IAAI,WAAW,KAAK,CAAC,IAAI,YAAY,IAAI,EAAE;YACvC,OAAO,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,IAAI,sBAAsB,CAAC;gBAC/F,YAAY,GAAG,gCAAgC,GAAG,MAAM,GAAG,qCAAqC,CAAC;;YAErG,OAAO,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,gCAAgC,CAAC,IAAI,gCAAgC,CAAC;gBACnH,MAAM,GAAG,qCAAqC,CAAC;IAC3D,CAAC;IAEe,cAAc;QAC1B,OAAO,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;CACJ"}
@@ -1,3 +1,4 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
2
  export declare class EmptyChatPromptWrapper extends ChatPromptWrapper {
3
+ readonly wrapperName: string;
3
4
  }
@@ -1,4 +1,5 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
2
  export class EmptyChatPromptWrapper extends ChatPromptWrapper {
3
+ wrapperName = "Empty";
3
4
  }
4
5
  //# sourceMappingURL=EmptyChatPromptWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EmptyChatPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/EmptyChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;CAAG"}
1
+ {"version":3,"file":"EmptyChatPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/EmptyChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,MAAM,OAAO,sBAAuB,SAAQ,iBAAiB;IACzC,WAAW,GAAW,OAAO,CAAC;CACjD"}
@@ -1,8 +1,18 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
2
  export declare class GeneralChatPromptWrapper extends ChatPromptWrapper {
3
- wrapPrompt(prompt: string, { systemPrompt, promptIndex }: {
3
+ readonly wrapperName: string;
4
+ private readonly _instructionName;
5
+ private readonly _responseName;
6
+ constructor({ instructionName, responseName }?: {
7
+ instructionName?: string;
8
+ responseName?: string;
9
+ });
10
+ wrapPrompt(prompt: string, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }: {
4
11
  systemPrompt: string;
5
12
  promptIndex: number;
13
+ lastStopString: string | null;
14
+ lastStopStringSuffix: string | null;
6
15
  }): string;
7
16
  getStopStrings(): string[];
17
+ private _getPromptPrefix;
8
18
  }
@@ -1,11 +1,35 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
+ import { getTextCompletion } from "../utils/getTextCompletion.js";
2
3
  export class GeneralChatPromptWrapper extends ChatPromptWrapper {
3
- wrapPrompt(prompt, { systemPrompt, promptIndex }) {
4
- const conversationPrompt = "\n\n### Human:\n\n" + prompt + "\n\n### Assistant:\n\n";
5
- return promptIndex === 0 ? systemPrompt + conversationPrompt : conversationPrompt;
4
+ wrapperName = "General";
5
+ _instructionName;
6
+ _responseName;
7
+ constructor({ instructionName = "Human", responseName = "Assistant" } = {}) {
8
+ super();
9
+ this._instructionName = instructionName;
10
+ this._responseName = responseName;
11
+ }
12
+ wrapPrompt(prompt, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }) {
13
+ if (promptIndex === 0)
14
+ return systemPrompt + `\n\n### ${this._instructionName}:\n\n` + prompt + `\n\n### ${this._responseName}:\n\n`;
15
+ return this._getPromptPrefix(lastStopString, lastStopStringSuffix) + prompt + `\n\n### ${this._responseName}:\n\n`;
6
16
  }
7
17
  getStopStrings() {
8
- return ["### Human:", "Human:", "### Assistant:", "Assistant:", "<end>"];
18
+ return [
19
+ `\n\n### ${this._instructionName}`,
20
+ `### ${this._instructionName}`,
21
+ `\n\n### ${this._responseName}`,
22
+ `### ${this._responseName}`,
23
+ "<end>"
24
+ ];
25
+ }
26
+ _getPromptPrefix(lastStopString, lastStopStringSuffix) {
27
+ return getTextCompletion(lastStopString === "<end>"
28
+ ? lastStopStringSuffix
29
+ : (lastStopString + (lastStopStringSuffix ?? "")), [
30
+ `\n\n### ${this._instructionName}:\n\n`,
31
+ `### ${this._instructionName}:\n\n`
32
+ ]) ?? `\n\n### ${this._instructionName}:\n\n`;
9
33
  }
10
34
  }
11
35
  //# sourceMappingURL=GeneralChatPromptWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeneralChatPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/GeneralChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAE1D,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC3C,UAAU,CAAC,MAAc,EAAE,EAAC,YAAY,EAAE,WAAW,EAAgD;QACjH,MAAM,kBAAkB,GAAG,oBAAoB,GAAG,MAAM,GAAG,wBAAwB,CAAC;QAEpF,OAAO,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACtF,CAAC;IAEe,cAAc;QAC1B,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;CACJ"}
1
+ {"version":3,"file":"GeneralChatPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/GeneralChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAEhE,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC3C,WAAW,GAAW,SAAS,CAAC;IAC/B,gBAAgB,CAAS;IACzB,aAAa,CAAS;IAEvC,YAAmB,EAAC,eAAe,GAAG,OAAO,EAAE,YAAY,GAAG,WAAW,KAAuD,EAAE;QAC9H,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;QACxC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAEe,UAAU,CAAC,MAAc,EAAE,EAAC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAE1G;QACG,IAAI,WAAW,KAAK,CAAC;YACjB,OAAO,YAAY,GAAG,WAAW,IAAI,CAAC,gBAAgB,OAAO,GAAG,MAAM,GAAG,WAAW,IAAI,CAAC,aAAa,OAAO,CAAC;QAElH,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,oBAAoB,CAAC,GAAG,MAAM,GAAG,WAAW,IAAI,CAAC,aAAa,OAAO,CAAC;IACvH,CAAC;IAEe,cAAc;QAC1B,OAAO;YACH,WAAW,IAAI,CAAC,gBAAgB,EAAE;YAClC,OAAO,IAAI,CAAC,gBAAgB,EAAE;YAC9B,WAAW,IAAI,CAAC,aAAa,EAAE;YAC/B,OAAO,IAAI,CAAC,aAAa,EAAE;YAC3B,OAAO;SACV,CAAC;IACN,CAAC;IAEO,gBAAgB,CAAC,cAA6B,EAAE,oBAAmC;QACvF,OAAO,iBAAiB,CACpB,cAAc,KAAK,OAAO;YACtB,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,EACrD;YACI,WAAW,IAAI,CAAC,gBAAgB,OAAO;YACvC,OAAO,IAAI,CAAC,gBAAgB,OAAO;SACtC,CACJ,IAAI,WAAW,IAAI,CAAC,gBAAgB,OAAO,CAAC;IACjD,CAAC;CACJ"}
@@ -1,8 +1,11 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
2
  export declare class LlamaChatPromptWrapper extends ChatPromptWrapper {
3
- wrapPrompt(prompt: string, { systemPrompt, promptIndex }: {
3
+ readonly wrapperName: string;
4
+ wrapPrompt(prompt: string, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }: {
4
5
  systemPrompt: string;
5
6
  promptIndex: number;
7
+ lastStopString: string | null;
8
+ lastStopStringSuffix: string | null;
6
9
  }): string;
7
10
  getStopStrings(): string[];
8
11
  }
@@ -1,16 +1,20 @@
1
1
  import { ChatPromptWrapper } from "../ChatPromptWrapper.js";
2
+ import { getTextCompletion } from "../utils/getTextCompletion.js";
2
3
  // source: https://huggingface.co/blog/llama2#how-to-prompt-llama-2
3
4
  export class LlamaChatPromptWrapper extends ChatPromptWrapper {
4
- wrapPrompt(prompt, { systemPrompt, promptIndex }) {
5
+ wrapperName = "LlamaChat";
6
+ wrapPrompt(prompt, { systemPrompt, promptIndex, lastStopString, lastStopStringSuffix }) {
7
+ const previousCompletionEnd = (lastStopString ?? "") + (lastStopStringSuffix ?? "");
5
8
  if (promptIndex === 0 && systemPrompt != "") {
6
- return "<s>[INST] <<SYS>>\n" + systemPrompt + "\n<</SYS>>\n\n" + prompt + " [/INST]\n\n";
9
+ return (getTextCompletion(previousCompletionEnd, "<s>[INST] <<SYS>>\n") ?? "<s>[INST] <<SYS>>\n") + systemPrompt +
10
+ "\n<</SYS>>\n\n" + prompt + " [/INST]\n\n";
7
11
  }
8
12
  else {
9
- return "<s>[INST] " + prompt + " [/INST]\n\n";
13
+ return (getTextCompletion(previousCompletionEnd, "</s><s>[INST] ") ?? "<s>[INST] ") + prompt + " [/INST]\n\n";
10
14
  }
11
15
  }
12
16
  getStopStrings() {
13
- return ["</s><s>[INST]"];
17
+ return ["</s>"];
14
18
  }
15
19
  }
16
20
  //# sourceMappingURL=LlamaChatPromptWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LlamaChatPromptWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/LlamaChatPromptWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;A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cAAc;QAC1B,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ import { LlamaChatPromptWrapper } from "./LlamaChatPromptWrapper.js";
2
+ export declare function getChatWrapperByBos(bos: string | undefined | null): typeof LlamaChatPromptWrapper | null;
@@ -0,0 +1,14 @@
1
+ import { LlamaChatPromptWrapper } from "./LlamaChatPromptWrapper.js";
2
+ import { ChatMLPromptWrapper } from "./ChatMLPromptWrapper.js";
3
+ export function getChatWrapperByBos(bos) {
4
+ if (bos === "" || bos == null)
5
+ return null;
6
+ if ("<s>[INST] <<SYS>>\n".startsWith(bos)) {
7
+ return LlamaChatPromptWrapper;
8
+ }
9
+ else if ("<|im_start|>system\n".startsWith(bos)) {
10
+ return ChatMLPromptWrapper;
11
+ }
12
+ return null;
13
+ }
14
+ //# sourceMappingURL=createChatWrapperByBos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createChatWrapperByBos.js","sourceRoot":"","sources":["../../src/chatWrappers/createChatWrapperByBos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7D,MAAM,UAAU,mBAAmB,CAAC,GAA8B;IAC9D,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,IAAI,IAAI;QACzB,OAAO,IAAI,CAAC;IAEhB,IAAI,qBAAqB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACvC,OAAO,sBAAsB,CAAC;KACjC;SAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC/C,OAAO,mBAAmB,CAAC;KAC9B;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -2,7 +2,9 @@ import { CommandModule } from "yargs";
2
2
  type BuildCommand = {
3
3
  arch?: string;
4
4
  nodeTarget?: string;
5
+ metal: boolean;
6
+ cuda: boolean;
5
7
  };
6
8
  export declare const BuildCommand: CommandModule<object, BuildCommand>;
7
- export declare function BuildLlamaCppCommand({ arch, nodeTarget }: BuildCommand): Promise<void>;
9
+ export declare function BuildLlamaCppCommand({ arch, nodeTarget, metal, cuda }: BuildCommand): Promise<void>;
8
10
  export {};
@@ -1,24 +1,44 @@
1
+ import process from "process";
1
2
  import chalk from "chalk";
2
3
  import { compileLlamaCpp } from "../../utils/compileLLamaCpp.js";
3
4
  import withOra from "../../utils/withOra.js";
4
5
  import { clearTempFolder } from "../../utils/clearTempFolder.js";
6
+ import { defaultLlamaCppCudaSupport, defaultLlamaCppMetalSupport } from "../../config.js";
5
7
  export const BuildCommand = {
6
8
  command: "build",
7
9
  describe: "Compile the currently downloaded llama.cpp",
8
10
  builder(yargs) {
9
11
  return yargs
10
12
  .option("arch", {
13
+ alias: "a",
11
14
  type: "string",
12
15
  description: "The architecture to compile llama.cpp for"
13
16
  })
14
17
  .option("nodeTarget", {
18
+ alias: "t",
15
19
  type: "string",
16
20
  description: "The Node.js version to compile llama.cpp for. Example: v18.0.0"
21
+ })
22
+ .option("metal", {
23
+ type: "boolean",
24
+ default: defaultLlamaCppMetalSupport,
25
+ description: "Compile llama.cpp with Metal support. Can also be set via the NODE_LLAMA_CPP_METAL environment variable"
26
+ })
27
+ .option("cuda", {
28
+ type: "boolean",
29
+ default: defaultLlamaCppCudaSupport,
30
+ description: "Compile llama.cpp with CUDA support. Can also be set via the NODE_LLAMA_CPP_CUDA environment variable"
17
31
  });
18
32
  },
19
33
  handler: BuildLlamaCppCommand
20
34
  };
21
- export async function BuildLlamaCppCommand({ arch, nodeTarget }) {
35
+ export async function BuildLlamaCppCommand({ arch, nodeTarget, metal, cuda }) {
36
+ if (metal && process.platform === "darwin") {
37
+ console.log(`${chalk.yellow("Metal:")} enabled`);
38
+ }
39
+ if (cuda) {
40
+ console.log(`${chalk.yellow("CUDA:")} enabled`);
41
+ }
22
42
  await withOra({
23
43
  loading: chalk.blue("Compiling llama.cpp"),
24
44
  success: chalk.blue("Compiled llama.cpp"),
@@ -27,7 +47,9 @@ export async function BuildLlamaCppCommand({ arch, nodeTarget }) {
27
47
  await compileLlamaCpp({
28
48
  arch: arch ? arch : undefined,
29
49
  nodeTarget: nodeTarget ? nodeTarget : undefined,
30
- setUsedBingFlag: true
50
+ setUsedBingFlag: true,
51
+ metal,
52
+ cuda
31
53
  });
32
54
  });
33
55
  await withOra({
@@ -1 +1 @@
1
- {"version":3,"file":"BuildCommand.js","sourceRoot":"","sources":["../../../src/cli/commands/BuildCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAO/D,MAAM,CAAC,MAAM,YAAY,GAAwC;IAC7D,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,4CAA4C;IACtD,OAAO,CAAC,KAAK;QACT,OAAO,KAAK;aACP,MAAM,CAAC,MAAM,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2CAA2C;SAC3D,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gEAAgE;SAChF,CAAC,CAAC;IACX,CAAC;IACD,OAAO,EAAE,oBAAoB;CAChC,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EAAC,IAAI,EAAE,UAAU,EAAe;IACvE,MAAM,OAAO,CAAC;QACV,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC;QAC1C,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC;QACzC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC;KAClD,EAAE,KAAK,IAAI,EAAE;QACV,MAAM,eAAe,CAAC;YAClB,I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E,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"}
@@ -1,10 +1,16 @@
1
1
  import { CommandModule } from "yargs";
2
+ import type { LlamaGrammar } from "../../llamaEvaluator/LlamaGrammar.js";
2
3
  type ChatCommand = {
3
4
  model: string;
4
5
  systemInfo: boolean;
5
6
  systemPrompt: string;
6
- wrapper: string;
7
+ wrapper: "auto" | "general" | "llamaChat" | "chatML";
7
8
  contextSize: number;
9
+ grammar: "text" | Parameters<typeof LlamaGrammar.getFor>[0];
10
+ temperature: number;
11
+ topK: number;
12
+ topP: number;
13
+ maxTokens: number;
8
14
  };
9
15
  export declare const ChatCommand: CommandModule<object, ChatCommand>;
10
16
  export {};