@fugood/llama.node 1.2.3 → 1.2.5
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/package.json +14 -14
- package/scripts/llama.cpp.patch +33 -11
- package/src/llama.cpp/CMakeLists.txt +1 -0
- package/src/llama.cpp/common/CMakeLists.txt +46 -2
- package/src/llama.cpp/common/arg.cpp +484 -204
- package/src/llama.cpp/common/arg.h +0 -1
- package/src/llama.cpp/common/chat-parser.cpp +156 -15
- package/src/llama.cpp/common/chat-parser.h +3 -0
- package/src/llama.cpp/common/chat.cpp +217 -6
- package/src/llama.cpp/common/chat.h +5 -3
- package/src/llama.cpp/common/common.cpp +22 -6
- package/src/llama.cpp/common/common.h +6 -4
- package/src/llama.cpp/common/http.h +73 -0
- package/src/llama.cpp/common/json-partial.cpp +51 -0
- package/src/llama.cpp/ggml/CMakeLists.txt +7 -6
- package/src/llama.cpp/ggml/include/ggml-backend.h +2 -0
- package/src/llama.cpp/ggml/include/ggml-rpc.h +8 -9
- package/src/llama.cpp/ggml/include/ggml.h +22 -0
- package/src/llama.cpp/ggml/src/CMakeLists.txt +3 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +12 -2
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/amx.cpp +1 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/arch/loongarch/quants.c +12 -12
- package/src/llama.cpp/ggml/src/ggml-cpu/arch/s390/quants.c +100 -3
- package/src/llama.cpp/ggml/src/ggml-cpu/arch-fallback.h +0 -1
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +1 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +10 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.cpp +209 -96
- package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.h +32 -44
- package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +107 -83
- package/src/llama.cpp/ggml/src/ggml-cpu/ops.cpp +17 -17
- package/src/llama.cpp/ggml/src/ggml-cpu/simd-mappings.h +8 -8
- package/src/llama.cpp/ggml/src/ggml-cpu/spacemit/ime.cpp +1024 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/unary-ops.cpp +103 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/unary-ops.h +1 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/vec.cpp +66 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/vec.h +11 -9
- package/src/llama.cpp/include/llama.h +8 -0
- package/src/llama.cpp/src/llama-arch.cpp +93 -0
- package/src/llama.cpp/src/llama-arch.h +22 -0
- package/src/llama.cpp/src/llama-chat.cpp +1 -1
- package/src/llama.cpp/src/llama-context.cpp +6 -0
- package/src/llama.cpp/src/llama-graph.cpp +57 -22
- package/src/llama.cpp/src/llama-graph.h +10 -1
- package/src/llama.cpp/src/llama-hparams.cpp +5 -1
- package/src/llama.cpp/src/llama-hparams.h +17 -2
- package/src/llama.cpp/src/llama-kv-cache-iswa.cpp +2 -2
- package/src/llama.cpp/src/llama-kv-cache.cpp +2 -5
- package/src/llama.cpp/src/llama-memory-hybrid.cpp +11 -9
- package/src/llama.cpp/src/llama-memory-recurrent.cpp +11 -3
- package/src/llama.cpp/src/llama-model-loader.cpp +2 -0
- package/src/llama.cpp/src/llama-model.cpp +572 -45
- package/src/llama.cpp/src/llama-model.h +18 -0
- package/src/llama.cpp/src/llama-sampling.cpp +5 -0
- package/src/llama.cpp/src/llama-vocab.cpp +7 -1
- package/src/llama.cpp/src/llama-vocab.h +41 -40
- package/src/llama.cpp/src/unicode.h +43 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/llama.node",
|
|
3
3
|
"access": "public",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.5",
|
|
5
5
|
"description": "An another Node binding of llama.cpp",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -72,19 +72,19 @@
|
|
|
72
72
|
"CMakeLists.txt"
|
|
73
73
|
],
|
|
74
74
|
"optionalDependencies": {
|
|
75
|
-
"@fugood/node-llama-linux-x64": "1.2.
|
|
76
|
-
"@fugood/node-llama-linux-x64-vulkan": "1.2.
|
|
77
|
-
"@fugood/node-llama-linux-x64-cuda": "1.2.
|
|
78
|
-
"@fugood/node-llama-linux-arm64": "1.2.
|
|
79
|
-
"@fugood/node-llama-linux-arm64-vulkan": "1.2.
|
|
80
|
-
"@fugood/node-llama-linux-arm64-cuda": "1.2.
|
|
81
|
-
"@fugood/node-llama-win32-x64": "1.2.
|
|
82
|
-
"@fugood/node-llama-win32-x64-vulkan": "1.2.
|
|
83
|
-
"@fugood/node-llama-win32-x64-cuda": "1.2.
|
|
84
|
-
"@fugood/node-llama-win32-arm64": "1.2.
|
|
85
|
-
"@fugood/node-llama-win32-arm64-vulkan": "1.2.
|
|
86
|
-
"@fugood/node-llama-darwin-x64": "1.2.
|
|
87
|
-
"@fugood/node-llama-darwin-arm64": "1.2.
|
|
75
|
+
"@fugood/node-llama-linux-x64": "1.2.5",
|
|
76
|
+
"@fugood/node-llama-linux-x64-vulkan": "1.2.5",
|
|
77
|
+
"@fugood/node-llama-linux-x64-cuda": "1.2.5",
|
|
78
|
+
"@fugood/node-llama-linux-arm64": "1.2.5",
|
|
79
|
+
"@fugood/node-llama-linux-arm64-vulkan": "1.2.5",
|
|
80
|
+
"@fugood/node-llama-linux-arm64-cuda": "1.2.5",
|
|
81
|
+
"@fugood/node-llama-win32-x64": "1.2.5",
|
|
82
|
+
"@fugood/node-llama-win32-x64-vulkan": "1.2.5",
|
|
83
|
+
"@fugood/node-llama-win32-x64-cuda": "1.2.5",
|
|
84
|
+
"@fugood/node-llama-win32-arm64": "1.2.5",
|
|
85
|
+
"@fugood/node-llama-win32-arm64-vulkan": "1.2.5",
|
|
86
|
+
"@fugood/node-llama-darwin-x64": "1.2.5",
|
|
87
|
+
"@fugood/node-llama-darwin-arm64": "1.2.5"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@babel/preset-env": "^7.24.4",
|
package/scripts/llama.cpp.patch
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
diff --git a/src/llama.cpp/common/CMakeLists.txt b/src/llama.cpp/common/CMakeLists.txt
|
|
2
|
+
index fe290bf8f..d377e29b9 100644
|
|
3
|
+
--- a/src/llama.cpp/common/CMakeLists.txt
|
|
4
|
+
+++ b/src/llama.cpp/common/CMakeLists.txt
|
|
5
|
+
@@ -170,9 +170,16 @@ if (LLAMA_LLGUIDANCE)
|
|
6
|
+
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} llguidance ${LLGUIDANCE_PLATFORM_LIBS})
|
|
7
|
+
endif ()
|
|
8
|
+
|
|
9
|
+
+# Add Windows socket libraries unconditionally on Windows
|
|
10
|
+
+if (WIN32)
|
|
11
|
+
+ set(LLAMA_COMMON_WIN_LIBS ws2_32)
|
|
12
|
+
+else()
|
|
13
|
+
+ set(LLAMA_COMMON_WIN_LIBS "")
|
|
14
|
+
+endif()
|
|
15
|
+
+
|
|
16
|
+
target_include_directories(${TARGET} PUBLIC . ../vendor)
|
|
17
|
+
target_compile_features (${TARGET} PUBLIC cxx_std_17)
|
|
18
|
+
-target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
|
|
19
|
+
+target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} ${LLAMA_COMMON_WIN_LIBS} PUBLIC llama Threads::Threads)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
#
|
|
1
23
|
diff --git a/src/llama.cpp/common/chat.cpp b/src/llama.cpp/common/chat.cpp
|
|
2
|
-
index
|
|
24
|
+
index 8587140e1..7931a31a1 100644
|
|
3
25
|
--- a/src/llama.cpp/common/chat.cpp
|
|
4
26
|
+++ b/src/llama.cpp/common/chat.cpp
|
|
5
27
|
@@ -6,9 +6,6 @@
|
|
@@ -29,7 +51,7 @@ index 111b4a21b..16ce87672 100644
|
|
|
29
51
|
struct templates_params {
|
|
30
52
|
json messages;
|
|
31
53
|
json tools;
|
|
32
|
-
@@ -
|
|
54
|
+
@@ -807,8 +794,7 @@ static std::string apply(
|
|
33
55
|
if (additional_context) {
|
|
34
56
|
tmpl_inputs.extra_context.merge_patch(*additional_context);
|
|
35
57
|
}
|
|
@@ -40,7 +62,7 @@ index 111b4a21b..16ce87672 100644
|
|
|
40
62
|
minja::chat_template_options tmpl_opts;
|
|
41
63
|
// To avoid double BOS / EOS tokens, we're manually removing begining / trailing tokens
|
|
42
64
|
diff --git a/src/llama.cpp/common/chat.h b/src/llama.cpp/common/chat.h
|
|
43
|
-
index
|
|
65
|
+
index f7b36ec71..c07429f08 100644
|
|
44
66
|
--- a/src/llama.cpp/common/chat.h
|
|
45
67
|
+++ b/src/llama.cpp/common/chat.h
|
|
46
68
|
@@ -9,7 +9,18 @@
|
|
@@ -64,10 +86,10 @@ index d1e480c91..437e64e29 100644
|
|
|
64
86
|
struct common_chat_tool_call {
|
|
65
87
|
std::string name;
|
|
66
88
|
diff --git a/src/llama.cpp/common/common.cpp b/src/llama.cpp/common/common.cpp
|
|
67
|
-
index
|
|
89
|
+
index b0591e84b..93759f884 100644
|
|
68
90
|
--- a/src/llama.cpp/common/common.cpp
|
|
69
91
|
+++ b/src/llama.cpp/common/common.cpp
|
|
70
|
-
@@ -
|
|
92
|
+
@@ -1126,6 +1126,7 @@ struct llama_model_params common_model_params_to_llama(common_params & params) {
|
|
71
93
|
mparams.n_gpu_layers = params.n_gpu_layers;
|
|
72
94
|
}
|
|
73
95
|
|
|
@@ -76,10 +98,10 @@ index fdce1dcde..55aac3412 100644
|
|
|
76
98
|
mparams.split_mode = params.split_mode;
|
|
77
99
|
mparams.tensor_split = params.tensor_split;
|
|
78
100
|
diff --git a/src/llama.cpp/common/common.h b/src/llama.cpp/common/common.h
|
|
79
|
-
index
|
|
101
|
+
index 040a44ebd..37ad69173 100644
|
|
80
102
|
--- a/src/llama.cpp/common/common.h
|
|
81
103
|
+++ b/src/llama.cpp/common/common.h
|
|
82
|
-
@@ -
|
|
104
|
+
@@ -274,6 +274,7 @@ struct lr_opt {
|
|
83
105
|
struct ggml_opt_optimizer_params common_opt_lr_pars(void * userdata);
|
|
84
106
|
|
|
85
107
|
struct common_params {
|
|
@@ -88,7 +110,7 @@ index 390dda5e5..f259ca785 100644
|
|
|
88
110
|
int32_t n_ctx = 4096; // context size
|
|
89
111
|
int32_t n_batch = 2048; // logical batch size for prompt processing (must be >=32 to use BLAS)
|
|
90
112
|
diff --git a/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt b/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt
|
|
91
|
-
index
|
|
113
|
+
index 42041b717..371752718 100644
|
|
92
114
|
--- a/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt
|
|
93
115
|
+++ b/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt
|
|
94
116
|
@@ -106,7 +106,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
|
|
@@ -101,10 +123,10 @@ index ce0a3e128..df9300224 100644
|
|
|
101
123
|
check_cxx_compiler_flag(-mfp16-format=ieee GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E)
|
|
102
124
|
if (NOT "${GGML_COMPILER_SUPPORTS_FP16_FORMAT_I3E}" STREQUAL "")
|
|
103
125
|
diff --git a/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt b/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt
|
|
104
|
-
index
|
|
126
|
+
index 83a83887b..8ae962b29 100644
|
|
105
127
|
--- a/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt
|
|
106
128
|
+++ b/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt
|
|
107
|
-
@@ -
|
|
129
|
+
@@ -112,7 +112,7 @@ if (Vulkan_FOUND)
|
|
108
130
|
endif()
|
|
109
131
|
|
|
110
132
|
# Set up toolchain for host compilation whether cross-compiling or not
|
|
@@ -113,7 +135,7 @@ index b97e7bf99..c3eb9519f 100644
|
|
|
113
135
|
if (GGML_VULKAN_SHADERS_GEN_TOOLCHAIN)
|
|
114
136
|
set(HOST_CMAKE_TOOLCHAIN_FILE ${GGML_VULKAN_SHADERS_GEN_TOOLCHAIN})
|
|
115
137
|
else()
|
|
116
|
-
@@ -
|
|
138
|
+
@@ -132,7 +132,7 @@ if (Vulkan_FOUND)
|
|
117
139
|
|
|
118
140
|
include(ExternalProject)
|
|
119
141
|
|
|
@@ -92,6 +92,7 @@ option(LLAMA_TOOLS_INSTALL "llama: install tools" ${LLAMA_TOOLS_INSTALL_
|
|
|
92
92
|
|
|
93
93
|
# 3rd party libs
|
|
94
94
|
option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON)
|
|
95
|
+
option(LLAMA_OPENSSL "llama: use openssl to support HTTPS" OFF)
|
|
95
96
|
option(LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF)
|
|
96
97
|
|
|
97
98
|
# Required for relocatable CMake package
|
|
@@ -56,6 +56,7 @@ add_library(${TARGET} STATIC
|
|
|
56
56
|
common.h
|
|
57
57
|
console.cpp
|
|
58
58
|
console.h
|
|
59
|
+
http.h
|
|
59
60
|
json-partial.cpp
|
|
60
61
|
json-partial.h
|
|
61
62
|
json-schema-to-grammar.cpp
|
|
@@ -87,7 +88,43 @@ if (LLAMA_CURL)
|
|
|
87
88
|
target_compile_definitions(${TARGET} PUBLIC LLAMA_USE_CURL)
|
|
88
89
|
include_directories(${CURL_INCLUDE_DIRS})
|
|
89
90
|
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} ${CURL_LIBRARIES})
|
|
90
|
-
endif
|
|
91
|
+
endif()
|
|
92
|
+
|
|
93
|
+
if (LLAMA_OPENSSL)
|
|
94
|
+
find_package(OpenSSL)
|
|
95
|
+
if (OpenSSL_FOUND)
|
|
96
|
+
include(CheckCSourceCompiles)
|
|
97
|
+
set(SAVED_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
|
|
98
|
+
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
99
|
+
check_c_source_compiles("
|
|
100
|
+
#include <openssl/opensslv.h>
|
|
101
|
+
#if defined(OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER)
|
|
102
|
+
# if OPENSSL_VERSION_NUMBER < 0x1010107f
|
|
103
|
+
# error bad version
|
|
104
|
+
# endif
|
|
105
|
+
#else
|
|
106
|
+
# if OPENSSL_VERSION_NUMBER < 0x30000000L
|
|
107
|
+
# error bad version
|
|
108
|
+
# endif
|
|
109
|
+
#endif
|
|
110
|
+
int main() { return 0; }
|
|
111
|
+
" OPENSSL_VERSION_SUPPORTED)
|
|
112
|
+
set(CMAKE_REQUIRED_INCLUDES ${SAVED_CMAKE_REQUIRED_INCLUDES})
|
|
113
|
+
if (OPENSSL_VERSION_SUPPORTED)
|
|
114
|
+
message(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
|
|
115
|
+
target_compile_definitions(${TARGET} PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
|
|
116
|
+
target_link_libraries(${TARGET} PUBLIC OpenSSL::SSL OpenSSL::Crypto)
|
|
117
|
+
if (APPLE AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
118
|
+
target_compile_definitions(${TARGET} PUBLIC CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN)
|
|
119
|
+
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
|
|
120
|
+
find_library(SECURITY_FRAMEWORK Security REQUIRED)
|
|
121
|
+
target_link_libraries(${TARGET} PUBLIC ${CORE_FOUNDATION_FRAMEWORK} ${SECURITY_FRAMEWORK})
|
|
122
|
+
endif()
|
|
123
|
+
endif()
|
|
124
|
+
else()
|
|
125
|
+
message(STATUS "OpenSSL not found, SSL support disabled")
|
|
126
|
+
endif()
|
|
127
|
+
endif()
|
|
91
128
|
|
|
92
129
|
if (LLAMA_LLGUIDANCE)
|
|
93
130
|
include(ExternalProject)
|
|
@@ -133,9 +170,16 @@ if (LLAMA_LLGUIDANCE)
|
|
|
133
170
|
set(LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} llguidance ${LLGUIDANCE_PLATFORM_LIBS})
|
|
134
171
|
endif ()
|
|
135
172
|
|
|
173
|
+
# Add Windows socket libraries unconditionally on Windows
|
|
174
|
+
if (WIN32)
|
|
175
|
+
set(LLAMA_COMMON_WIN_LIBS ws2_32)
|
|
176
|
+
else()
|
|
177
|
+
set(LLAMA_COMMON_WIN_LIBS "")
|
|
178
|
+
endif()
|
|
179
|
+
|
|
136
180
|
target_include_directories(${TARGET} PUBLIC . ../vendor)
|
|
137
181
|
target_compile_features (${TARGET} PUBLIC cxx_std_17)
|
|
138
|
-
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
|
|
182
|
+
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} ${LLAMA_COMMON_WIN_LIBS} PUBLIC llama Threads::Threads)
|
|
139
183
|
|
|
140
184
|
|
|
141
185
|
#
|