node-llama-cpp 3.0.0-beta.15 → 3.0.0-beta.17
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/dist/ChatWrapper.d.ts +1 -15
- package/dist/ChatWrapper.js +19 -29
- package/dist/ChatWrapper.js.map +1 -1
- package/dist/bindings/AddonTypes.d.ts +5 -1
- package/dist/bindings/Llama.d.ts +7 -0
- package/dist/bindings/Llama.js +12 -1
- package/dist/bindings/Llama.js.map +1 -1
- package/dist/bindings/getLlama.d.ts +2 -2
- package/dist/bindings/getLlama.js +1 -1
- package/dist/bindings/getLlama.js.map +1 -1
- package/dist/bindings/utils/cloneLlamaCppRepo.js +23 -23
- package/dist/bindings/utils/cloneLlamaCppRepo.js.map +1 -1
- package/dist/chatWrappers/FunctionaryChatWrapper.js +39 -40
- package/dist/chatWrappers/FunctionaryChatWrapper.js.map +1 -1
- package/dist/chatWrappers/{LlamaChatWrapper.d.ts → Llama2ChatWrapper.d.ts} +1 -1
- package/dist/chatWrappers/{LlamaChatWrapper.js → Llama2ChatWrapper.js} +3 -3
- package/dist/chatWrappers/Llama2ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3ChatWrapper.d.ts +31 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js +129 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +2 -2
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js +6 -2
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js.map +1 -1
- package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +2 -2
- package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -1
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +42 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +82 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +1 -1
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js.map +1 -1
- package/dist/chatWrappers/utils/resolveChatWrapper.d.ts +6 -4
- package/dist/chatWrappers/utils/resolveChatWrapper.js +26 -18
- package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -1
- package/dist/cli/commands/BuildCommand.js +1 -1
- package/dist/cli/commands/BuildCommand.js.map +1 -1
- package/dist/cli/commands/ChatCommand.d.ts +4 -1
- package/dist/cli/commands/ChatCommand.js +93 -81
- package/dist/cli/commands/ChatCommand.js.map +1 -1
- package/dist/cli/commands/CompleteCommand.d.ts +4 -1
- package/dist/cli/commands/CompleteCommand.js +82 -61
- package/dist/cli/commands/CompleteCommand.js.map +1 -1
- package/dist/cli/commands/DebugCommand.js +4 -4
- package/dist/cli/commands/DownloadCommand.js +3 -4
- package/dist/cli/commands/DownloadCommand.js.map +1 -1
- package/dist/cli/commands/InfillCommand.d.ts +4 -1
- package/dist/cli/commands/InfillCommand.js +84 -65
- package/dist/cli/commands/InfillCommand.js.map +1 -1
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +2 -1
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +20 -7
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js.map +1 -1
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js +42 -4
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -1
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +4 -1
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +69 -36
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js.map +1 -1
- package/dist/cli/recommendedModels.d.ts +2 -0
- package/dist/cli/recommendedModels.js +350 -0
- package/dist/cli/recommendedModels.js.map +1 -0
- package/dist/cli/utils/ConsoleInteraction.d.ts +23 -0
- package/dist/cli/utils/ConsoleInteraction.js +122 -0
- package/dist/cli/utils/ConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/ConsoleTable.js +5 -5
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.d.ts +13 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js +111 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/consolePromptQuestion.d.ts +5 -0
- package/dist/cli/utils/consolePromptQuestion.js +80 -0
- package/dist/cli/utils/consolePromptQuestion.js.map +1 -0
- package/dist/cli/utils/getReadablePath.d.ts +1 -0
- package/dist/cli/utils/getReadablePath.js +14 -0
- package/dist/cli/utils/getReadablePath.js.map +1 -0
- package/dist/cli/utils/printCommonInfoLines.js +5 -4
- package/dist/cli/utils/printCommonInfoLines.js.map +1 -1
- package/dist/cli/utils/printInfoLine.d.ts +4 -2
- package/dist/cli/utils/printInfoLine.js +15 -6
- package/dist/cli/utils/printInfoLine.js.map +1 -1
- package/dist/cli/utils/resolveCommandGgufPath.d.ts +2 -1
- package/dist/cli/utils/resolveCommandGgufPath.js +551 -2
- package/dist/cli/utils/resolveCommandGgufPath.js.map +1 -1
- package/dist/cli/utils/resolveHeaderFlag.d.ts +1 -0
- package/dist/cli/utils/resolveHeaderFlag.js +21 -0
- package/dist/cli/utils/resolveHeaderFlag.js.map +1 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.d.ts +19 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js +10 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js.map +1 -0
- package/dist/cli/utils/splitAnsiToLines.d.ts +1 -0
- package/dist/cli/utils/splitAnsiToLines.js +17 -0
- package/dist/cli/utils/splitAnsiToLines.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +5 -2
- package/dist/config.js.map +1 -1
- package/dist/consts.d.ts +2 -0
- package/dist/consts.js +8 -0
- package/dist/consts.js.map +1 -1
- package/dist/evaluator/LlamaChat/LlamaChat.d.ts +9 -2
- package/dist/evaluator/LlamaChat/LlamaChat.js +58 -22
- package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -1
- package/dist/evaluator/LlamaChat/utils/FunctionCallGrammar.js +3 -1
- package/dist/evaluator/LlamaChat/utils/FunctionCallGrammar.js.map +1 -1
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +10 -3
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +5 -3
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -1
- package/dist/evaluator/LlamaCompletion.d.ts +11 -4
- package/dist/evaluator/LlamaCompletion.js +16 -15
- package/dist/evaluator/LlamaCompletion.js.map +1 -1
- package/dist/evaluator/LlamaContext/LlamaContext.d.ts +13 -23
- package/dist/evaluator/LlamaContext/LlamaContext.js +47 -60
- package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -1
- package/dist/evaluator/LlamaEmbeddingContext.js +1 -1
- package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -1
- package/dist/evaluator/LlamaGrammar.d.ts +3 -2
- package/dist/evaluator/LlamaGrammar.js +3 -2
- package/dist/evaluator/LlamaGrammar.js.map +1 -1
- package/dist/evaluator/LlamaModel.d.ts +21 -18
- package/dist/evaluator/LlamaModel.js +34 -205
- package/dist/evaluator/LlamaModel.js.map +1 -1
- package/dist/evaluator/TokenBias.d.ts +22 -0
- package/dist/evaluator/TokenBias.js +33 -0
- package/dist/evaluator/TokenBias.js.map +1 -0
- package/dist/gguf/{GgufInsights.d.ts → insights/GgufInsights.d.ts} +5 -3
- package/dist/gguf/{GgufInsights.js → insights/GgufInsights.js} +46 -35
- package/dist/gguf/insights/GgufInsights.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +87 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +136 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +18 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +52 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +14 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +177 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js.map +1 -0
- package/dist/gguf/insights/utils/scoreLevels.d.ts +5 -0
- package/dist/gguf/insights/utils/scoreLevels.js +16 -0
- package/dist/gguf/insights/utils/scoreLevels.js.map +1 -0
- package/dist/gguf/readGgufFileInfo.js +2 -1
- package/dist/gguf/readGgufFileInfo.js.map +1 -1
- package/dist/gguf/types/GgufMetadataTypes.d.ts +4 -0
- package/dist/gguf/types/GgufMetadataTypes.js.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +21 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/LlamaText.d.ts +2 -1
- package/dist/utils/LlamaText.js +20 -0
- package/dist/utils/LlamaText.js.map +1 -1
- package/dist/utils/StopGenerationDetector.js +19 -18
- package/dist/utils/StopGenerationDetector.js.map +1 -1
- package/dist/utils/TokenStreamRegulator.d.ts +4 -2
- package/dist/utils/TokenStreamRegulator.js +22 -4
- package/dist/utils/TokenStreamRegulator.js.map +1 -1
- package/dist/utils/getConsoleLogPrefix.js +1 -1
- package/dist/utils/getReadableContextSize.d.ts +1 -0
- package/dist/utils/getReadableContextSize.js +7 -0
- package/dist/utils/getReadableContextSize.js.map +1 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js +15 -11
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/isToken.d.ts +2 -0
- package/dist/utils/isToken.js +4 -0
- package/dist/utils/isToken.js.map +1 -0
- package/dist/utils/isUrl.d.ts +1 -0
- package/dist/utils/isUrl.js +15 -0
- package/dist/utils/isUrl.js.map +1 -0
- package/dist/utils/tokenizeInput.d.ts +1 -1
- package/dist/utils/tokenizeInput.js +3 -0
- package/dist/utils/tokenizeInput.js.map +1 -1
- package/dist/utils/utilTypes.d.ts +3 -0
- package/dist/utils/utilTypes.js +2 -0
- package/dist/utils/utilTypes.js.map +1 -0
- package/dist/utils/withOra.d.ts +1 -0
- package/dist/utils/withOra.js +13 -7
- package/dist/utils/withOra.js.map +1 -1
- package/dist/utils/withProgressLog.d.ts +23 -0
- package/dist/utils/withProgressLog.js +211 -0
- package/dist/utils/withProgressLog.js.map +1 -0
- package/dist/utils/withStatusLogs.js +1 -1
- package/dist/utils/withStatusLogs.js.map +1 -1
- package/llama/addon.cpp +90 -10
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/gitRelease.bundle +0 -0
- package/llama/grammars/README.md +10 -0
- package/llama/llama.cpp.info.json +1 -1
- package/llamaBins/linux-arm64/_nlcBuildMetadata.json +1 -1
- package/llamaBins/linux-arm64/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l/_nlcBuildMetadata.json +1 -1
- package/llamaBins/linux-armv7l/llama-addon.node +0 -0
- package/llamaBins/linux-x64/_nlcBuildMetadata.json +1 -1
- package/llamaBins/linux-x64/llama-addon.node +0 -0
- package/llamaBins/linux-x64-cuda/_nlcBuildMetadata.json +1 -1
- package/llamaBins/linux-x64-cuda/llama-addon.node +0 -0
- package/llamaBins/linux-x64-vulkan/_nlcBuildMetadata.json +1 -1
- package/llamaBins/linux-x64-vulkan/llama-addon.node +0 -0
- package/llamaBins/mac-arm64-metal/_nlcBuildMetadata.json +1 -1
- package/llamaBins/mac-arm64-metal/default.metallib +0 -0
- package/llamaBins/mac-arm64-metal/llama-addon.node +0 -0
- package/llamaBins/mac-x64/_nlcBuildMetadata.json +1 -1
- package/llamaBins/mac-x64/llama-addon.node +0 -0
- package/llamaBins/win-arm64/_nlcBuildMetadata.json +1 -1
- package/llamaBins/win-arm64/llama-addon.node +0 -0
- package/llamaBins/win-x64/_nlcBuildMetadata.json +1 -1
- package/llamaBins/win-x64/llama-addon.node +0 -0
- package/llamaBins/win-x64-cuda/_nlcBuildMetadata.json +1 -1
- package/llamaBins/win-x64-cuda/llama-addon.node +0 -0
- package/llamaBins/win-x64-vulkan/_nlcBuildMetadata.json +1 -1
- package/llamaBins/win-x64-vulkan/llama-addon.node +0 -0
- package/package.json +9 -7
- package/dist/chatWrappers/LlamaChatWrapper.js.map +0 -1
- package/dist/gguf/GgufInsights.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseModelFileName } from "../../utils/parseModelFileName.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Llama3ChatWrapper } from "../Llama3ChatWrapper.js";
|
|
3
|
+
import { Llama2ChatWrapper } from "../Llama2ChatWrapper.js";
|
|
3
4
|
import { ChatMLChatWrapper } from "../ChatMLChatWrapper.js";
|
|
4
5
|
import { GeneralChatWrapper } from "../GeneralChatWrapper.js";
|
|
5
6
|
import { FalconChatWrapper } from "../FalconChatWrapper.js";
|
|
@@ -11,7 +12,7 @@ import { TemplateChatWrapper } from "../generic/TemplateChatWrapper.js";
|
|
|
11
12
|
import { getConsoleLogPrefix } from "../../utils/getConsoleLogPrefix.js";
|
|
12
13
|
import { isJinjaTemplateEquivalentToSpecializedChatWrapper } from "./isJinjaTemplateEquivalentToSpecializedChatWrapper.js";
|
|
13
14
|
export const specializedChatWrapperTypeNames = Object.freeze([
|
|
14
|
-
"general", "
|
|
15
|
+
"general", "llama3Chat", "llama2Chat", "alpacaChat", "functionary", "chatML", "falconChat", "gemma"
|
|
15
16
|
]);
|
|
16
17
|
export const templateChatWrapperTypeNames = Object.freeze([
|
|
17
18
|
"template", "jinjaTemplate"
|
|
@@ -23,7 +24,8 @@ export const resolvableChatWrapperTypeNames = Object.freeze([
|
|
|
23
24
|
]);
|
|
24
25
|
const chatWrappers = {
|
|
25
26
|
"general": GeneralChatWrapper,
|
|
26
|
-
"
|
|
27
|
+
"llama3Chat": Llama3ChatWrapper,
|
|
28
|
+
"llama2Chat": Llama2ChatWrapper,
|
|
27
29
|
"alpacaChat": AlpacaChatWrapper,
|
|
28
30
|
"functionary": FunctionaryChatWrapper,
|
|
29
31
|
"chatML": ChatMLChatWrapper,
|
|
@@ -100,7 +102,7 @@ export function resolveChatWrapper({ type = "auto", bosString, filename, fileInf
|
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
const modelJinjaTemplate = customWrapperSettings?.jinjaTemplate?.template ?? fileInfo?.metadata?.tokenizer?.chat_template;
|
|
103
|
-
if (
|
|
105
|
+
if (modelJinjaTemplate != null && modelJinjaTemplate.trim() !== "") {
|
|
104
106
|
const jinjaTemplateChatWrapperOptions = {
|
|
105
107
|
...(customWrapperSettings?.jinjaTemplate ?? {}),
|
|
106
108
|
template: modelJinjaTemplate
|
|
@@ -121,13 +123,15 @@ export function resolveChatWrapper({ type = "auto", bosString, filename, fileInf
|
|
|
121
123
|
return new Wrapper(testChatWrapperSettings);
|
|
122
124
|
}
|
|
123
125
|
}
|
|
124
|
-
if (!
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
if (!noJinja) {
|
|
127
|
+
if (!fallbackToOtherWrappersOnJinjaError)
|
|
128
|
+
return new JinjaTemplateChatWrapper(jinjaTemplateChatWrapperOptions);
|
|
129
|
+
try {
|
|
130
|
+
return new JinjaTemplateChatWrapper(jinjaTemplateChatWrapperOptions);
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
console.error(getConsoleLogPrefix() + "Error creating Jinja template chat wrapper. Falling back to resolve other chat wrappers. Error:", err);
|
|
134
|
+
}
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
// try to find a pattern in the Jinja template to resolve to a specialized chat wrapper,
|
|
@@ -136,9 +140,11 @@ export function resolveChatWrapper({ type = "auto", bosString, filename, fileInf
|
|
|
136
140
|
if (modelJinjaTemplate.includes("<|im_start|>"))
|
|
137
141
|
return createSpecializedChatWrapper(ChatMLChatWrapper);
|
|
138
142
|
else if (modelJinjaTemplate.includes("[INST]"))
|
|
139
|
-
return createSpecializedChatWrapper(
|
|
143
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper, {
|
|
140
144
|
addSpaceBeforeEos: modelJinjaTemplate.includes("' ' + eos_token")
|
|
141
145
|
});
|
|
146
|
+
else if (modelJinjaTemplate.includes("<|start_header_id|>") && modelJinjaTemplate.includes("<|end_header_id|>"))
|
|
147
|
+
return createSpecializedChatWrapper(Llama3ChatWrapper);
|
|
142
148
|
else if (modelJinjaTemplate.includes("<start_of_turn>"))
|
|
143
149
|
return createSpecializedChatWrapper(GemmaChatWrapper);
|
|
144
150
|
}
|
|
@@ -151,19 +157,21 @@ export function resolveChatWrapper({ type = "auto", bosString, filename, fileInf
|
|
|
151
157
|
const firstSplitLowercaseSubType = splitLowercaseSubType[0];
|
|
152
158
|
if (lowercaseName === "llama") {
|
|
153
159
|
if (splitLowercaseSubType.includes("chat"))
|
|
154
|
-
return createSpecializedChatWrapper(
|
|
160
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper);
|
|
155
161
|
return createSpecializedChatWrapper(GeneralChatWrapper);
|
|
156
162
|
}
|
|
163
|
+
else if (lowercaseName === "codellama")
|
|
164
|
+
return createSpecializedChatWrapper(GeneralChatWrapper);
|
|
157
165
|
else if (lowercaseName === "yarn" && firstSplitLowercaseSubType === "llama")
|
|
158
|
-
return createSpecializedChatWrapper(
|
|
166
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper);
|
|
159
167
|
else if (lowercaseName === "orca")
|
|
160
168
|
return createSpecializedChatWrapper(ChatMLChatWrapper);
|
|
161
169
|
else if (lowercaseName === "phind" && lowercaseSubType === "codellama")
|
|
162
|
-
return createSpecializedChatWrapper(
|
|
170
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper);
|
|
163
171
|
else if (lowercaseName === "mistral")
|
|
164
172
|
return createSpecializedChatWrapper(GeneralChatWrapper);
|
|
165
173
|
else if (firstSplitLowercaseSubType === "llama")
|
|
166
|
-
return createSpecializedChatWrapper(
|
|
174
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper);
|
|
167
175
|
else if (lowercaseSubType === "alpaca")
|
|
168
176
|
return createSpecializedChatWrapper(AlpacaChatWrapper);
|
|
169
177
|
else if (lowercaseName === "functionary")
|
|
@@ -179,14 +187,14 @@ export function resolveChatWrapper({ type = "auto", bosString, filename, fileInf
|
|
|
179
187
|
if (fileInfo != null) {
|
|
180
188
|
const arch = fileInfo.metadata.general?.architecture;
|
|
181
189
|
if (arch === "llama")
|
|
182
|
-
return createSpecializedChatWrapper(
|
|
190
|
+
return createSpecializedChatWrapper(GeneralChatWrapper);
|
|
183
191
|
else if (arch === "falcon")
|
|
184
192
|
return createSpecializedChatWrapper(FalconChatWrapper);
|
|
185
193
|
}
|
|
186
194
|
if (bosString === "" || bosString == null)
|
|
187
195
|
return null;
|
|
188
196
|
if ("<s>[INST] <<SYS>>\n".startsWith(bosString)) {
|
|
189
|
-
return createSpecializedChatWrapper(
|
|
197
|
+
return createSpecializedChatWrapper(Llama2ChatWrapper);
|
|
190
198
|
}
|
|
191
199
|
else if ("<|im_start|>system\n".startsWith(bosString)) {
|
|
192
200
|
return createSpecializedChatWrapper(ChatMLChatWrapper);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveChatWrapper.js","sourceRoot":"","sources":["../../../src/chatWrappers/utils/resolveChatWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"resolveChatWrapper.js","sourceRoot":"","sources":["../../../src/chatWrappers/utils/resolveChatWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC1D,OA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,CAAC;gBAC7C,OAAO,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;SAC9D;KACJ;IAED,IAAI,QAAQ,IAAI,IAAI,EAAE;QAClB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;QAErD,IAAI,IAAI,KAAK,OAAO;YAChB,OAAO,4BAA4B,CAAC,kBAAkB,CAAC,CAAC;aACvD,IAAI,IAAI,KAAK,QAAQ;YACtB,OAAO,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;KAC9D;IAED,IAAI,SAAS,KAAK,EAAE,IAAI,SAAS,IAAI,IAAI;QACrC,OAAO,IAAI,CAAC;IAEhB,IAAI,qBAAqB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7C,OAAO,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;KAC1D;SAAM,IAAI,sBAAsB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QACrD,OAAO,4BAA4B,CAAC,iBAAiB,CAAC,CAAC;KAC1D;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAY;IACrD,OAAO,+BAA+B,CAAC,QAAQ,CAAC,IAAW,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAY;IAClD,OAAO,4BAA4B,CAAC,QAAQ,CAAC,IAAW,CAAC,CAAC;AAC9D,CAAC;AAED,0FAA0F;AAC1F,SAAS,gBAAgB,CAAI,KAAU,EAAE,cAAiB;IACtD,OAAO,KAAK,KAAK,cAAc,CAAC;AACpC,CAAC"}
|
|
@@ -30,7 +30,7 @@ export const BuildCommand = {
|
|
|
30
30
|
.option("nodeTarget", {
|
|
31
31
|
alias: "t",
|
|
32
32
|
type: "string",
|
|
33
|
-
description: "The Node.js version to compile llama.cpp for. Example: v18.0.0"
|
|
33
|
+
description: "The Node.js version to compile llama.cpp for. Example: `v18.0.0`"
|
|
34
34
|
})
|
|
35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AAC,GAAG,EAAE,CAAC;YACd,8BAA8B,CAAC,YAAY,EAAE,GAAG,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC;YACnE,OAAO,CAAC,GAAG,EAAE,CAAC;SACjB;QAED,MAAM;KACT;AACL,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { CommandModule } from "yargs";
|
|
2
2
|
import { LlamaGrammar } from "../../evaluator/LlamaGrammar.js";
|
|
3
|
+
import { BuildGpu } from "../../bindings/types.js";
|
|
3
4
|
import { SpecializedChatWrapperTypeName } from "../../chatWrappers/utils/resolveChatWrapper.js";
|
|
4
5
|
type ChatCommand = {
|
|
5
|
-
|
|
6
|
+
modelPath?: string;
|
|
7
|
+
header?: string[];
|
|
8
|
+
gpu?: BuildGpu | "auto";
|
|
6
9
|
systemInfo: boolean;
|
|
7
10
|
systemPrompt: string;
|
|
8
11
|
systemPromptFile?: string;
|
|
@@ -11,7 +11,7 @@ import { getLlama } from "../../bindings/getLlama.js";
|
|
|
11
11
|
import { LlamaGrammar } from "../../evaluator/LlamaGrammar.js";
|
|
12
12
|
import { LlamaChatSession } from "../../evaluator/LlamaChatSession/LlamaChatSession.js";
|
|
13
13
|
import { LlamaJsonSchemaGrammar } from "../../evaluator/LlamaJsonSchemaGrammar.js";
|
|
14
|
-
import { LlamaLogLevel, LlamaLogLevelGreaterThan } from "../../bindings/types.js";
|
|
14
|
+
import { LlamaLogLevel, LlamaLogLevelGreaterThan, nodeLlamaCppGpuOptions, parseNodeLlamaCppGpuOption } from "../../bindings/types.js";
|
|
15
15
|
import withOra from "../../utils/withOra.js";
|
|
16
16
|
import { TokenMeter } from "../../evaluator/TokenMeter.js";
|
|
17
17
|
import { printInfoLine } from "../utils/printInfoLine.js";
|
|
@@ -19,25 +19,42 @@ import { resolveChatWrapper, specializedChatWrapperTypeNames } from "../../chatW
|
|
|
19
19
|
import { GeneralChatWrapper } from "../../chatWrappers/GeneralChatWrapper.js";
|
|
20
20
|
import { printCommonInfoLines } from "../utils/printCommonInfoLines.js";
|
|
21
21
|
import { resolveCommandGgufPath } from "../utils/resolveCommandGgufPath.js";
|
|
22
|
+
import { withProgressLog } from "../../utils/withProgressLog.js";
|
|
23
|
+
import { resolveHeaderFlag } from "../utils/resolveHeaderFlag.js";
|
|
22
24
|
export const ChatCommand = {
|
|
23
25
|
command: "chat [modelPath]",
|
|
24
26
|
describe: "Chat with a Llama model",
|
|
25
27
|
builder(yargs) {
|
|
26
28
|
const isInDocumentationMode = getIsInDocumentationMode();
|
|
27
29
|
return yargs
|
|
28
|
-
.option("
|
|
29
|
-
alias: ["m", "
|
|
30
|
+
.option("modelPath", {
|
|
31
|
+
alias: ["m", "model", "path", "url"],
|
|
30
32
|
type: "string",
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
description: "Llama model file to use for the chat. Can be a path to a local file or a URL of a model file to download"
|
|
34
|
+
})
|
|
35
|
+
.option("header", {
|
|
36
|
+
alias: ["H"],
|
|
37
|
+
type: "string",
|
|
38
|
+
array: true,
|
|
39
|
+
description: "Headers to use when downloading a model from a URL, in the format `key: value`. You can pass this option multiple times to add multiple headers."
|
|
40
|
+
})
|
|
41
|
+
.option("gpu", {
|
|
42
|
+
type: "string",
|
|
43
|
+
// yargs types don't support passing `false` as a choice, although it is supported by yargs
|
|
44
|
+
choices: nodeLlamaCppGpuOptions,
|
|
45
|
+
coerce: (value) => {
|
|
46
|
+
if (value == null || value == "")
|
|
47
|
+
return undefined;
|
|
48
|
+
return parseNodeLlamaCppGpuOption(value);
|
|
49
|
+
},
|
|
50
|
+
defaultDescription: "Uses the latest local build, and fallbacks to \"auto\"",
|
|
51
|
+
description: "Compute layer implementation type to use for llama.cpp. If omitted, uses the latest local build, and fallbacks to \"auto\""
|
|
34
52
|
})
|
|
35
53
|
.option("systemInfo", {
|
|
36
54
|
alias: "i",
|
|
37
55
|
type: "boolean",
|
|
38
56
|
default: false,
|
|
39
|
-
description: "Print llama.cpp system info"
|
|
40
|
-
group: "Optional:"
|
|
57
|
+
description: "Print llama.cpp system info"
|
|
41
58
|
})
|
|
42
59
|
.option("systemPrompt", {
|
|
43
60
|
alias: "s",
|
|
@@ -45,195 +62,167 @@ export const ChatCommand = {
|
|
|
45
62
|
default: defaultChatSystemPrompt,
|
|
46
63
|
defaultDescription: " ",
|
|
47
64
|
description: "System prompt to use against the model" +
|
|
48
|
-
(isInDocumentationMode ? "" : (". [default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]"))
|
|
49
|
-
group: "Optional:"
|
|
65
|
+
(isInDocumentationMode ? "" : (". [default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]"))
|
|
50
66
|
})
|
|
51
67
|
.option("systemPromptFile", {
|
|
52
68
|
type: "string",
|
|
53
|
-
description: "Path to a file to load text from and use as as the model system prompt"
|
|
54
|
-
group: "Optional:"
|
|
69
|
+
description: "Path to a file to load text from and use as as the model system prompt"
|
|
55
70
|
})
|
|
56
71
|
.option("prompt", {
|
|
57
72
|
type: "string",
|
|
58
|
-
description: "First prompt to automatically send to the model when starting the chat"
|
|
59
|
-
group: "Optional:"
|
|
73
|
+
description: "First prompt to automatically send to the model when starting the chat"
|
|
60
74
|
})
|
|
61
75
|
.option("promptFile", {
|
|
62
76
|
type: "string",
|
|
63
|
-
description: "Path to a file to load text from and use as a first prompt to automatically send to the model when starting the chat"
|
|
64
|
-
group: "Optional:"
|
|
77
|
+
description: "Path to a file to load text from and use as a first prompt to automatically send to the model when starting the chat"
|
|
65
78
|
})
|
|
66
79
|
.option("wrapper", {
|
|
67
80
|
alias: "w",
|
|
68
81
|
type: "string",
|
|
69
82
|
default: "auto",
|
|
70
83
|
choices: ["auto", ...specializedChatWrapperTypeNames],
|
|
71
|
-
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token"
|
|
72
|
-
group: "Optional:"
|
|
84
|
+
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token"
|
|
73
85
|
})
|
|
74
86
|
.option("noJinja", {
|
|
75
87
|
type: "boolean",
|
|
76
88
|
default: false,
|
|
77
|
-
description: "Don't use a Jinja wrapper, even if it's the best option for the model"
|
|
78
|
-
group: "Optional:"
|
|
89
|
+
description: "Don't use a Jinja wrapper, even if it's the best option for the model"
|
|
79
90
|
})
|
|
80
91
|
.option("contextSize", {
|
|
81
92
|
alias: "c",
|
|
82
93
|
type: "number",
|
|
83
94
|
description: "Context size to use for the model context",
|
|
84
95
|
default: -1,
|
|
85
|
-
defaultDescription: "Automatically determined based on the available VRAM"
|
|
86
|
-
group: "Optional:"
|
|
96
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
87
97
|
})
|
|
88
98
|
.option("batchSize", {
|
|
89
99
|
alias: "b",
|
|
90
100
|
type: "number",
|
|
91
|
-
description: "Batch size to use for the model context. The default value is the context size"
|
|
92
|
-
group: "Optional:"
|
|
101
|
+
description: "Batch size to use for the model context. The default value is the context size"
|
|
93
102
|
})
|
|
94
103
|
.option("noTrimWhitespace", {
|
|
95
104
|
type: "boolean",
|
|
96
105
|
alias: ["noTrim"],
|
|
97
106
|
default: false,
|
|
98
|
-
description: "Don't trim whitespaces from the model response"
|
|
99
|
-
group: "Optional:"
|
|
107
|
+
description: "Don't trim whitespaces from the model response"
|
|
100
108
|
})
|
|
101
109
|
.option("grammar", {
|
|
102
110
|
alias: "g",
|
|
103
111
|
type: "string",
|
|
104
112
|
default: "text",
|
|
105
113
|
choices: ["text", "json", "list", "arithmetic", "japanese", "chess"],
|
|
106
|
-
description: "Restrict the model response to a specific grammar, like JSON for example"
|
|
107
|
-
group: "Optional:"
|
|
114
|
+
description: "Restrict the model response to a specific grammar, like JSON for example"
|
|
108
115
|
})
|
|
109
116
|
.option("jsonSchemaGrammarFile", {
|
|
110
117
|
alias: ["jsgf"],
|
|
111
118
|
type: "string",
|
|
112
|
-
description: "File path to a JSON schema file, to restrict the model response to only generate output that conforms to the JSON schema"
|
|
113
|
-
group: "Optional:"
|
|
119
|
+
description: "File path to a JSON schema file, to restrict the model response to only generate output that conforms to the JSON schema"
|
|
114
120
|
})
|
|
115
121
|
.option("threads", {
|
|
116
122
|
type: "number",
|
|
117
123
|
default: 6,
|
|
118
|
-
description: "Number of threads to use for the evaluation of tokens"
|
|
119
|
-
group: "Optional:"
|
|
124
|
+
description: "Number of threads to use for the evaluation of tokens"
|
|
120
125
|
})
|
|
121
126
|
.option("temperature", {
|
|
122
127
|
alias: "t",
|
|
123
128
|
type: "number",
|
|
124
129
|
default: 0,
|
|
125
|
-
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."
|
|
126
|
-
group: "Optional:"
|
|
130
|
+
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."
|
|
127
131
|
})
|
|
128
132
|
.option("minP", {
|
|
129
133
|
alias: "mp",
|
|
130
134
|
type: "number",
|
|
131
135
|
default: 0,
|
|
132
|
-
description: "From the next token candidates, discard the percentage of tokens with the lowest probability. For example, if set to `0.05`, 5% of the lowest probability tokens will be discarded. This is useful for generating more high-quality results when using a high temperature. Set to a value between `0` and `1` to enable. Only relevant when `temperature` is set to a value greater than `0`."
|
|
133
|
-
group: "Optional:"
|
|
136
|
+
description: "From the next token candidates, discard the percentage of tokens with the lowest probability. For example, if set to `0.05`, 5% of the lowest probability tokens will be discarded. This is useful for generating more high-quality results when using a high temperature. Set to a value between `0` and `1` to enable. Only relevant when `temperature` is set to a value greater than `0`."
|
|
134
137
|
})
|
|
135
138
|
.option("topK", {
|
|
136
139
|
alias: "k",
|
|
137
140
|
type: "number",
|
|
138
141
|
default: 40,
|
|
139
|
-
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."
|
|
140
|
-
group: "Optional:"
|
|
142
|
+
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."
|
|
141
143
|
})
|
|
142
144
|
.option("topP", {
|
|
143
145
|
alias: "p",
|
|
144
146
|
type: "number",
|
|
145
147
|
default: 0.95,
|
|
146
|
-
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`."
|
|
147
|
-
group: "Optional:"
|
|
148
|
+
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`."
|
|
148
149
|
})
|
|
149
150
|
.option("gpuLayers", {
|
|
150
151
|
alias: "gl",
|
|
151
152
|
type: "number",
|
|
152
153
|
description: "number of layers to store in VRAM",
|
|
153
154
|
default: -1,
|
|
154
|
-
defaultDescription: "Automatically determined based on the available VRAM"
|
|
155
|
-
group: "Optional:"
|
|
155
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
156
156
|
})
|
|
157
157
|
.option("repeatPenalty", {
|
|
158
158
|
alias: "rp",
|
|
159
159
|
type: "number",
|
|
160
160
|
default: 1.1,
|
|
161
|
-
description: "Prevent the model from repeating the same token too much. Set to `1` to disable."
|
|
162
|
-
group: "Optional:"
|
|
161
|
+
description: "Prevent the model from repeating the same token too much. Set to `1` to disable."
|
|
163
162
|
})
|
|
164
163
|
.option("lastTokensRepeatPenalty", {
|
|
165
164
|
alias: "rpn",
|
|
166
165
|
type: "number",
|
|
167
166
|
default: 64,
|
|
168
|
-
description: "Number of recent tokens generated by the model to apply penalties to repetition of"
|
|
169
|
-
group: "Optional:"
|
|
167
|
+
description: "Number of recent tokens generated by the model to apply penalties to repetition of"
|
|
170
168
|
})
|
|
171
169
|
.option("penalizeRepeatingNewLine", {
|
|
172
170
|
alias: "rpnl",
|
|
173
171
|
type: "boolean",
|
|
174
172
|
default: true,
|
|
175
|
-
description: "Penalize new line tokens. set
|
|
176
|
-
group: "Optional:"
|
|
173
|
+
description: "Penalize new line tokens. set `--no-penalizeRepeatingNewLine` or `--no-rpnl` to disable"
|
|
177
174
|
})
|
|
178
175
|
.option("repeatFrequencyPenalty", {
|
|
179
176
|
alias: "rfp",
|
|
180
177
|
type: "number",
|
|
181
|
-
description: "For n time a token is in the `punishTokens` array, lower its probability by `n * repeatFrequencyPenalty`. Set to a value between `0` and `1` to enable."
|
|
182
|
-
group: "Optional:"
|
|
178
|
+
description: "For n time a token is in the `punishTokens` array, lower its probability by `n * repeatFrequencyPenalty`. Set to a value between `0` and `1` to enable."
|
|
183
179
|
})
|
|
184
180
|
.option("repeatPresencePenalty", {
|
|
185
181
|
alias: "rpp",
|
|
186
182
|
type: "number",
|
|
187
|
-
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable."
|
|
188
|
-
group: "Optional:"
|
|
183
|
+
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable."
|
|
189
184
|
})
|
|
190
185
|
.option("maxTokens", {
|
|
191
186
|
alias: "mt",
|
|
192
187
|
type: "number",
|
|
193
188
|
default: 0,
|
|
194
|
-
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size"
|
|
195
|
-
group: "Optional:"
|
|
189
|
+
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size"
|
|
196
190
|
})
|
|
197
191
|
.option("noHistory", {
|
|
198
192
|
alias: "nh",
|
|
199
193
|
type: "boolean",
|
|
200
194
|
default: false,
|
|
201
|
-
description: "Don't load or save chat history"
|
|
202
|
-
group: "Optional:"
|
|
195
|
+
description: "Don't load or save chat history"
|
|
203
196
|
})
|
|
204
197
|
.option("environmentFunctions", {
|
|
205
198
|
alias: "ef",
|
|
206
199
|
type: "boolean",
|
|
207
200
|
default: false,
|
|
208
|
-
description: "Provide access to environment functions like `getDate` and `getTime`"
|
|
209
|
-
group: "Optional:"
|
|
201
|
+
description: "Provide access to environment functions like `getDate` and `getTime`"
|
|
210
202
|
})
|
|
211
203
|
.option("debug", {
|
|
212
204
|
alias: "d",
|
|
213
205
|
type: "boolean",
|
|
214
206
|
default: false,
|
|
215
|
-
description: "Print llama.cpp info and debug logs"
|
|
216
|
-
group: "Optional:"
|
|
207
|
+
description: "Print llama.cpp info and debug logs"
|
|
217
208
|
})
|
|
218
209
|
.option("meter", {
|
|
219
210
|
type: "boolean",
|
|
220
211
|
default: false,
|
|
221
|
-
description: "
|
|
222
|
-
group: "Optional:"
|
|
212
|
+
description: "Print how many tokens were used as input and output for each response"
|
|
223
213
|
})
|
|
224
214
|
.option("printTimings", {
|
|
225
215
|
alias: "pt",
|
|
226
216
|
type: "boolean",
|
|
227
217
|
default: false,
|
|
228
|
-
description: "Print llama.cpp timings after each response"
|
|
229
|
-
group: "Optional:"
|
|
218
|
+
description: "Print llama.cpp timings after each response"
|
|
230
219
|
});
|
|
231
220
|
},
|
|
232
|
-
async handler({
|
|
221
|
+
async handler({ modelPath, header, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize, batchSize, noTrimWhitespace, grammar, jsonSchemaGrammarFile, threads, temperature, minP, topK, topP, gpuLayers, repeatPenalty, lastTokensRepeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens, noHistory, environmentFunctions, debug, meter, printTimings }) {
|
|
233
222
|
try {
|
|
234
223
|
await RunChat({
|
|
235
|
-
|
|
236
|
-
noTrimWhitespace, grammar, jsonSchemaGrammarFile, threads, temperature, minP, topK, topP, gpuLayers,
|
|
224
|
+
modelPath, header, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize,
|
|
225
|
+
batchSize, noTrimWhitespace, grammar, jsonSchemaGrammarFile, threads, temperature, minP, topK, topP, gpuLayers,
|
|
237
226
|
lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens,
|
|
238
227
|
noHistory, environmentFunctions, debug, meter, printTimings
|
|
239
228
|
});
|
|
@@ -245,22 +234,28 @@ export const ChatCommand = {
|
|
|
245
234
|
}
|
|
246
235
|
}
|
|
247
236
|
};
|
|
248
|
-
async function RunChat({
|
|
237
|
+
async function RunChat({ modelPath: modelArg, header: headerArg, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize, batchSize, noTrimWhitespace, grammar: grammarArg, jsonSchemaGrammarFile: jsonSchemaGrammarFilePath, threads, temperature, minP, topK, topP, gpuLayers, lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens, noHistory, environmentFunctions, debug, meter, printTimings }) {
|
|
249
238
|
if (contextSize === -1)
|
|
250
239
|
contextSize = undefined;
|
|
251
240
|
if (gpuLayers === -1)
|
|
252
241
|
gpuLayers = undefined;
|
|
242
|
+
const headers = resolveHeaderFlag(headerArg);
|
|
253
243
|
const trimWhitespace = !noTrimWhitespace;
|
|
254
244
|
if (debug)
|
|
255
245
|
console.info(`${chalk.yellow("Log level:")} debug`);
|
|
256
|
-
const resolvedModelPath = await resolveCommandGgufPath(modelArg);
|
|
257
246
|
const llamaLogLevel = debug
|
|
258
247
|
? LlamaLogLevel.debug
|
|
259
248
|
: LlamaLogLevel.warn;
|
|
260
|
-
const llama =
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
const llama = gpu == null
|
|
250
|
+
? await getLlama("lastBuild", {
|
|
251
|
+
logLevel: llamaLogLevel
|
|
252
|
+
})
|
|
253
|
+
: await getLlama({
|
|
254
|
+
gpu,
|
|
255
|
+
logLevel: llamaLogLevel
|
|
256
|
+
});
|
|
263
257
|
const logBatchSize = batchSize != null;
|
|
258
|
+
const resolvedModelPath = await resolveCommandGgufPath(modelArg, llama, headers);
|
|
264
259
|
if (systemInfo)
|
|
265
260
|
console.log(llama.systemInfo);
|
|
266
261
|
if (systemPromptFile != null && systemPromptFile !== "") {
|
|
@@ -278,18 +273,34 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, systemPrompt
|
|
|
278
273
|
batchSize = contextSize;
|
|
279
274
|
}
|
|
280
275
|
let initialPrompt = prompt ?? null;
|
|
281
|
-
const model = await
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
276
|
+
const model = await withProgressLog({
|
|
277
|
+
loadingText: chalk.blue.bold("Loading model"),
|
|
278
|
+
successText: chalk.blue("Model loaded"),
|
|
279
|
+
failText: chalk.blue("Failed to load model"),
|
|
280
|
+
liveUpdates: !debug,
|
|
281
|
+
noProgress: debug,
|
|
282
|
+
liveCtrlCSendsAbortSignal: true
|
|
283
|
+
}, async (progressUpdater) => {
|
|
287
284
|
try {
|
|
288
285
|
return await llama.loadModel({
|
|
289
286
|
modelPath: resolvedModelPath,
|
|
290
|
-
gpuLayers: gpuLayers != null
|
|
287
|
+
gpuLayers: gpuLayers != null
|
|
288
|
+
? gpuLayers
|
|
289
|
+
: contextSize != null
|
|
290
|
+
? { fitContext: { contextSize } }
|
|
291
|
+
: undefined,
|
|
292
|
+
ignoreMemorySafetyChecks: gpuLayers != null,
|
|
293
|
+
onLoadProgress(loadProgress) {
|
|
294
|
+
progressUpdater.setProgress(loadProgress);
|
|
295
|
+
},
|
|
296
|
+
loadSignal: progressUpdater.abortSignal
|
|
291
297
|
});
|
|
292
298
|
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
if (err === progressUpdater.abortSignal?.reason)
|
|
301
|
+
process.exit(0);
|
|
302
|
+
throw err;
|
|
303
|
+
}
|
|
293
304
|
finally {
|
|
294
305
|
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
295
306
|
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
@@ -307,7 +318,8 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, systemPrompt
|
|
|
307
318
|
return await model.createContext({
|
|
308
319
|
contextSize: contextSize != null ? contextSize : undefined,
|
|
309
320
|
batchSize: batchSize != null ? batchSize : undefined,
|
|
310
|
-
threads
|
|
321
|
+
threads,
|
|
322
|
+
ignoreMemorySafetyChecks: gpuLayers != null || contextSize != null
|
|
311
323
|
});
|
|
312
324
|
}
|
|
313
325
|
finally {
|
|
@@ -327,7 +339,7 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, systemPrompt
|
|
|
327
339
|
bosString: model.tokens.bosString,
|
|
328
340
|
filename: model.filename,
|
|
329
341
|
fileInfo: model.fileInfo,
|
|
330
|
-
tokenizer: model.
|
|
342
|
+
tokenizer: model.tokenizer,
|
|
331
343
|
noJinja
|
|
332
344
|
}) ?? new GeneralChatWrapper();
|
|
333
345
|
const contextSequence = context.getSequence();
|