diff --git a/examples/server/public/index.html b/examples/server/public/index.html
index 07d779d20..8422df4ca 100644
--- a/examples/server/public/index.html
+++ b/examples/server/public/index.html
@@ -10,6 +10,7 @@
body {
font-family: system-ui;
font-size: 90%;
+ width: 100%;
}
#container {
@@ -18,6 +19,7 @@
flex-direction: column;
justify-content: space-between;
height: 100%;
+ width: 100%;
}
main {
@@ -29,18 +31,15 @@
flex-grow: 1;
overflow-y: auto;
-
- border: 1px solid #ccc;
- border-radius: 5px;
padding: 0.5em;
}
body {
- max-width: 600px;
min-width: 300px;
line-height: 1.2;
margin: 0 auto;
padding: 0 0.5em;
+ box-sizing: border-box;
}
p {
@@ -142,6 +141,81 @@
display: inline;
}
+ header {
+ display: flex;
+ justify-content: space-between;
+ align-items: baseline;
+ }
+
+ .header_controls {
+ gap: 0.5rem;
+ display: flex;
+ }
+
+ .flexform {
+ display: flex;
+ max-height: 100%;
+ height: 100%;
+ flex-wrap: wrap;
+ }
+
+ .column {
+ flex-grow: 1;
+ padding: 1rem;
+ box-sizing: border-box;
+ }
+
+ .aside {
+ max-width: 300px;
+ overflow: auto;
+ background: rgba(220, 220, 220, 0.2);
+ }
+
+ @media (max-width:600px) {
+ .aside {
+ max-width: 100%;
+ }
+ }
+
+ .range_field {
+ border-bottom: 1px dashed;
+ padding-bottom: 0.5em;
+ }
+
+ .range_field:last-child {
+ border-bottom: none;
+ }
+
+ .range_field label {
+ display: flex;
+ justify-content: space-between;
+ }
+
+ .range_field input {
+ width: 100%;
+ }
+
+ .basecontainer {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+ overflow: hidden;
+ }
+
+ #content {
+ overflow: auto;
+ }
+
+ .response p {
+ padding: 0.5em;
+ margin: 0;
+ border-radius: 0.5em;
+ }
+
+ .response p:nth-child(even) {
+ background-color: rgba(242, 242, 242, 0.5);
+ }
+
header,
footer {
text-align: center;
@@ -150,8 +224,18 @@
footer {
font-size: 80%;
color: #888;
+ box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(0, 0, 0, 0) 0px 0px 0px 0px, rgba(229, 231, 235, 0.53) 0px -1px 0px 0px, rgba(0, 0, 0, 0.24) 0px 5px 20px -5px;
+ padding-top: 0.5em;
}
+
+ @media (max-width:600px) {
+ .footernote {
+ display: block;
+ }
+ }
+
+
.mode-chat textarea[name=prompt] {
height: 4.5em;
}
@@ -537,26 +621,26 @@
}
return html`
-
- `
+
+ `
}
function CompletionControls() {
@@ -565,11 +649,11 @@
runCompletion();
}
return html`
-
-
-
-
-
`;
+
+
+
+
+
`;
}
const ChatLog = (props) => {
@@ -613,12 +697,12 @@
}
return html`
-
-

-
- ${messages.flatMap(chatLine)}
-
-
`;
+
+

