From c01737ff69c3d9aeb1aed53c88bedeec94741a04 Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 1 Dec 2023 15:46:01 +0700 Subject: [PATCH] refactor: Change inference-extension to inference-nitro-extension --- .gitignore | 8 +-- extensions/inference-extension/package.json | 57 ------------------- .../README.md | 0 .../bin}/linux-cpu/.gitkeep | 0 .../bin}/linux-cuda/.gitkeep | 0 .../bin}/linux-start.sh | 0 .../bin}/mac-arm64/.gitkeep | 0 .../bin}/mac-x64/.gitkeep | 0 .../bin}/version.txt | 0 .../bin}/win-cpu/.gitkeep | 0 .../bin}/win-cuda/.gitkeep | 0 .../bin}/win-start.bat | 0 .../download.bat | 0 .../inference-nitro-extension/package.json | 57 +++++++++++++++++++ .../src/@types/global.d.ts | 0 .../src/helpers/sse.ts | 0 .../src/index.ts | 0 .../src/module.ts | 2 +- .../tsconfig.json | 0 .../webpack.config.js | 0 20 files changed, 62 insertions(+), 62 deletions(-) delete mode 100644 extensions/inference-extension/package.json rename extensions/{inference-extension => inference-nitro-extension}/README.md (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/linux-cpu/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/linux-cuda/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/linux-start.sh (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/mac-arm64/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/mac-x64/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/version.txt (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/win-cpu/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/win-cuda/.gitkeep (100%) rename extensions/{inference-extension/nitro => inference-nitro-extension/bin}/win-start.bat (100%) rename extensions/{inference-extension => inference-nitro-extension}/download.bat (100%) create mode 100644 extensions/inference-nitro-extension/package.json rename extensions/{inference-extension => inference-nitro-extension}/src/@types/global.d.ts (100%) rename extensions/{inference-extension => inference-nitro-extension}/src/helpers/sse.ts (100%) rename extensions/{inference-extension => inference-nitro-extension}/src/index.ts (100%) rename extensions/{inference-extension => inference-nitro-extension}/src/module.ts (99%) rename extensions/{inference-extension => inference-nitro-extension}/tsconfig.json (100%) rename extensions/{inference-extension => inference-nitro-extension}/webpack.config.js (100%) diff --git a/.gitignore b/.gitignore index 4bfb0576fe..d400a3b813 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ package-lock.json core/lib/** # Nitro binary files -extensions/inference-extension/nitro/*/nitro -extensions/inference-extension/nitro/*/*.exe -extensions/inference-extension/nitro/*/*.dll -extensions/inference-extension/nitro/*/*.metal \ No newline at end of file +extensions/inference-nitro-extension/bin/*/nitro +extensions/inference-nitro-extension/bin/*/*.exe +extensions/inference-nitro-extension/bin/*/*.dll +extensions/inference-nitro-extension/bin/*/*.metal \ No newline at end of file diff --git a/extensions/inference-extension/package.json b/extensions/inference-extension/package.json deleted file mode 100644 index 798d2e46d8..0000000000 --- a/extensions/inference-extension/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@janhq/inference-extension", - "version": "1.0.0", - "description": "Inference Extension, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.", - "main": "dist/index.js", - "module": "dist/module.js", - "author": "Jan ", - "license": "AGPL-3.0", - "scripts": { - "build": "tsc -b . && webpack --config webpack.config.js", - "downloadnitro:linux": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64.tar.gz -e --strip 1 -o ./nitro/linux-cpu && chmod +x ./nitro/linux-cpu/nitro && chmod +x ./nitro/linux-start.sh && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64-cuda.tar.gz -e --strip 1 -o ./nitro/linux-cuda && chmod +x ./nitro/linux-cuda/nitro && chmod +x ./nitro/linux-start.sh", - "downloadnitro:darwin": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-arm64.tar.gz -e --strip 1 -o ./nitro/mac-arm64 && chmod +x ./nitro/mac-arm64/nitro && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-amd64.tar.gz -e --strip 1 -o ./nitro/mac-x64 && chmod +x ./nitro/mac-x64/nitro", - "downloadnitro:win32": "download.bat", - "downloadnitro": "run-script-os", - "build:publish:darwin": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && ../../.github/scripts/auto-sign.sh && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/pre-install", - "build:publish:win32": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/pre-install", - "build:publish:linux": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/pre-install", - "build:publish": "run-script-os" - }, - "exports": { - ".": "./dist/index.js", - "./main": "./dist/module.js" - }, - "devDependencies": { - "cpx": "^1.5.0", - "rimraf": "^3.0.2", - "run-script-os": "^1.1.6", - "webpack": "^5.88.2", - "webpack-cli": "^5.1.4" - }, - "dependencies": { - "@janhq/core": "file:../../core", - "download-cli": "^1.1.1", - "electron-log": "^5.0.1", - "fetch-retry": "^5.0.6", - "kill-port": "^2.0.1", - "path-browserify": "^1.0.1", - "rxjs": "^7.8.1", - "tcp-port-used": "^1.0.2", - "ts-loader": "^9.5.0", - "ulid": "^2.3.0" - }, - "engines": { - "node": ">=18.0.0" - }, - "files": [ - "dist/*", - "package.json", - "README.md" - ], - "bundleDependencies": [ - "tcp-port-used", - "kill-port", - "fetch-retry", - "electron-log" - ] -} diff --git a/extensions/inference-extension/README.md b/extensions/inference-nitro-extension/README.md similarity index 100% rename from extensions/inference-extension/README.md rename to extensions/inference-nitro-extension/README.md diff --git a/extensions/inference-extension/nitro/linux-cpu/.gitkeep b/extensions/inference-nitro-extension/bin/linux-cpu/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/linux-cpu/.gitkeep rename to extensions/inference-nitro-extension/bin/linux-cpu/.gitkeep diff --git a/extensions/inference-extension/nitro/linux-cuda/.gitkeep b/extensions/inference-nitro-extension/bin/linux-cuda/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/linux-cuda/.gitkeep rename to extensions/inference-nitro-extension/bin/linux-cuda/.gitkeep diff --git a/extensions/inference-extension/nitro/linux-start.sh b/extensions/inference-nitro-extension/bin/linux-start.sh similarity index 100% rename from extensions/inference-extension/nitro/linux-start.sh rename to extensions/inference-nitro-extension/bin/linux-start.sh diff --git a/extensions/inference-extension/nitro/mac-arm64/.gitkeep b/extensions/inference-nitro-extension/bin/mac-arm64/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/mac-arm64/.gitkeep rename to extensions/inference-nitro-extension/bin/mac-arm64/.gitkeep diff --git a/extensions/inference-extension/nitro/mac-x64/.gitkeep b/extensions/inference-nitro-extension/bin/mac-x64/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/mac-x64/.gitkeep rename to extensions/inference-nitro-extension/bin/mac-x64/.gitkeep diff --git a/extensions/inference-extension/nitro/version.txt b/extensions/inference-nitro-extension/bin/version.txt similarity index 100% rename from extensions/inference-extension/nitro/version.txt rename to extensions/inference-nitro-extension/bin/version.txt diff --git a/extensions/inference-extension/nitro/win-cpu/.gitkeep b/extensions/inference-nitro-extension/bin/win-cpu/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/win-cpu/.gitkeep rename to extensions/inference-nitro-extension/bin/win-cpu/.gitkeep diff --git a/extensions/inference-extension/nitro/win-cuda/.gitkeep b/extensions/inference-nitro-extension/bin/win-cuda/.gitkeep similarity index 100% rename from extensions/inference-extension/nitro/win-cuda/.gitkeep rename to extensions/inference-nitro-extension/bin/win-cuda/.gitkeep diff --git a/extensions/inference-extension/nitro/win-start.bat b/extensions/inference-nitro-extension/bin/win-start.bat similarity index 100% rename from extensions/inference-extension/nitro/win-start.bat rename to extensions/inference-nitro-extension/bin/win-start.bat diff --git a/extensions/inference-extension/download.bat b/extensions/inference-nitro-extension/download.bat similarity index 100% rename from extensions/inference-extension/download.bat rename to extensions/inference-nitro-extension/download.bat diff --git a/extensions/inference-nitro-extension/package.json b/extensions/inference-nitro-extension/package.json new file mode 100644 index 0000000000..ef74fff080 --- /dev/null +++ b/extensions/inference-nitro-extension/package.json @@ -0,0 +1,57 @@ +{ + "name": "@janhq/inference-nitro-extension", + "version": "1.0.0", + "description": "Inference Engine for Nitro Extension, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.", + "main": "dist/index.js", + "module": "dist/module.js", + "author": "Jan ", + "license": "AGPL-3.0", + "scripts": { + "build": "tsc -b . && webpack --config webpack.config.js", + "downloadnitro:linux": "NITRO_VERSION=$(cat ./bin/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64.tar.gz -e --strip 1 -o ./bin/linux-cpu && chmod +x ./bin/linux-cpu/nitro && chmod +x ./bin/linux-start.sh && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64-cuda.tar.gz -e --strip 1 -o ./bin/linux-cuda && chmod +x ./bin/linux-cuda/nitro && chmod +x ./bin/linux-start.sh", + "downloadnitro:darwin": "NITRO_VERSION=$(cat ./bin/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-arm64.tar.gz -e --strip 1 -o ./bin/mac-arm64 && chmod +x ./bin/mac-arm64/nitro && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-amd64.tar.gz -e --strip 1 -o ./bin/mac-x64 && chmod +x ./bin/mac-x64/nitro", + "downloadnitro:win32": "download.bat", + "downloadnitro": "run-script-os", + "build:publish:darwin": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && ../../.github/scripts/auto-sign.sh && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../electron/pre-install", + "build:publish:win32": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../electron/pre-install", + "build:publish:linux": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"bin/**\" \"dist/bin\" && npm pack && cpx *.tgz ../../electron/pre-install", + "build:publish": "run-script-os" + }, + "exports": { + ".": "./dist/index.js", + "./main": "./dist/module.js" + }, + "devDependencies": { + "cpx": "^1.5.0", + "rimraf": "^3.0.2", + "run-script-os": "^1.1.6", + "webpack": "^5.88.2", + "webpack-cli": "^5.1.4" + }, + "dependencies": { + "@janhq/core": "file:../../core", + "download-cli": "^1.1.1", + "electron-log": "^5.0.1", + "fetch-retry": "^5.0.6", + "kill-port": "^2.0.1", + "path-browserify": "^1.0.1", + "rxjs": "^7.8.1", + "tcp-port-used": "^1.0.2", + "ts-loader": "^9.5.0", + "ulid": "^2.3.0" + }, + "engines": { + "node": ">=18.0.0" + }, + "files": [ + "dist/*", + "package.json", + "README.md" + ], + "bundleDependencies": [ + "tcp-port-used", + "kill-port", + "fetch-retry", + "electron-log" + ] +} diff --git a/extensions/inference-extension/src/@types/global.d.ts b/extensions/inference-nitro-extension/src/@types/global.d.ts similarity index 100% rename from extensions/inference-extension/src/@types/global.d.ts rename to extensions/inference-nitro-extension/src/@types/global.d.ts diff --git a/extensions/inference-extension/src/helpers/sse.ts b/extensions/inference-nitro-extension/src/helpers/sse.ts similarity index 100% rename from extensions/inference-extension/src/helpers/sse.ts rename to extensions/inference-nitro-extension/src/helpers/sse.ts diff --git a/extensions/inference-extension/src/index.ts b/extensions/inference-nitro-extension/src/index.ts similarity index 100% rename from extensions/inference-extension/src/index.ts rename to extensions/inference-nitro-extension/src/index.ts diff --git a/extensions/inference-extension/src/module.ts b/extensions/inference-nitro-extension/src/module.ts similarity index 99% rename from extensions/inference-extension/src/module.ts rename to extensions/inference-nitro-extension/src/module.ts index 72e418d6c0..90582073e1 100644 --- a/extensions/inference-extension/src/module.ts +++ b/extensions/inference-nitro-extension/src/module.ts @@ -168,7 +168,7 @@ function checkAndUnloadNitro() { */ async function spawnNitroProcess(): Promise { return new Promise((resolve, reject) => { - let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default + let binaryFolder = path.join(__dirname, "bin"); // Current directory by default let binaryName; if (process.platform === "win32") { diff --git a/extensions/inference-extension/tsconfig.json b/extensions/inference-nitro-extension/tsconfig.json similarity index 100% rename from extensions/inference-extension/tsconfig.json rename to extensions/inference-nitro-extension/tsconfig.json diff --git a/extensions/inference-extension/webpack.config.js b/extensions/inference-nitro-extension/webpack.config.js similarity index 100% rename from extensions/inference-extension/webpack.config.js rename to extensions/inference-nitro-extension/webpack.config.js