Skip to content

Commit 7f66365

Browse files
committed
feat: Update with upstream pr 460
1 parent 0a634de commit 7f66365

35 files changed

+2186
-950
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ jobs:
2323
- name: TypeScript validity
2424
run: npm run test:typescript
2525

26-
compile-docs:
27-
name: Test docs compilation
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v4
31-
with:
32-
lfs: true
33-
fetch-depth: 0
34-
fetch-tags: true
35-
- uses: actions/setup-node@v4
36-
with:
37-
node-version: "20"
38-
- name: Install modules
39-
run: npm ci
40-
- name: Build
41-
run: npm run build
42-
- name: Download latest llama.cpp release
43-
env:
44-
CI: true
45-
run: node ./dist/cli/cli.js source download --release latest --skipBuild --noBundle --noUsageExample --updateBinariesReleaseMetadataAndSaveGitBundle
46-
- name: Compile docs
47-
run: npm run docs:build
26+
# compile-docs:
27+
# name: Test docs compilation
28+
# runs-on: ubuntu-latest
29+
# steps:
30+
# - uses: actions/checkout@v4
31+
# with:
32+
# lfs: true
33+
# fetch-depth: 0
34+
# fetch-tags: true
35+
# - uses: actions/setup-node@v4
36+
# with:
37+
# node-version: "20"
38+
# - name: Install modules
39+
# run: npm ci
40+
# - name: Build
41+
# run: npm run build
42+
# - name: Download latest llama.cpp release
43+
# env:
44+
# CI: true
45+
# run: node ./dist/cli/cli.js source download --release latest --skipBuild --noBundle --noUsageExample --updateBinariesReleaseMetadataAndSaveGitBundle
46+
# - name: Compile docs
47+
# run: npm run docs:build

