From d8fcafe644b5755842ebab97de98657796d14d36 Mon Sep 17 00:00:00 2001 From: cocktailpeanut Date: Wed, 22 Mar 2023 16:18:21 -0400 Subject: [PATCH] download alpaca from huggingface + installer fix installer fix => don't stop when rename fails, it's ok. just try renaming but if it doesn't exist it should just ignore because it means there's no file to rename --- alpaca.js | 21 ++++++++++++++------- index.js | 8 ++++---- package.json | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/alpaca.js b/alpaca.js index e33a42a..86e7d68 100644 --- a/alpaca.js +++ b/alpaca.js @@ -75,27 +75,34 @@ class Alpaca { console.log("mkdir", e) }) console.log("downloading torrent") + let url switch (model) { case "7B": - await this.root.torrent.add('magnet:?xt=urn:btih:5aaceaec63b03e51a98f04fd5c42320b2a033010&dn=ggml-alpaca-7b-q4.bin&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce', dir) - console.log("renaming") - await fs.promises.rename( - path.resolve(dir, "ggml-alpaca-7b-q4.bin"), - path.resolve(dir, "ggml-model-q4_0.bin") - ) + //await this.root.torrent.add('magnet:?xt=urn:btih:5aaceaec63b03e51a98f04fd5c42320b2a033010&dn=ggml-alpaca-7b-q4.bin&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce', dir) + //console.log("renaming") + //await fs.promises.rename( + // path.resolve(dir, "ggml-alpaca-7b-q4.bin"), + // path.resolve(dir, "ggml-model-q4_0.bin") + //) + url = "https://huggingface.co/Pi3141/alpaca-7B-ggml/resolve/main/ggml-model-q4_0.bin" + await this.root.down(url, path.resolve(dir, "ggml-model-q4_0.bin")) break; case "13B": + /* await this.root.torrent.add('magnet:?xt=urn:btih:053b3d54d2e77ff020ebddf51dad681f2a651071&dn=ggml-alpaca-13b-q4.bin&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce', dir) console.log("renaming") await fs.promises.rename( path.resolve(dir, "ggml-alpaca-13b-q4.bin"), path.resolve(dir, "ggml-model-q4_0.bin") ) + */ + url = "https://huggingface.co/Pi3141/alpaca-13B-ggml/resolve/main/ggml-model-q4_0.bin" + await this.root.down(url, path.resolve(dir, "ggml-model-q4_0.bin")) break; case "30B": - const url = "https://huggingface.co/Pi3141/alpaca-30B-ggml/resolve/main/ggml-model-q4_0.bin" + url = "https://huggingface.co/Pi3141/alpaca-30B-ggml/resolve/main/ggml-model-q4_0.bin" await this.root.down(url, path.resolve(dir, "ggml-model-q4_0.bin")) break; diff --git a/index.js b/index.js index e8239cf..ea1cf3a 100644 --- a/index.js +++ b/index.js @@ -337,15 +337,15 @@ class Dalai { let models_path = path.resolve(engine.home, "models") let temp_path = path.resolve(this.home, "tmp") let temp_models_path = path.resolve(temp_path, "models") - await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { }) + await fs.promises.mkdir(temp_path, { recursive: true }).catch((e) => { console.log("1", e) }) // 1. move the models folder to ../tmp - await fs.promises.rename(models_path, temp_models_path) + await fs.promises.rename(models_path, temp_models_path).catch((e) => { console.log("2", e) }) // 2. wipe out the folder - await fs.promises.rm(engine.home, { recursive: true }).catch((e) => { console.log(e) }) + await fs.promises.rm(engine.home, { recursive: true }).catch((e) => { console.log("3", e) }) // 3. install engine await this.add(core) // 4. move back the files inside /tmp - await fs.promises.rename(temp_models_path, models_path) + await fs.promises.rename(temp_models_path, models_path).catch((e) => { console.log("4", e) }) // next add the models let res = await this.cores[core].add(...models) diff --git a/package.json b/package.json index 78bf356..8839c99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dalai", - "version": "0.3.0", + "version": "0.3.1", "description": "", "main": "index.js", "author": "cocktailpeanut",