+
+ ${messages.flatMap(chatLine)}
+
+
`;
};
const ConfigForm = (props) => {
@@ -649,22 +733,20 @@
const FloatField = ({ label, max, min, name, step, value }) => {
return html`
-
-
-
- ${value}
-
- `
+
+
+
+
+ `
};
const IntField = ({ label, max, min, name, value }) => {
return html`
-
-
-
- ${value}
-
- `
+
+
+
+
+ `
};
const userTemplateReset = (e) => {
@@ -675,129 +757,145 @@
const UserTemplateResetButton = () => {
if (selectedUserTemplate.value.name == 'default') {
return html`
-
- `
+
+ `
}
return html`
-
- `
+
+ `
};
useEffect(() => {
// autosave template on every change
userTemplateAutosave()
- }, [session.value, params.value])
+ }, [session.value])// removed params.value as it would re render the page.
const GrammarControl = () => (
html`
-
-
-
- `
+
+ Grammer Configuration
+
+
+ `
);
const PromptControlFieldSet = () => (
html`
-
- `
+
+ `
);
const ChatConfigForm = () => (
html`
- ${PromptControlFieldSet()}
+ ${PromptControlFieldSet()}
-
-
-
-
-
+
+
+
+
-
-
-
- ${GrammarControl()}
-
- `
+
+
+
+
+ `
);
const CompletionConfigForm = () => (
html`
- ${PromptControlFieldSet()}
- ${GrammarControl()}
- `
+ ${PromptControlFieldSet()}
+ `
);
- return html`
-
+
+
+ Mirostat
+
+
+
+
+
+
+ ${FloatField({ label: "Mirostat tau", max: 10.0, min: 0.0, name: "mirostat_tau", step: 0.01, value: params.value.mirostat_tau })}
+ ${FloatField({ label: "Mirostat eta", max: 1.0, min: 0.0, name: "mirostat_eta", step: 0.01, value: params.value.mirostat_eta })}
+
+
`
+ );
+
+ const ModeSelector = () => (
+ html`
+
+ `
+ )
+
+ if (props?.header)
+ return html`<${ModeSelector} />`
+
+ return html`
+
+ `
}
const probColor = (p) => {
@@ -830,30 +928,30 @@
const pColor = found ? probColor(found.prob) : 'transparent'
const popoverChildren = html`
-
- ${probs.map((p, index) => {
+
+ ${probs.map((p, index) => {
return html`
-
- ${p.tok_str}:
- ${Math.floor(p.prob * 100)}%
-
- `
+ >
+
${p.tok_str}:
+
${Math.floor(p.prob * 100)}%
+
+ `
})}
-
- `
+
+ `
return html`
- <${Popover} style=${{ backgroundColor: pColor }} popoverChildren=${popoverChildren}>
- ${msg.content.match(/\n/gim) ? html`
` : msg.content}
- >
- `
+ <${Popover} style=${{ backgroundColor: pColor }} popoverChildren=${popoverChildren}>
+ ${msg.content.match(/\n/gim) ? html`
` : msg.content}
+ >
+ `
});
}
@@ -879,10 +977,10 @@
return html``
}
return html`
-
- ${llamaStats.value.predicted_per_token_ms.toFixed()}ms per token, ${llamaStats.value.predicted_per_second.toFixed(2)} tokens per second
-
- `
+
+ ${llamaStats.value.predicted_per_token_ms.toFixed()}ms per token, ${llamaStats.value.predicted_per_second.toFixed(2)} tokens per second |
+
+ `
}
// simple popover impl
@@ -917,22 +1015,22 @@
}, []);
return html`
- ${props.children}
- ${isOpen.value && html`
- <${Portal} into="#portal">
- ${props.children}
+ ${isOpen.value && html`
+ <${Portal} into="#portal">
+
- ${props.popoverChildren}
-
- ${Portal}>
- `}
- `;
+ >
+ ${props.popoverChildren}
+
+ ${Portal}>
+ `}
+ `;
};
// Source: preact-portal (https://github.com/developit/preact-portal/blob/master/src/preact-portal.js)
@@ -975,10 +1073,10 @@
}
this.remote = render(html`
- <${PortalProxy} context=${this.context}>
- ${show && this.props.children || null}
- ${PortalProxy}>
- `, this.into, this.remote);
+ <${PortalProxy} context=${this.context}>
+ ${show && this.props.children || null}
+ ${PortalProxy}>
+ `, this.into, this.remote);
}
render() {
@@ -999,29 +1097,29 @@
function App(props) {
return html`
-
-
+
+
+ llama.cpp
+ <${ConfigForm} header/>
+
-
- <${chatStarted.value ? ChatLog : ConfigForm} />
-
+
+ <${chatStarted.value ? ChatLog : ConfigForm} />
+
-
- <${session.value.type === 'chat' ? MessageInput : CompletionControls} />
-
-
-
-
- `;
+
+
+ `;
}
render(h(App), document.querySelector('#container'));
+
@@ -1031,5 +1129,4 @@
-