Skip to content

Commit eee6d69

Browse files
committed
fix mobile, fix missing prompt cache
1 parent fedce00 commit eee6d69

File tree

1 file changed

+51
-44
lines changed

1 file changed

+51
-44
lines changed

examples/server/public/index.html

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#container {
1818
margin: 0em auto;
19-
2019
display: flex;
2120
flex-direction: column;
2221
justify-content: space-between;
@@ -35,28 +34,19 @@
3534
gap: 1em;
3635

3736
flex-grow: 1;
38-
border-style: outset;
39-
padding: 1em;
40-
}
41-
42-
main .content {
43-
flex-grow: 1;
44-
}
45-
46-
main .content > * {
4737
overflow-y: auto;
48-
}
4938

50-
footer {
51-
font-size: smaller;
52-
color: #999;
39+
border: 1px solid #ccc;
40+
border-radius: 5px;
41+
padding: 0.5em;
5342
}
5443

5544
body {
5645
max-width: 600px;
5746
min-width: 300px;
5847
line-height: 1.2;
5948
margin: 0 auto;
49+
padding: 0 0.5em;
6050
}
6151

6252
p {
@@ -67,31 +57,30 @@
6757
margin-bottom: 0.5em;
6858
}
6959

70-
form {
60+
#write form {
7161
margin: 1em 0 0 0;
7262
display: flex;
63+
flex-direction: column;
7364
gap: 0.5em;
74-
flex-direction: row;
75-
align-items: center;
65+
align-items: stretch;
7666
}
7767

78-
form > * {
79-
padding: 4px;
68+
.right {
69+
display: flex;
70+
flex-direction: row;
71+
gap: 0.5em;
72+
justify-content: flex-end;
8073
}
8174

82-
form input {
83-
flex-grow: 1;
75+
fieldset {
76+
border: none;
77+
padding: 0;
78+
margin: 0;
8479
}
8580

86-
form textarea {
81+
textarea {
8782
flex-grow: 1;
88-
min-height: 5em;
89-
width: 100%;
90-
}
91-
92-
fieldset {
9383
width: 100%;
94-
padding: 1em;
9584
}
9685

9786
fieldset label {
@@ -209,12 +198,23 @@
209198
message.value = "";
210199
}
211200

201+
const enterSubmits = (event) => {
202+
if (event.which === 13 && !event.shiftKey) {
203+
submit(event);
204+
}
205+
}
206+
212207
return html`
213208
<form onsubmit=${submit}>
214-
<input type="text" value="${message}" oninput=${(e) => message.value = e.target.value} autofocus placeholder="Chat here..."/>
209+
<div>
210+
<textarea type="text" rows=2 onkeypress=${enterSubmits} value="${message}" oninput=${(e) => message.value = e.target.value} placeholder="Start here..."/>
211+
212+
</div>
213+
<div class="right">
215214
<button type="submit" disabled=${!generating.value} >Send</button>
216215
<button onclick=${stop} disabled=${generating}>Stop</button>
217216
<button onclick=${reset}>Reset</button>
217+
</div>
218218
</form>
219219
`
220220
}
@@ -241,21 +241,16 @@
241241
};
242242

243243
const ConfigForm = (props) => {
244-
245244
const updateSession = (el) => session.value = { ...session.value, [el.target.name]: el.target.value }
246245
const updateParams = (el) => params.value = { ...params.value, [el.target.name]: el.target.value }
247246
const updateParamsFloat = (el) => params.value = { ...params.value, [el.target.name]: parseFloat(el.target.value) }
248-
const updateParamsInt = (el) => params.value = { ...params.value, [el.target.name]: parseInt(el.target.value) }
249-
250247

251248
return html`
252249
<form>
253250
<fieldset>
254-
<legend>Settings</legend>
255-
256251
<div>
257252
<label for="prompt">Prompt</label>
258-
<textarea type="text" name="prompt" value="${session.value.prompt}" oninput=${updateSession}/>
253+
<textarea type="text" name="prompt" value="${session.value.prompt}" rows=4 oninput=${updateSession}/>
259254
</div>
260255
261256
<div>
@@ -270,12 +265,12 @@
270265
271266
<div>
272267
<label for="template">Prompt template</label>
273-
<textarea id="template" name="template" value="${session.value.template}" oninput=${updateSession}/>
268+
<textarea id="template" name="template" value="${session.value.template}" rows=4 oninput=${updateSession}/>
274269
</div>
275270
276271
<div>
277272
<label for="template">Chat history template</label>
278-
<textarea id="template" name="historyTemplate" value="${session.value.historyTemplate}" oninput=${updateSession}/>
273+
<textarea id="template" name="historyTemplate" value="${session.value.historyTemplate}" rows=1 oninput=${updateSession}/>
279274
</div>
280275
281276
<div>
@@ -286,9 +281,22 @@
286281
287282
<div>
288283
<label for="nPredict">Predictions</label>
289-
<input type="range" id="nPredict" min="1" max="2048" step="1" name="n_predict" value="${params.value.n_predict}" oninput=${updateParamsInt} />
284+
<input type="range" id="nPredict" min="1" max="2048" step="1" name="n_predict" value="${params.value.n_predict}" oninput=${updateParamsFloat} />
290285
<span>${params.value.n_predict}</span>
291286
</div>
287+
288+
<div>
289+
<label for="repeat_penalty">Penalize repeat sequence</label>
290+
<input type="range" id="repeat_penalty" min="0.0" max="2.0" step="0.01" name="repeat_penalty" value="${params.value.repeat_penalty}" oninput=${updateParamsFloat} />
291+
<span>${params.value.repeat_penalty}</span>
292+
</div>
293+
294+
<div>
295+
<label for="repeat_last_n">Consider N tokens for penalize</label>
296+
<input type="range" id="repeat_last_n" min="0.0" max="2048" name="repeat_last_n" value="${params.value.repeat_last_n}" oninput=${updateParamsFloat} />
297+
<span>${params.value.repeat_last_n}</span>
298+
</div>
299+
292300
</fieldset>
293301
</form>
294302
`
@@ -303,15 +311,14 @@
303311
<h1>llama.cpp</h1>
304312
</header>
305313
306-
<main>
307-
<div id="content">
314+
<main id="content">
308315
<${chatStarted.value ? ChatLog : ConfigForm} />
309-
</div>
310-
<div>
311-
<${MessageInput} />
312-
</div>
313316
</main>
314317
318+
<footer id="write">
319+
<${MessageInput} />
320+
</footer>
321+
315322
<footer>
316323
<p>Powered by <a href="https://github.com/ggerganov/llama.cpp">llama.cpp</a> and <a href="https://ggml.ai">ggml.ai</a></p>
317324
</footer>

0 commit comments

Comments
 (0)