-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ca9e93
Showing
7 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: 'recursive' | ||
token: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Semantic release | ||
run: npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.idea/ | ||
|
||
/cpp/.idea/ | ||
/cpp/build/ | ||
/cpp/cmake-build-debug/ | ||
|
||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/changelog", | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": [ | ||
"package.json", | ||
"CHANGELOG.md" | ||
] | ||
} | ||
] | ||
], | ||
"branches": [ | ||
"master" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
project(llamacpp_node_bindings) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
# Use cmake-js provided node-addon-api and Node.js include directories | ||
include_directories(${CMAKE_JS_INC}) | ||
|
||
# Define the Node.js addon target | ||
add_library(${PROJECT_NAME} SHARED | ||
src/main.cpp | ||
src/LlamaCPPBinding.h | ||
src/LlamaCPPBinding.cpp | ||
${CMAKE_JS_SRC} | ||
) | ||
|
||
# Set target output name to 'addon.node' | ||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") | ||
|
||
# Add RobotCPP submodule library | ||
add_subdirectory(${CMAKE_SOURCE_DIR}/externals/llama-cpp) | ||
|
||
# Link the RobotCPP library and cmake-js provided Node.js runtime libraries | ||
target_link_libraries(${PROJECT_NAME} PRIVATE | ||
RobotCPP | ||
${CMAKE_JS_LIB} | ||
) | ||
|
||
# Set the output directory to 'build/Release' for compatibility with Node.js | ||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Release | ||
) | ||
|
||
# Include Node-API wrappers | ||
execute_process(COMMAND node -p "require('node-addon-api').include" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE NODE_ADDON_API_DIR | ||
) | ||
string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR}) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR}) | ||
|
||
# define NAPI_VERSION | ||
add_definitions(-DNAPI_VERSION=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class LlamaWrapper { | ||
constructor(); | ||
initialize(modelPath: string, contextSize?: number): boolean; | ||
runQuery(prompt: string, maxTokens?: number): string; | ||
runQueryStream(prompt: string, maxTokens: number, callback: (response: string) => void): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const llama = require('./cpp/build/Release/llamacpp_node_bindings.node'); | ||
|
||
module.exports = { | ||
LlamaWrapper: llama.LlamaWrapper | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "llama.cpp-ts", | ||
"version": "0.0.1", | ||
"description": "Node.js bindings for LlamaCPP, a C++ library for running language models.", | ||
"repository": "https://github.com/developer239/llama.cpp-ts", | ||
"main": "index.js", | ||
"typings": "index.d.ts", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"dependencies": { | ||
"node-addon-api": "6.1.0", | ||
"cmake-js": "7.2.1" | ||
}, | ||
"scripts": { | ||
"install": "cmake-js compile", | ||
"build": "cmake-js compile" | ||
}, | ||
"keywords": [ | ||
"node", | ||
"language-model", | ||
"c++", | ||
"cpp", | ||
"node-addon-api", | ||
"cmake", | ||
"cmake-js", | ||
"llama", | ||
"llama.cpp", | ||
"3.1" | ||
], | ||
"devDependencies": { | ||
"@semantic-release/changelog": "6.0.3", | ||
"@semantic-release/commit-analyzer": "9.0.2", | ||
"@semantic-release/git": "10.0.1", | ||
"@semantic-release/npm": "10.0.3", | ||
"@semantic-release/release-notes-generator": "10.0.3", | ||
"semantic-release": "21.0.1" | ||
} | ||
} |