-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpinokio.js
132 lines (131 loc) · 4.06 KB
/
pinokio.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const path = require('path')
module.exports = {
version: "2.0",
title: "Open WebUI",
description: "User-friendly WebUI for LLMs, supported LLM runners include Ollama and OpenAI-compatible APIs https://github.com/open-webui/open-webui",
icon: "icon.png",
pre: [{
icon: "ollama.png",
title: "Ollama",
description: "Get up and running with large language models.",
href: "https://ollama.com/"
}],
menu: async (kernel, info) => {
//let installing = kernel.running(__dirname, "install.js")
//let installed = await kernel.exists(__dirname, "app", "backend", "env")
//let running = kernel.running(__dirname, "start.js")
//let updating = kernel.running(__dirname, "update.js")
//let resetting = kernel.running(__dirname, "reset.js")
let installing = info.running("install.js")
let installed = info.exists("app/backend/env")
let running = info.running("start.js")
let updating = info.running("update.js")
let resetting = info.running("reset.js")
console.log(">>>>>>>> __dirname", __dirname)
console.log(">>>>>>>> Install Path", path.resolve(__dirname, "install.js"))
console.log(">>>>>>>> Start Path", path.resolve(__dirname, "start.js"))
console.log(">>>>>>>> Running Status:", kernel.api.running)
console.log(">>>>>>>> LOG", { installing, installed, running, updating, resetting })
if (installing) {
return [{
default: true,
icon: "fa-solid fa-plug",
text: "Installing",
href: "install.js",
}]
} else if (installed) {
if (running) {
let local = kernel.memory.local[path.resolve(__dirname, "start.js")]
if (local && local.url) {
let o = [{
// default: true,
popout: true,
icon: "fa-solid fa-rocket",
text: "Open Web UI",
href: local.url,
}, {
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start.js",
}]
return o
} else {
return [{
default: true,
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start.js",
}]
}
} else if (updating) {
return [{
default: true,
icon: 'fa-solid fa-arrows-rotate',
text: "Updating...",
href: "update.js",
}]
} else if (resetting) {
return [{
default: true,
icon: 'fa-solid fa-broom',
text: "Resetting...",
href: "reset.js",
}]
} else {
// let names = []
// if (kernel.jsdom) {
// let JSDOM = kernel.jsdom.JSDOM
// try {
// let dom = await JSDOM.fromURL("https://ollama.com/library")
// let els = dom.window.document.querySelectorAll("#repo li a")
// let urls = []
// for(let el of els) {
// urls.push(el.href)
// names.push(new URL(el.href).pathname.split("/").filter(x => x)[1])
// }
// console.log("names", names)
// } catch (e) {
// }
// }
return [{
default: true,
icon: "fa-solid fa-power-off",
text: "Start",
href: "start.js",
// }, {
// icon: "fa-solid fa-download",
// text: "Download Models",
// menu: names.map((name) => {
// return {
// icon: "fa-solid fa-circle-down",
// text: name,
// href: "down.js",
// params: {
// name
// }
// }
// })
}, {
icon: "fa-solid fa-arrows-rotate",
text: "Update",
href: "update.js",
}, {
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}, {
icon: "fa-solid fa-broom",
text: "Factory Reset",
href: "reset.js",
}]
}
} else {
return [{
default: true,
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}]
}
}
}