forked from pinokiocomputer/llamanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (37 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const yargs = require('yargs/yargs')
const llamacpp = require('./llamacpp')
const Server = require('./server')
// START
// $ npx llamanet start local Phi-3-mini-4k-instruct-fp16.gguf
// $ npx llamanet start huggingface microsoft/Phi-3-mini-4k-instruct-gguf Phi-3-mini-4k-instruct-fp16.gguf
//
// STOP
// $ npx llamanet stop local Phi-3-mini-4k-instruct-fp16.gguf
//
// STATUS
// $ npx llamanet status
//
// VIEW MODELS
// $ npx llamanet models
module.exports = {
run: async (argv) => {
process.env.OPENAI_BASE_URL = "http://localhost:42424/v1"
process.env.OPENAI_API_KEY = "llamanet"
// 1. download llamacpp if it doesn't exist
await llamacpp.download()
// 2. start the llamanet web server if it's not started yet
const server = new Server()
await server.start()
// by default, no actions should exit
// 3. Call the command
if (argv) {
if (Array.isArray(argv)) {
const response = await server.call(argv)
return response
} else if (argv._ && argv._.length > 0) {
const response = await server.call(argv)
return response
}
}
}
}