.vitepress/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,6 @@ export default defineConfig({
470470
}
471471
},
472472
sidebar: {
473-
"/api/": getApiReferenceSidebar(),
474-
475473
"/guide/": [{
476474
text: "Guide",
477475
base: "/guide",
@@ -550,7 +548,9 @@ export default defineConfig({
550548
]
551549
}
552550
]
553-
}]
551+
}],
552+
553+
"/api/": getApiReferenceSidebar()
554554
},
555555
socialLinks: [
556556
{icon: "npm", link: "https://www.npmjs.com/package/node-llama-cpp"},

docs/cli/pull.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If a file already exists and its size matches the expected size, it will not be
2020

2121
The supported URI schemes are:
2222
- **HTTP:** `https://`, `http://`
23-
- **Hugging Face:** `hf:<user>/<model>:<quant>` (`#<quant>` is optional, [but recommended](../guide/downloading-models.md#hf-scheme-specify-quant))
23+
- **Hugging Face:** `hf:<user>/<model>:<quant>` (`:<quant>` is optional, [but recommended](../guide/downloading-models.md#hf-scheme-specify-quant))
2424
- **Hugging Face:** `hf:<user>/<model>/<file-path>#<branch>` (`#<branch>` is optional)
2525

2626
Learn more about using model URIs in the [Downloading Models guide](../guide/downloading-models.md#model-uris).

docs/guide/CUDA.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,33 @@ set NODE_LLAMA_CPP_CMAKE_OPTION_CMAKE_GENERATOR_TOOLSET=%CUDA_PATH%
114114

115115
Then run the build command again to check whether setting the `CMAKE_GENERATOR_TOOLSET` cmake option fixed the issue.
116116

117+
### Fix the `forward compatibility was attempted on non supported HW` Error {#fix-cuda-forward-compatibility}
118+
This error usually happens when the CUDA version you have installed on your machine is older than the CUDA version used in the prebuilt binaries supplied by `node-llama-cpp`.
119+
120+
To resolve this issue, you can either [update your CUDA installation](https://developer.nvidia.com/cuda-downloads) to the latest version (recommended) or [build `node-llama-cpp` on your machine](#building) against the CUDA version you have installed.
121+
122+
### Fix the `Binary GPU type mismatch. Expected: cuda, got: false` Error {#fix-cuda-gpu-type-mismatch}
123+
This error usually happens when you have multiple conflicting CUDA versions installed on your machine.
124+
125+
To fix it, uninstall older CUDA versions and restart your machine (important).
126+
127+
:::: details Check which CUDA libraries are picked up by `node-llama-cpp`'s prebuilt binaries on your machine
128+
129+
Run this command inside of your project:
130+
131+
::: code-group
132+
```shell [Linux]
133+
ldd ./node_modules/@node-llama-cpp/linux-x64-cuda/bins/linux-x64-cuda/libggml-cuda.so
134+
```
135+
136+
```cmd [Windows]
137+
"C:\Program Files\Git\usr\bin\ldd.exe" node_modules\@node-llama-cpp\win-x64-cuda\bins\win-x64-cuda\ggml-cuda.dll
138+
```
139+
:::
140+
141+
::::
142+
143+
117144
## Using `node-llama-cpp` With CUDA
118145
It's recommended to use [`getLlama`](../api/functions/getLlama) without specifying a GPU type,
119146
so it'll detect the available GPU types and use the best one automatically.

docs/guide/awesome.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,32 @@
22
description: Awesome projects that use node-llama-cpp
33
---
44
# Awesome `node-llama-cpp`
5-
Awesome projects that use `node-llama-cpp`.
5+
:sunglasses: Awesome projects that use `node-llama-cpp`.
6+
7+
<script setup lang="ts">
8+
import DataBadge from "../../.vitepress/components/DataBadge/DataBadge.vue";
9+
</script>
610

711
## Open Source
812
* [CatAI](https://github.com/withcatai/catai) - a simplified AI assistant API for Node.js, with REST API support
13+
<br /><DataBadge title="License" content="MIT"/>
14+
15+
* [Manzoni](https://manzoni.app/) ([GitHub](https://github.com/gems-platforms/manzoni-app)) - a text editor running local LLMs
16+
<br /><DataBadge title="License" content="AGPL-3.0"/>
17+
918

1019
## Proprietary
11-
> List your project here!
20+
* [BashBuddy](https://bashbuddy.run) ([GitHub](https://github.com/wosherco/bashbuddy)) - write bash commands with natural language
21+
<br /><DataBadge title="Partially open source" content="Source available" href="https://github.com/wosherco/bashbuddy/blob/main/LICENSE.md"/>
22+
23+
* [nutshell](https://withnutshell.com) - Private AI meeting notes processed completely on your device
24+
1225

1326

1427
<br />
1528

1629
---
1730

31+
> To add a project to this list, [open a PR](https://github.com/withcatai/node-llama-cpp/edit/master/docs/guide/awesome.md).
32+
>
1833
> To have a project listed here, it should clearly state that it uses `node-llama-cpp`.

docs/guide/cmakeOptions.data.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ function parseCmakeOptions(cmakeListsTxt: string, optionFilter: ((key: string) =
9090
}
9191
} else if (option.defaultValue === "${BUILD_SHARED_LIBS_DEFAULT}")
9292
option.defaultValue = htmlEscapeWithCodeMarkdown("`OFF` on MinGW, `ON` otherwise");
93+
else if (option.defaultValue === "${GGML_CUDA_GRAPHS_DEFAULT}")
94+
option.defaultValue = htmlEscapeWithCodeMarkdown("`ON`");
95+
else if (option.defaultValue === "${GGML_NATIVE_DEFAULT}")
96+
option.defaultValue = htmlEscapeWithCodeMarkdown("`OFF` when building for a different architecture,\n`ON` otherwise");
97+
else if (option.key === "LLAMA_CURL")
98+
option.defaultValue = htmlEscapeWithCodeMarkdown("`OFF`");
9399
else
94100
option.defaultValue = htmlEscapeWithCodeMarkdown(
95101
option.defaultValue != null

docs/guide/downloading-models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ You can reference models using a URI instead of their full download URL when usi
7676
When downloading a model from a URI, the model files will be prefixed with a corresponding adaptation of the URI.
7777

7878
To reference a model from Hugging Face, you can use one of these schemes:
79-
* `hf:<user>/<model>:<quant>` (`#<quant>` is optional, [but recommended](#hf-scheme-specify-quant))
79+
* `hf:<user>/<model>:<quant>` (`:<quant>` is optional, [but recommended](#hf-scheme-specify-quant))
8080
* `hf:<user>/<model>/<file-path>#<branch>` (`#<branch>` is optional)
8181

8282
Here are example usages of the Hugging Face URI scheme:

docs/guide/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,5 @@ Explore the [API reference](../api/functions/getLlama.md) to learn more about th
316316
and use the search bar (press <kbd class="doc-kbd">/</kbd>) to find documentation for a specific topic or API.
317317

318318
Check out the [roadmap](https://github.com/orgs/withcatai/projects/1) to see what's coming next,<br/>
319+
visit the [awesome list](./awesome.md) to find great projects that use `node-llama-cpp`,<br/>
319320
and consider [sponsoring `node-llama-cpp`](https://github.com/sponsors/giladgd) to accelerate the development of new features.

llama/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.14)
1+
cmake_minimum_required(VERSION 3.19)
22

33
if (NLC_CURRENT_PLATFORM STREQUAL "win-x64" OR NLC_CURRENT_PLATFORM STREQUAL "win-arm64")
44
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
@@ -70,7 +70,9 @@ include_directories(${NODE_ADDON_API_DIR} ${CMAKE_JS_INC})
7070
add_subdirectory("llama.cpp")
7171
include_directories("llama.cpp")
7272
include_directories("./llama.cpp/common")
73-
include_directories("./llama.cpp/src")
73+
74+
# This is needed to use methods in "llama-grammar.h" and "unicode.h"
75+
target_include_directories(llama PUBLIC "./llama.cpp/src")
7476

7577
unset(GPU_INFO_HEADERS)
7678
unset(GPU_INFO_SOURCES)

llama/addon/AddonContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include <algorithm>
33
#include <cmath>
44
#include "common/common.h"
5-
#include "llama-grammar.h"
65
#include "llama.h"
76

87
#include "addonGlobals.h"

0 commit comments

Comments
 (0)