Commit
·
d2e3798
1
Parent(s):
3dbd65d
small update, may be useful later
Browse files- public/index.html +16 -5
- src/index.mts +4 -0
public/index.html
CHANGED
@@ -25,8 +25,18 @@
|
|
25 |
type="text"
|
26 |
name="modelDraft"
|
27 |
x-model="modelDraft"
|
|
|
28 |
class="input input-bordered w-full rounded text-lg text-stone-500 bg-stone-200 font-mono"
|
29 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
<textarea
|
31 |
name="promptDraft"
|
32 |
x-model="promptDraft"
|
@@ -36,7 +46,7 @@
|
|
36 |
></textarea>
|
37 |
<button
|
38 |
class="btn disabled:text-stone-400"
|
39 |
-
@click="open = true, prompt = promptDraft, model = modelDraft, state = state === 'stopped' ? 'loading' : 'stopped'"
|
40 |
:class="promptDraft.length < minPromptSize ? 'btn-neutral' : state === 'stopped' ? 'btn-accent' : 'btn-warning'"
|
41 |
:disabled="promptDraft.length < minPromptSize"
|
42 |
>
|
@@ -58,7 +68,7 @@
|
|
58 |
class="border-none w-full h-screen"
|
59 |
:src="!open
|
60 |
? '/placeholder.html'
|
61 |
-
: `/app?model=${encodeURIComponent(model)}&prompt=${encodeURIComponent(prompt)}`
|
62 |
"></iframe>
|
63 |
</div>
|
64 |
</div>
|
@@ -95,13 +105,14 @@ function humanFileSize(bytes, si=false, dp=1) {
|
|
95 |
return bytes.toFixed(dp) + ' ' + units[u];
|
96 |
}
|
97 |
function app() {
|
98 |
-
const defaultModel = 'OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5'
|
99 |
return {
|
100 |
open: false,
|
101 |
promptDraft: new URLSearchParams(window.location.search).get('prompt') || 'A simple page to compute the bmi, using kg and meters',
|
102 |
prompt: '',
|
103 |
-
modelDraft:
|
104 |
-
model:
|
|
|
|
|
105 |
size: 0,
|
106 |
minPromptSize: 16, // if you change this, you will need to also change in src/index.mts
|
107 |
timeoutInSec: 10, // time before we determine something went wrong
|
|
|
25 |
type="text"
|
26 |
name="modelDraft"
|
27 |
x-model="modelDraft"
|
28 |
+
placeholder="OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5"
|
29 |
class="input input-bordered w-full rounded text-lg text-stone-500 bg-stone-200 font-mono"
|
30 |
/>
|
31 |
+
<!--
|
32 |
+
<input
|
33 |
+
type="text"
|
34 |
+
name="endpointDraft"
|
35 |
+
x-model="endpointDraft"
|
36 |
+
placeholder="Endpoint URL (disabled by default)"
|
37 |
+
class="input input-bordered w-full rounded text-lg text-stone-500 bg-stone-200 font-mono"
|
38 |
+
/>
|
39 |
+
-->
|
40 |
<textarea
|
41 |
name="promptDraft"
|
42 |
x-model="promptDraft"
|
|
|
46 |
></textarea>
|
47 |
<button
|
48 |
class="btn disabled:text-stone-400"
|
49 |
+
@click="open = true, prompt = promptDraft, model = modelDraft, endpoint = endpointDraft, state = state === 'stopped' ? 'loading' : 'stopped'"
|
50 |
:class="promptDraft.length < minPromptSize ? 'btn-neutral' : state === 'stopped' ? 'btn-accent' : 'btn-warning'"
|
51 |
:disabled="promptDraft.length < minPromptSize"
|
52 |
>
|
|
|
68 |
class="border-none w-full h-screen"
|
69 |
:src="!open
|
70 |
? '/placeholder.html'
|
71 |
+
: `/app?model=${encodeURIComponent(model)}&endpoint=${encodeURIComponent(endpoint)}&prompt=${encodeURIComponent(prompt)}`
|
72 |
"></iframe>
|
73 |
</div>
|
74 |
</div>
|
|
|
105 |
return bytes.toFixed(dp) + ' ' + units[u];
|
106 |
}
|
107 |
function app() {
|
|
|
108 |
return {
|
109 |
open: false,
|
110 |
promptDraft: new URLSearchParams(window.location.search).get('prompt') || 'A simple page to compute the bmi, using kg and meters',
|
111 |
prompt: '',
|
112 |
+
modelDraft: '',
|
113 |
+
model: '',
|
114 |
+
endpoint: '',
|
115 |
+
endpointDraft: '',
|
116 |
size: 0,
|
117 |
minPromptSize: 16, // if you change this, you will need to also change in src/index.mts
|
118 |
timeoutInSec: 10, // time before we determine something went wrong
|
src/index.mts
CHANGED
@@ -59,6 +59,10 @@ app.get("/app", async (req, res) => {
|
|
59 |
|
60 |
console.log('model:', model)
|
61 |
|
|
|
|
|
|
|
|
|
62 |
if (`${req.query.prompt}`.length < minPromptSize) {
|
63 |
res.write(`prompt too short, please enter at least ${minPromptSize} characters`)
|
64 |
res.end()
|
|
|
59 |
|
60 |
console.log('model:', model)
|
61 |
|
62 |
+
const endpoint = `${req.query.endpoint || ''}`
|
63 |
+
|
64 |
+
console.log('endpoint:', endpoint)
|
65 |
+
|
66 |
if (`${req.query.prompt}`.length < minPromptSize) {
|
67 |
res.write(`prompt too short, please enter at least ${minPromptSize} characters`)
|
68 |
res.end()
|