mirror of https://github.com/cocktailpeanut/dalai
Merge pull request #107 from matbee-eth/main
Add threads support to front end ui, showing system cpu count by default
This commit is contained in:
commit
dc8658ae07
|
@ -1,6 +1,7 @@
|
|||
const express = require('express')
|
||||
const http = require('http')
|
||||
const path = require('path')
|
||||
const os = require('os')
|
||||
const Dalai = require("../../index")
|
||||
const app = express()
|
||||
const httpServer = http.Server(app);
|
||||
|
@ -13,7 +14,9 @@ const start = (port, home) => {
|
|||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.resolve(__dirname, "views"))
|
||||
app.get("/", (req, res) => {
|
||||
res.render("index")
|
||||
res.render("index", {
|
||||
threads: os.cpus().length
|
||||
})
|
||||
})
|
||||
httpServer.listen(port, () => {
|
||||
console.log(`Server running on http://localhost:${port}/`)
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<script>
|
||||
const config = {
|
||||
seed: -1,
|
||||
threads: 4,
|
||||
threads: <%= threads %>,
|
||||
n_predict: 200,
|
||||
top_k: 420,
|
||||
top_p: 0.9,
|
||||
|
@ -127,7 +127,7 @@ const form = document.getElementById('form');
|
|||
const input = document.querySelector('#input');
|
||||
const model = document.querySelector('#model');
|
||||
const renderHeader = (config) => {
|
||||
const fields = [{ key: "debug", type: "checkbox" }, "n_predict", "repeat_last_n", "repeat_penalty", "top_k", "top_p", "temp", "seed"].map((key) => {
|
||||
const fields = [{ key: "debug", type: "checkbox" }, "n_predict", "repeat_last_n", "repeat_penalty", "top_k", "top_p", "temp", "seed", "threads"].map((key) => {
|
||||
if (typeof key === "string") {
|
||||
return `<div class='kv'>
|
||||
<label>${key}</label>
|
||||
|
|
8
llama.js
8
llama.js
|
@ -139,10 +139,10 @@ npx dalai install 7B 13B
|
|||
await fs.promises.mkdir(resolvedPath, { recursive: true }).catch((e) => { })
|
||||
|
||||
for(let file of files) {
|
||||
// if (fs.existsSync(path.resolve(resolvedPath, file))) {
|
||||
// console.log(`Skip file download, it already exists: ${file}`)
|
||||
// continue;
|
||||
// }
|
||||
if (fs.existsSync(path.resolve(resolvedPath, file))) {
|
||||
console.log(`Skip file download, it already exists: ${file}`)
|
||||
continue;
|
||||
}
|
||||
|
||||
const url = `https://agi.gpt4.org/llama/LLaMA/${model}/${file}`
|
||||
await this.root.down(url, path.resolve(resolvedPath, file), {
|
||||
|
|
Loading…
Reference in New Issue