Skip to content

Commit

Permalink
download alpaca from huggingface + installer fix
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cocktailpeanut committed Mar 22, 2023
1 parent 0404c33 commit d8fcafe
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
21 changes: 14 additions & 7 deletions alpaca.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dalai",
"version": "0.3.0",
"version": "0.3.1",
"description": "",
"main": "index.js",
"author": "cocktailpeanut",
Expand Down

0 comments on commit d8fcafe

Please sign in to comment.