Download code/tell.js from Redhanuman/pocket-storyteller: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/Redhanuman/pocket-storyteller/resolve/main/code/tell.js
- Command line
-
hf download hf://Redhanuman/pocket-storyteller/code/tell.js
-
curl -L -o tell.js https://huggingface.co/Redhanuman/pocket-storyteller/resolve/main/code/tell.js
876 Bytes
| // Tell a story in the terminal. | |
| // node tell.js "Once upon a time, there was a little fox named Pip" | |
| // node tell.js "Lily found a tiny door" 1.0 (second number = imagination, default 0.8) | |
| const fs = require("fs"), path = require("path"); | |
| const Storyteller = require(path.resolve(__dirname, "web/storyteller.js")); | |
| const b = fs.readFileSync(path.resolve(__dirname, "web/storyteller.bin")); | |
| const st = new Storyteller(b.buffer.slice(b.byteOffset, b.byteOffset + b.length)); | |
| const prompt = process.argv[2] || "Once upon a time", temperature = +process.argv[3] || 0.8; | |
| st.reset(st.encode(prompt)); | |
| process.stdout.write(prompt); | |
| const t0 = Date.now(); let n = 0; | |
| for (; n < 600; n++) { const s = st.next({ temperature, topK: 40 }); if (s.done) break; process.stdout.write(s.text); } | |
| console.log(`\n\n[${n} word-pieces in ${((Date.now() - t0) / 1000).toFixed(1)} s]`); | |