forked from pinokiofactory/openui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinokio.js
118 lines (118 loc) · 3.44 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
const path = require('path')
const fs = require('fs')
module.exports = {
version: "1.5",
title: "openui",
description: "Describe UI and see it rendered live. Ask for changes and convert HTML to React, Svelte, Web Components, etc. Like vercel v0, but open source https://github.com/wandb/openui",
icon: "icon.png",
menu: async (kernel) => {
let installing = await kernel.running(__dirname, "install.js")
let installed = await kernel.exists(__dirname, "app", "backend", "env")
let chatgpt_running = await kernel.running(__dirname, "start_chatgpt.js")
let ollama_running = await kernel.running(__dirname, "start_ollama.js")
let running = chatgpt_running || ollama_running
let key
try {
key = await fs.promises.readFile(path.resolve(__dirname, "key.txt"), "utf8")
} catch (e) {
key = ""
}
const models = ["llava:7b", "llava:13b", "llava:34b", "bakllava"]
if (installing) {
return [{
icon: "fa-solid fa-plug",
text: "Installing",
href: "install.js",
}]
} else if (installed) {
if (running) {
if (chatgpt_running) {
let local = kernel.memory.local[path.resolve(__dirname, "start_chatgpt.js")]
if (local && local.url) {
return [{
icon: "fa-solid fa-rocket",
text: "Open Web UI",
href: local.url,
popout: true,
}, {
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start_chatgpt.js",
}]
} else {
return [{
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start_chatgpt.js",
}]
}
} else if (ollama_running) {
let local = kernel.memory.local[path.resolve(__dirname, "start_ollama.js")]
if (local && local.url) {
return [{
icon: "fa-solid fa-rocket",
text: "Open Web UI",
href: local.url,
popout: true,
}, {
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start_ollama.js",
}]
} else {
return [{
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start_ollama.js",
}]
}
}
} else {
return [{
icon: "fa-solid fa-power-off",
text: "Start",
menu: [{
text: "Use Ollama",
href: "start_ollama.js"
}, {
text: "Use ChatGPT",
href: "start_chatgpt.js",
params: {
key
}
}]
}, {
icon: "fa-solid fa-plug",
text: "Update",
href: "update.js",
}, {
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}, {
icon: "fa-solid fa-circle-down",
text: "Download Models",
menu: models.map((model) => {
return {
text: model,
href: "download.js",
params: {
name: model
}
}
})
}, {
icon: "fa-regular fa-circle-xmark",
text: "Reset",
href: "reset.js",
}]
}
} else {
return [{
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}]
}
}
}