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:
cocktailpeanut 2023-03-22 01:27:53 -04:00 committed by GitHub
commit dc8658ae07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -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}/`)

View File

@ -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>

View File

@ -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), {