node-llama-cpp 3.2.0 → 3.3.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/dist/bindings/AddonTypes.d.ts +4 -3
- package/dist/bindings/Llama.d.ts +1 -1
- package/dist/bindings/Llama.js +17 -2
- package/dist/bindings/Llama.js.map +1 -1
- package/dist/bindings/getLlama.d.ts +4 -1
- package/dist/bindings/getLlama.js +42 -2
- package/dist/bindings/getLlama.js.map +1 -1
- package/dist/bindings/utils/compileLLamaCpp.d.ts +1 -1
- package/dist/bindings/utils/compileLLamaCpp.js +41 -2
- package/dist/bindings/utils/compileLLamaCpp.js.map +1 -1
- package/dist/bindings/utils/testBindingBinary.d.ts +2 -1
- package/dist/bindings/utils/testBindingBinary.js +122 -37
- package/dist/bindings/utils/testBindingBinary.js.map +1 -1
- package/dist/chatWrappers/Llama3_1ChatWrapper.js +3 -2
- package/dist/chatWrappers/Llama3_1ChatWrapper.js.map +1 -1
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.d.ts +35 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js +253 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js.map +1 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +13 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +30 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -1
- package/dist/chatWrappers/utils/getModelLinageNames.d.ts +2 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js +18 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js.map +1 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.d.ts +2 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js +9 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js.map +1 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.d.ts +4 -2
- package/dist/chatWrappers/utils/resolveChatWrapper.js +9 -31
- package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -1
- package/dist/cli/commands/ChatCommand.js +1 -1
- package/dist/cli/commands/ChatCommand.js.map +1 -1
- package/dist/cli/commands/InitCommand.d.ts +2 -1
- package/dist/cli/commands/InitCommand.js +32 -13
- package/dist/cli/commands/InitCommand.js.map +1 -1
- package/dist/cli/recommendedModels.js +11 -0
- package/dist/cli/recommendedModels.js.map +1 -1
- package/dist/evaluator/LlamaChat/LlamaChat.js +25 -12
- package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -1
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +140 -132
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -1
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.d.ts +1 -1
- package/dist/evaluator/LlamaGrammar.js +7 -0
- package/dist/evaluator/LlamaGrammar.js.map +1 -1
- package/dist/evaluator/LlamaJsonSchemaGrammar.d.ts +3 -2
- package/dist/evaluator/LlamaJsonSchemaGrammar.js +3 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -1
- package/dist/gguf/fileReaders/GgufFileReader.d.ts +1 -1
- package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +1 -1
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts +5 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js +15 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map +1 -1
- package/dist/utils/gbnfJson/GbnfTerminal.d.ts +3 -0
- package/dist/utils/gbnfJson/GbnfTerminal.js +25 -3
- package/dist/utils/gbnfJson/GbnfTerminal.js.map +1 -1
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts +1 -1
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js +53 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.d.ts +11 -2
- package/dist/utils/gbnfJson/terminals/GbnfArray.js +64 -15
- package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.d.ts +3 -2
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js +13 -7
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js +28 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js +90 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts +4 -1
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js +8 -1
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts +5 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js +24 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js +4 -3
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts +3 -1
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js +8 -2
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +14 -5
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +67 -9
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfOr.d.ts +2 -1
- package/dist/utils/gbnfJson/terminals/GbnfOr.js +6 -2
- package/dist/utils/gbnfJson/terminals/GbnfOr.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +7 -1
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +69 -20
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfString.d.ts +8 -1
- package/dist/utils/gbnfJson/terminals/GbnfString.js +31 -21
- package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts +2 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js +7 -4
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +2 -1
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +24 -5
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +16 -1
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js +47 -1
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -1
- package/dist/utils/gbnfJson/types.d.ts +164 -17
- package/dist/utils/gbnfJson/types.js +6 -0
- package/dist/utils/gbnfJson/types.js.map +1 -1
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +61 -9
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js +99 -8
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map +1 -1
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js +125 -16
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/includesText.d.ts +1 -0
- package/dist/utils/includesText.js +12 -0
- package/dist/utils/includesText.js.map +1 -0
- package/dist/utils/wrapAbortSignal.d.ts +1 -1
- package/dist/utils/wrapAbortSignal.js +9 -4
- package/dist/utils/wrapAbortSignal.js.map +1 -1
- package/llama/CMakeLists.txt +10 -90
- package/llama/addon/AddonGrammar.cpp +49 -1
- package/llama/addon/AddonGrammar.h +3 -0
- package/llama/addon/addon.cpp +17 -0
- package/llama/addon/globals/getGpuInfo.cpp +54 -52
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/gitRelease.bundle +0 -0
- package/llama/gpuInfo/vulkan-gpu-info.cpp +0 -8
- package/llama/gpuInfo/vulkan-gpu-info.h +0 -1
- package/llama/grammars/README.md +1 -1
- package/llama/llama.cpp.info.json +1 -1
- package/package.json +49 -45
- package/templates/README.md +6 -0
- package/templates/packed/electron-typescript-react.json +1 -1
- package/templates/packed/node-typescript.json +1 -1
- package/llama/gpuInfo/cuda-gpu-info.cu +0 -120
- package/llama/gpuInfo/cuda-gpu-info.h +0 -10
- package/llama/gpuInfo/metal-gpu-info.h +0 -8
- package/llama/gpuInfo/metal-gpu-info.mm +0 -37
package/llama/addon/addon.cpp
CHANGED
|
@@ -151,6 +151,22 @@ class AddonBackendUnloadWorker : public Napi::AsyncWorker {
|
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
+
Napi::Value addonLoadBackends(const Napi::CallbackInfo& info) {
|
|
155
|
+
const bool forceLoadLibraries = info.Length() == 0
|
|
156
|
+
? false
|
|
157
|
+
: info[0].IsBoolean()
|
|
158
|
+
? info[0].As<Napi::Boolean>().Value()
|
|
159
|
+
: false;
|
|
160
|
+
|
|
161
|
+
ggml_backend_reg_count();
|
|
162
|
+
|
|
163
|
+
if (forceLoadLibraries) {
|
|
164
|
+
ggml_backend_load_all();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return info.Env().Undefined();
|
|
168
|
+
}
|
|
169
|
+
|
|
154
170
|
Napi::Value addonInit(const Napi::CallbackInfo& info) {
|
|
155
171
|
if (backendInitialized) {
|
|
156
172
|
Napi::Promise::Deferred deferred = Napi::Promise::Deferred::New(info.Env());
|
|
@@ -205,6 +221,7 @@ Napi::Object registerCallback(Napi::Env env, Napi::Object exports) {
|
|
|
205
221
|
Napi::PropertyDescriptor::Function("getGpuDeviceInfo", getGpuDeviceInfo),
|
|
206
222
|
Napi::PropertyDescriptor::Function("getGpuType", getGpuType),
|
|
207
223
|
Napi::PropertyDescriptor::Function("getSwapInfo", getSwapInfo),
|
|
224
|
+
Napi::PropertyDescriptor::Function("loadBackends", addonLoadBackends),
|
|
208
225
|
Napi::PropertyDescriptor::Function("init", addonInit),
|
|
209
226
|
Napi::PropertyDescriptor::Function("dispose", addonDispose),
|
|
210
227
|
});
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
#include "getGpuInfo.h"
|
|
2
2
|
#include "addonLog.h"
|
|
3
3
|
|
|
4
|
-
#ifdef
|
|
5
|
-
#
|
|
4
|
+
#ifdef __APPLE__
|
|
5
|
+
#include <TargetConditionals.h>
|
|
6
6
|
#endif
|
|
7
|
+
|
|
7
8
|
#ifdef GPU_INFO_USE_VULKAN
|
|
8
9
|
# include "../../gpuInfo/vulkan-gpu-info.h"
|
|
9
10
|
#endif
|
|
10
|
-
#ifdef GPU_INFO_USE_METAL
|
|
11
|
-
# include "../../gpuInfo/metal-gpu-info.h"
|
|
12
|
-
#endif
|
|
13
11
|
|
|
14
12
|
|
|
15
|
-
#ifdef GPU_INFO_USE_CUDA
|
|
16
|
-
void logCudaError(const char* message) {
|
|
17
|
-
addonLlamaCppLogCallback(GGML_LOG_LEVEL_ERROR, (std::string("CUDA error: ") + std::string(message)).c_str(), nullptr);
|
|
18
|
-
}
|
|
19
|
-
#endif
|
|
20
13
|
#ifdef GPU_INFO_USE_VULKAN
|
|
21
14
|
void logVulkanWarning(const char* message) {
|
|
22
15
|
addonLlamaCppLogCallback(GGML_LOG_LEVEL_WARN, (std::string("Vulkan warning: ") + std::string(message)).c_str(), nullptr);
|
|
@@ -24,20 +17,31 @@ void logVulkanWarning(const char* message) {
|
|
|
24
17
|
#endif
|
|
25
18
|
|
|
26
19
|
Napi::Value getGpuVramInfo(const Napi::CallbackInfo& info) {
|
|
20
|
+
ggml_backend_dev_t device = NULL;
|
|
21
|
+
size_t deviceTotal = 0;
|
|
22
|
+
size_t deviceFree = 0;
|
|
23
|
+
|
|
27
24
|
uint64_t total = 0;
|
|
28
25
|
uint64_t used = 0;
|
|
29
26
|
uint64_t unifiedVramSize = 0;
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
for (size_t i = 0; i < ggml_backend_dev_count(); i++) {
|
|
29
|
+
device = ggml_backend_dev_get(i);
|
|
30
|
+
if (ggml_backend_dev_type(device) == GGML_BACKEND_DEVICE_TYPE_GPU) {
|
|
31
|
+
deviceTotal = 0;
|
|
32
|
+
deviceFree = 0;
|
|
33
|
+
ggml_backend_dev_memory(device, &deviceFree, &deviceTotal);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
total += deviceTotal;
|
|
36
|
+
used += deviceTotal - deviceFree;
|
|
37
|
+
|
|
38
|
+
#if defined(__arm64__) || defined(__aarch64__)
|
|
39
|
+
if (std::string(ggml_backend_dev_name(device)) == "Metal") {
|
|
40
|
+
unifiedVramSize += deviceTotal;
|
|
41
|
+
}
|
|
40
42
|
#endif
|
|
43
|
+
}
|
|
44
|
+
}
|
|
41
45
|
|
|
42
46
|
#ifdef GPU_INFO_USE_VULKAN
|
|
43
47
|
uint64_t vulkanDeviceTotal = 0;
|
|
@@ -46,23 +50,15 @@ Napi::Value getGpuVramInfo(const Napi::CallbackInfo& info) {
|
|
|
46
50
|
const bool vulkanDeviceSupportsMemoryBudgetExtension = gpuInfoGetTotalVulkanDevicesInfo(&vulkanDeviceTotal, &vulkanDeviceUsed, &vulkanDeviceUnifiedVramSize, logVulkanWarning);
|
|
47
51
|
|
|
48
52
|
if (vulkanDeviceSupportsMemoryBudgetExtension) {
|
|
49
|
-
total
|
|
50
|
-
|
|
53
|
+
if (vulkanDeviceUnifiedVramSize > total) {
|
|
54
|
+
// this means that we counted memory from devices that aren't used by llama.cpp
|
|
55
|
+
vulkanDeviceUnifiedVramSize = 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
unifiedVramSize += vulkanDeviceUnifiedVramSize;
|
|
52
59
|
}
|
|
53
60
|
#endif
|
|
54
61
|
|
|
55
|
-
#ifdef GPU_INFO_USE_METAL
|
|
56
|
-
uint64_t metalDeviceTotal = 0;
|
|
57
|
-
uint64_t metalDeviceUsed = 0;
|
|
58
|
-
uint64_t metalDeviceUnifiedVramSize = 0;
|
|
59
|
-
getMetalGpuInfo(&metalDeviceTotal, &metalDeviceUsed, &metalDeviceUnifiedVramSize);
|
|
60
|
-
|
|
61
|
-
total += metalDeviceTotal;
|
|
62
|
-
used += metalDeviceUsed;
|
|
63
|
-
unifiedVramSize += metalDeviceUnifiedVramSize;
|
|
64
|
-
#endif
|
|
65
|
-
|
|
66
62
|
Napi::Object result = Napi::Object::New(info.Env());
|
|
67
63
|
result.Set("total", Napi::Number::From(info.Env(), total));
|
|
68
64
|
result.Set("used", Napi::Number::From(info.Env(), used));
|
|
@@ -74,17 +70,13 @@ Napi::Value getGpuVramInfo(const Napi::CallbackInfo& info) {
|
|
|
74
70
|
Napi::Value getGpuDeviceInfo(const Napi::CallbackInfo& info) {
|
|
75
71
|
std::vector<std::string> deviceNames;
|
|
76
72
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
for (size_t i = 0; i < ggml_backend_dev_count(); i++) {
|
|
74
|
+
ggml_backend_dev_t device = ggml_backend_dev_get(i);
|
|
75
|
+
if (ggml_backend_dev_type(device) == GGML_BACKEND_DEVICE_TYPE_GPU) {
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#ifdef GPU_INFO_USE_METAL
|
|
86
|
-
getMetalGpuDeviceNames(&deviceNames);
|
|
87
|
-
#endif
|
|
77
|
+
deviceNames.push_back(std::string(ggml_backend_dev_description(device)));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
88
80
|
|
|
89
81
|
Napi::Object result = Napi::Object::New(info.Env());
|
|
90
82
|
|
|
@@ -98,17 +90,27 @@ Napi::Value getGpuDeviceInfo(const Napi::CallbackInfo& info) {
|
|
|
98
90
|
}
|
|
99
91
|
|
|
100
92
|
Napi::Value getGpuType(const Napi::CallbackInfo& info) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
for (size_t i = 0; i < ggml_backend_dev_count(); i++) {
|
|
94
|
+
ggml_backend_dev_t device = ggml_backend_dev_get(i);
|
|
95
|
+
const auto deviceName = std::string(ggml_backend_dev_name(device));
|
|
96
|
+
|
|
97
|
+
if (deviceName == "Metal") {
|
|
98
|
+
return Napi::String::New(info.Env(), "metal");
|
|
99
|
+
} else if (std::string(deviceName).find("Vulkan") == 0) {
|
|
100
|
+
return Napi::String::New(info.Env(), "vulkan");
|
|
101
|
+
} else if (std::string(deviceName).find("CUDA") == 0 || std::string(deviceName).find("ROCm") == 0 || std::string(deviceName).find("MUSA") == 0) {
|
|
102
|
+
return Napi::String::New(info.Env(), "cuda");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
108
105
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
for (size_t i = 0; i < ggml_backend_dev_count(); i++) {
|
|
107
|
+
ggml_backend_dev_t device = ggml_backend_dev_get(i);
|
|
108
|
+
const auto deviceName = std::string(ggml_backend_dev_name(device));
|
|
109
|
+
|
|
110
|
+
if (deviceName == "CPU") {
|
|
111
|
+
return Napi::Boolean::New(info.Env(), false);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
112
114
|
|
|
113
115
|
return info.Env().Undefined();
|
|
114
|
-
}
|
|
116
|
+
}
|
package/llama/gitRelease.bundle
CHANGED
|
Binary file
|
|
@@ -80,11 +80,3 @@ static bool enumerateVulkanDevices(size_t* total, size_t* used, size_t* unifiedM
|
|
|
80
80
|
bool gpuInfoGetTotalVulkanDevicesInfo(size_t* total, size_t* used, size_t* unifiedMemorySize, gpuInfoVulkanWarningLogCallback_t warningLogCallback) {
|
|
81
81
|
return enumerateVulkanDevices(total, used, unifiedMemorySize, false, nullptr, warningLogCallback);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
bool gpuInfoGetVulkanDeviceNames(std::vector<std::string> * deviceNames, gpuInfoVulkanWarningLogCallback_t warningLogCallback) {
|
|
85
|
-
size_t vulkanDeviceTotal = 0;
|
|
86
|
-
size_t vulkanDeviceUsed = 0;
|
|
87
|
-
size_t unifiedMemorySize = 0;
|
|
88
|
-
|
|
89
|
-
return enumerateVulkanDevices(&vulkanDeviceTotal, &vulkanDeviceUsed, &unifiedMemorySize, true, deviceNames, warningLogCallback);
|
|
90
|
-
}
|
|
@@ -6,4 +6,3 @@
|
|
|
6
6
|
typedef void (*gpuInfoVulkanWarningLogCallback_t)(const char* message);
|
|
7
7
|
|
|
8
8
|
bool gpuInfoGetTotalVulkanDevicesInfo(size_t* total, size_t* used, size_t* unifiedMemorySize, gpuInfoVulkanWarningLogCallback_t warningLogCallback);
|
|
9
|
-
bool gpuInfoGetVulkanDeviceNames(std::vector<std::string> * deviceNames, gpuInfoVulkanWarningLogCallback_t warningLogCallback);
|
package/llama/grammars/README.md
CHANGED
|
@@ -124,7 +124,7 @@ You can use GBNF grammars:
|
|
|
124
124
|
- In [llama-cli](../examples/main), passed as the `--json` / `-j` flag
|
|
125
125
|
- To convert to a grammar ahead of time:
|
|
126
126
|
- in CLI, with [examples/json_schema_to_grammar.py](../examples/json_schema_to_grammar.py)
|
|
127
|
-
- in JavaScript with [json-schema-to-grammar.mjs](../examples/server/
|
|
127
|
+
- in JavaScript with [json-schema-to-grammar.mjs](../examples/server/public_legacy/json-schema-to-grammar.mjs) (this is used by the [server](../examples/server)'s Web UI)
|
|
128
128
|
|
|
129
129
|
Take a look at [tests](../tests/test-json-schema-to-grammar.cpp) to see which features are likely supported (you'll also find usage examples in https://github.com/ggerganov/llama.cpp/pull/5978, https://github.com/ggerganov/llama.cpp/pull/6659 & https://github.com/ggerganov/llama.cpp/pull/6555).
|
|
130
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-llama-cpp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Run AI models locally on your machine with node.js bindings for llama.cpp. Enforce a JSON schema on the model output on the generation level",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -112,7 +112,10 @@
|
|
|
112
112
|
"batching",
|
|
113
113
|
"gpu"
|
|
114
114
|
],
|
|
115
|
-
"author":
|
|
115
|
+
"author": {
|
|
116
|
+
"name": "Gilad S.",
|
|
117
|
+
"url": "https://github.com/giladgd"
|
|
118
|
+
},
|
|
116
119
|
"license": "MIT",
|
|
117
120
|
"preferUnplugged": true,
|
|
118
121
|
"bugs": {
|
|
@@ -124,52 +127,53 @@
|
|
|
124
127
|
},
|
|
125
128
|
"homepage": "https://node-llama-cpp.withcat.ai",
|
|
126
129
|
"devDependencies": {
|
|
127
|
-
"@commitlint/cli": "^19.
|
|
128
|
-
"@commitlint/config-conventional": "^19.
|
|
129
|
-
"@eslint/compat": "^1.2.
|
|
130
|
+
"@commitlint/cli": "^19.6.0",
|
|
131
|
+
"@commitlint/config-conventional": "^19.6.0",
|
|
132
|
+
"@eslint/compat": "^1.2.3",
|
|
130
133
|
"@fontsource/inter": "^5.1.0",
|
|
131
|
-
"@nolebase/vitepress-plugin-git-changelog": "^2.
|
|
132
|
-
"@nolebase/vitepress-plugin-og-image": "^2.
|
|
134
|
+
"@nolebase/vitepress-plugin-git-changelog": "^2.11.1",
|
|
135
|
+
"@nolebase/vitepress-plugin-og-image": "^2.11.1",
|
|
133
136
|
"@resvg/resvg-js": "^2.6.2",
|
|
134
137
|
"@semantic-release/exec": "^6.0.3",
|
|
135
|
-
"@semantic-release/github": "11.0.
|
|
138
|
+
"@semantic-release/github": "11.0.1",
|
|
136
139
|
"@semantic-release/npm": "12.0.1",
|
|
137
|
-
"@shikijs/vitepress-twoslash": "^1.
|
|
138
|
-
"@stylistic/eslint-plugin": "^2.
|
|
140
|
+
"@shikijs/vitepress-twoslash": "^1.24.0",
|
|
141
|
+
"@stylistic/eslint-plugin": "^2.11.0",
|
|
139
142
|
"@types/async-retry": "^1.4.9",
|
|
140
143
|
"@types/bytes": "^3.1.4",
|
|
141
144
|
"@types/cross-spawn": "^6.0.2",
|
|
142
145
|
"@types/fs-extra": "^11.0.4",
|
|
143
|
-
"@types/node": "^22.
|
|
146
|
+
"@types/node": "^22.10.1",
|
|
144
147
|
"@types/proper-lockfile": "^4.1.4",
|
|
145
148
|
"@types/semver": "^7.5.8",
|
|
146
149
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
147
150
|
"@types/which": "^3.0.4",
|
|
148
151
|
"@types/yargs": "^17.0.33",
|
|
149
|
-
"@vitest/coverage-v8": "^2.1.
|
|
150
|
-
"@vitest/ui": "^2.1.
|
|
151
|
-
"
|
|
152
|
+
"@vitest/coverage-v8": "^2.1.6",
|
|
153
|
+
"@vitest/ui": "^2.1.6",
|
|
154
|
+
"electron": "^33.2.1",
|
|
155
|
+
"eslint": "^9.16.0",
|
|
152
156
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
153
157
|
"eslint-plugin-import": "^2.31.0",
|
|
154
|
-
"eslint-plugin-jsdoc": "^50.
|
|
155
|
-
"eslint-plugin-n": "^17.
|
|
158
|
+
"eslint-plugin-jsdoc": "^50.6.0",
|
|
159
|
+
"eslint-plugin-n": "^17.14.0",
|
|
156
160
|
"feed": "^4.2.2",
|
|
157
|
-
"husky": "^9.1.
|
|
161
|
+
"husky": "^9.1.7",
|
|
158
162
|
"rehype": "^13.0.1",
|
|
159
163
|
"rimraf": "^6.0.1",
|
|
160
164
|
"semantic-release": "^24.2.0",
|
|
161
165
|
"sharp": "^0.33.5",
|
|
162
|
-
"tslib": "^2.8.
|
|
163
|
-
"typedoc": "^0.
|
|
164
|
-
"typedoc-plugin-markdown": "^4.
|
|
165
|
-
"typedoc-plugin-mdn-links": "^
|
|
166
|
-
"typedoc-vitepress-theme": "^1.0
|
|
167
|
-
"typescript": "^5.
|
|
168
|
-
"typescript-eslint": "^8.
|
|
169
|
-
"vite-node": "^2.1.
|
|
170
|
-
"vitepress": "^1.
|
|
171
|
-
"vitest": "^2.1.
|
|
172
|
-
"zx": "^8.
|
|
166
|
+
"tslib": "^2.8.1",
|
|
167
|
+
"typedoc": "^0.27.2",
|
|
168
|
+
"typedoc-plugin-markdown": "^4.3.1",
|
|
169
|
+
"typedoc-plugin-mdn-links": "^4.0.3",
|
|
170
|
+
"typedoc-vitepress-theme": "^1.1.0",
|
|
171
|
+
"typescript": "^5.7.2",
|
|
172
|
+
"typescript-eslint": "^8.16.0",
|
|
173
|
+
"vite-node": "^2.1.6",
|
|
174
|
+
"vitepress": "^1.5.0",
|
|
175
|
+
"vitest": "^2.1.6",
|
|
176
|
+
"zx": "^8.2.4"
|
|
173
177
|
},
|
|
174
178
|
"dependencies": {
|
|
175
179
|
"@huggingface/jinja": "^0.3.2",
|
|
@@ -179,20 +183,20 @@
|
|
|
179
183
|
"chmodrp": "^1.0.2",
|
|
180
184
|
"cmake-js": "^7.3.0",
|
|
181
185
|
"cross-env": "^7.0.3",
|
|
182
|
-
"cross-spawn": "^7.0.
|
|
186
|
+
"cross-spawn": "^7.0.6",
|
|
183
187
|
"env-var": "^7.5.0",
|
|
184
188
|
"filenamify": "^6.0.0",
|
|
185
189
|
"fs-extra": "^11.2.0",
|
|
186
190
|
"ignore": "^5.3.2",
|
|
187
|
-
"ipull": "^3.9.
|
|
191
|
+
"ipull": "^3.9.2",
|
|
188
192
|
"is-unicode-supported": "^2.1.0",
|
|
189
193
|
"lifecycle-utils": "^1.7.0",
|
|
190
194
|
"log-symbols": "^7.0.0",
|
|
191
|
-
"nanoid": "^5.0.
|
|
192
|
-
"node-addon-api": "^8.
|
|
195
|
+
"nanoid": "^5.0.9",
|
|
196
|
+
"node-addon-api": "^8.3.0",
|
|
193
197
|
"octokit": "^4.0.2",
|
|
194
|
-
"ora": "^8.1.
|
|
195
|
-
"pretty-ms": "^9.
|
|
198
|
+
"ora": "^8.1.1",
|
|
199
|
+
"pretty-ms": "^9.2.0",
|
|
196
200
|
"proper-lockfile": "^4.1.2",
|
|
197
201
|
"semver": "^7.6.3",
|
|
198
202
|
"simple-git": "^3.27.0",
|
|
@@ -212,16 +216,16 @@
|
|
|
212
216
|
}
|
|
213
217
|
},
|
|
214
218
|
"optionalDependencies": {
|
|
215
|
-
"@node-llama-cpp/linux-arm64": "3.
|
|
216
|
-
"@node-llama-cpp/linux-armv7l": "3.
|
|
217
|
-
"@node-llama-cpp/linux-x64": "3.
|
|
218
|
-
"@node-llama-cpp/linux-x64-cuda": "3.
|
|
219
|
-
"@node-llama-cpp/linux-x64-vulkan": "3.
|
|
220
|
-
"@node-llama-cpp/mac-arm64-metal": "3.
|
|
221
|
-
"@node-llama-cpp/mac-x64": "3.
|
|
222
|
-
"@node-llama-cpp/win-arm64": "3.
|
|
223
|
-
"@node-llama-cpp/win-x64": "3.
|
|
224
|
-
"@node-llama-cpp/win-x64-cuda": "3.
|
|
225
|
-
"@node-llama-cpp/win-x64-vulkan": "3.
|
|
219
|
+
"@node-llama-cpp/linux-arm64": "3.3.0",
|
|
220
|
+
"@node-llama-cpp/linux-armv7l": "3.3.0",
|
|
221
|
+
"@node-llama-cpp/linux-x64": "3.3.0",
|
|
222
|
+
"@node-llama-cpp/linux-x64-cuda": "3.3.0",
|
|
223
|
+
"@node-llama-cpp/linux-x64-vulkan": "3.3.0",
|
|
224
|
+
"@node-llama-cpp/mac-arm64-metal": "3.3.0",
|
|
225
|
+
"@node-llama-cpp/mac-x64": "3.3.0",
|
|
226
|
+
"@node-llama-cpp/win-arm64": "3.3.0",
|
|
227
|
+
"@node-llama-cpp/win-x64": "3.3.0",
|
|
228
|
+
"@node-llama-cpp/win-x64-cuda": "3.3.0",
|
|
229
|
+
"@node-llama-cpp/win-x64-vulkan": "3.3.0"
|
|
226
230
|
}
|
|
227
231
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Use the following command to scaffold a project from a template:
|
|
2
|
+
```bash
|
|
3
|
+
npm create node-llama-cpp@latest
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
> Don't use the templates in this repository directly. They are built to be used with `npm create` command ([learn more](https://node-llama-cpp.withcat.ai/guide/))
|