|
16 | 16 |
|
17 | 17 | #container { |
18 | 18 | margin: 0em auto; |
19 | | - |
20 | 19 | display: flex; |
21 | 20 | flex-direction: column; |
22 | 21 | justify-content: space-between; |
|
35 | 34 | gap: 1em; |
36 | 35 |
|
37 | 36 | flex-grow: 1; |
38 | | - border-style: outset; |
39 | | - padding: 1em; |
40 | | - } |
41 | | - |
42 | | - main .content { |
43 | | - flex-grow: 1; |
44 | | - } |
45 | | - |
46 | | - main .content > * { |
47 | 37 | overflow-y: auto; |
48 | | - } |
49 | 38 |
|
50 | | - footer { |
51 | | - font-size: smaller; |
52 | | - color: #999; |
| 39 | + border: 1px solid #ccc; |
| 40 | + border-radius: 5px; |
| 41 | + padding: 0.5em; |
53 | 42 | } |
54 | 43 |
|
55 | 44 | body { |
56 | 45 | max-width: 600px; |
57 | 46 | min-width: 300px; |
58 | 47 | line-height: 1.2; |
59 | 48 | margin: 0 auto; |
| 49 | + padding: 0 0.5em; |
60 | 50 | } |
61 | 51 |
|
62 | 52 | p { |
|
67 | 57 | margin-bottom: 0.5em; |
68 | 58 | } |
69 | 59 |
|
70 | | - form { |
| 60 | + #write form { |
71 | 61 | margin: 1em 0 0 0; |
72 | 62 | display: flex; |
| 63 | + flex-direction: column; |
73 | 64 | gap: 0.5em; |
74 | | - flex-direction: row; |
75 | | - align-items: center; |
| 65 | + align-items: stretch; |
76 | 66 | } |
77 | 67 |
|
78 | | - form > * { |
79 | | - padding: 4px; |
| 68 | + .right { |
| 69 | + display: flex; |
| 70 | + flex-direction: row; |
| 71 | + gap: 0.5em; |
| 72 | + justify-content: flex-end; |
80 | 73 | } |
81 | 74 |
|
82 | | - form input { |
83 | | - flex-grow: 1; |
| 75 | + fieldset { |
| 76 | + border: none; |
| 77 | + padding: 0; |
| 78 | + margin: 0; |
84 | 79 | } |
85 | 80 |
|
86 | | - form textarea { |
| 81 | + textarea { |
87 | 82 | flex-grow: 1; |
88 | | - min-height: 5em; |
89 | | - width: 100%; |
90 | | - } |
91 | | - |
92 | | - fieldset { |
93 | 83 | width: 100%; |
94 | | - padding: 1em; |
95 | 84 | } |
96 | 85 |
|
97 | 86 | fieldset label { |
|
209 | 198 | message.value = ""; |
210 | 199 | } |
211 | 200 |
|
| 201 | + const enterSubmits = (event) => { |
| 202 | + if (event.which === 13 && !event.shiftKey) { |
| 203 | + submit(event); |
| 204 | + } |
| 205 | + } |
| 206 | + |
212 | 207 | return html` |
213 | 208 | <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"> |
215 | 214 | <button type="submit" disabled=${!generating.value} >Send</button> |
216 | 215 | <button onclick=${stop} disabled=${generating}>Stop</button> |
217 | 216 | <button onclick=${reset}>Reset</button> |
| 217 | + </div> |
218 | 218 | </form> |
219 | 219 | ` |
220 | 220 | } |
|
241 | 241 | }; |
242 | 242 |
|
243 | 243 | const ConfigForm = (props) => { |
244 | | - |
245 | 244 | const updateSession = (el) => session.value = { ...session.value, [el.target.name]: el.target.value } |
246 | 245 | const updateParams = (el) => params.value = { ...params.value, [el.target.name]: el.target.value } |
247 | 246 | 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 | | - |
250 | 247 |
|
251 | 248 | return html` |
252 | 249 | <form> |
253 | 250 | <fieldset> |
254 | | - <legend>Settings</legend> |
255 | | -
|
256 | 251 | <div> |
257 | 252 | <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}/> |
259 | 254 | </div> |
260 | 255 |
|
261 | 256 | <div> |
|
270 | 265 |
|
271 | 266 | <div> |
272 | 267 | <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}/> |
274 | 269 | </div> |
275 | 270 |
|
276 | 271 | <div> |
277 | 272 | <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}/> |
279 | 274 | </div> |
280 | 275 |
|
281 | 276 | <div> |
|
286 | 281 |
|
287 | 282 | <div> |
288 | 283 | <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} /> |
290 | 285 | <span>${params.value.n_predict}</span> |
291 | 286 | </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 | +
|
292 | 300 | </fieldset> |
293 | 301 | </form> |
294 | 302 | ` |
|
303 | 311 | <h1>llama.cpp</h1> |
304 | 312 | </header> |
305 | 313 |
|
306 | | - <main> |
307 | | - <div id="content"> |
| 314 | + <main id="content"> |
308 | 315 | <${chatStarted.value ? ChatLog : ConfigForm} /> |
309 | | - </div> |
310 | | - <div> |
311 | | - <${MessageInput} /> |
312 | | - </div> |
313 | 316 | </main> |
314 | 317 |
|
| 318 | + <footer id="write"> |
| 319 | + <${MessageInput} /> |
| 320 | + </footer> |
| 321 | +
|
315 | 322 | <footer> |
316 | 323 | <p>Powered by <a href="https://github.com/ggerganov/llama.cpp">llama.cpp</a> and <a href="https://ggml.ai">ggml.ai</a></p> |
317 | 324 | </footer> |
|
0 commit comments