Users, groups, permissions, model settings and reasoning display
Four features, plus the schema machinery they needed. **Schema sync.** The first live instance had data in it, and create_all only creates missing *tables* -- a new column silently never appeared. db/migrations.py now diffs the declared models against the database and ALTER TABLE ... ADD COLUMN for what is missing, deriving a backfill default from the column type (SQLite refuses a NOT NULL column without one, and a Python-side `default=dict` cannot be expressed in DDL). Verified against a copy of the live database: eight changes applied, all rows preserved, second run a no-op. Renames, drops and retypes are still manual and say so. **Permissions.** A flat set of named booleans: an instance baseline widened by each group the user belongs to. A group grants and never denies -- with denies, "why can this user not do X" cannot be answered without simulating every group. Admins bypass entirely, because an admin can grant it back to themselves in two clicks and pretending otherwise is theatre. Model *access* is separate: public, or granted to groups. The picker is not the boundary -- switching a chat to a model you cannot reach is a 403. **Model settings.** Ordering, pinned-first, an instance default and a per-user default, display names, descriptions, capability flags, and uploaded images. Images are stored and served locally rather than by URL: a remote URL makes every page render a request to a third party. Uploads are validated by magic number, not the declared content type, and stored under a random name. Models with no image get a generated initial whose hue is derived from the model id, so it is stable. **Reasoning display.** Streams into its own collapsible block above the answer, labelled "Thought for 14 seconds", collapsed once finished, and never replayed as context on the next turn. Two sources: the reasoning_content delta field, and <think> tags inline in content -- the latter needs a streaming splitter because the tags arrive split across chunks. Models emitting no reasoning show nothing, via a :has() rule rather than JavaScript. Verified against qwen35-9b on llama-swap: 694 reasoning events, 52 answer tokens, cleanly separated. Two bugs found and fixed while testing: - A bare `Mapped[list]` relationship is treated by SQLAlchemy as a scalar and returns None instead of []. It needs the element type. - FastAPI substitutes the default for an empty form value, so with `x: str | None = Form(None)` a submitted `x=` is indistinguishable from an absent field. That silently broke clearing a system prompt or a temperature. update_chat now reads the raw form and checks key presence. 143 tests, ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -103,6 +103,81 @@
|
||||
}
|
||||
.nav-item.is-disabled:hover { background: none; color: var(--ink-muted); }
|
||||
|
||||
/* --- Model list ----------------------------------------------------------- */
|
||||
.bulk-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
.bulk-bar .model-rows { flex-basis: 100%; margin-top: var(--sp-3); }
|
||||
|
||||
.model-rows {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
overflow: hidden;
|
||||
}
|
||||
.model-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-3);
|
||||
padding: var(--sp-3);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
}
|
||||
.model-row:last-child { border-bottom: 0; }
|
||||
.model-row.is-off { opacity: 0.55; }
|
||||
.model-row__check { accent-color: var(--accent); width: 1rem; height: 1rem; flex: none; }
|
||||
.model-row__avatar { flex: none; }
|
||||
.model-row__main { flex: 1; min-width: 0; }
|
||||
.model-row__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.model-row__id {
|
||||
display: block;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-muted);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.model-row__actions { display: flex; gap: var(--sp-1); flex: none; align-items: center; }
|
||||
|
||||
/* --- Permission and checkbox grids ---------------------------------------- */
|
||||
.checkbox-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--sp-2) var(--sp-4);
|
||||
}
|
||||
.checkbox-row .checkbox { flex: 0 0 auto; }
|
||||
.checkbox.is-muted { opacity: 0.6; }
|
||||
|
||||
.perm-row {
|
||||
align-items: flex-start;
|
||||
padding: var(--sp-2) 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.perm-row:last-child { border-bottom: 0; }
|
||||
.perm-row input { margin-top: 0.2rem; }
|
||||
.perm-row__desc {
|
||||
display: block;
|
||||
font-size: var(--text-xs);
|
||||
color: var(--ink-faint);
|
||||
font-weight: 400;
|
||||
line-height: var(--leading-normal);
|
||||
}
|
||||
|
||||
.input--file {
|
||||
padding: 0.35rem;
|
||||
font-size: var(--text-sm);
|
||||
background: var(--surface-raised);
|
||||
}
|
||||
|
||||
.field__hint code {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.92em;
|
||||
|
||||
@@ -137,6 +137,66 @@
|
||||
}
|
||||
@keyframes caret { 0%, 49% { opacity: 0.75; } 50%, 100% { opacity: 0; } }
|
||||
|
||||
/* --- Reasoning ------------------------------------------------------------ */
|
||||
.reasoning {
|
||||
margin: 0 0 var(--sp-3);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: color-mix(in srgb, var(--surface) 70%, transparent);
|
||||
font-size: var(--text-sm);
|
||||
}
|
||||
|
||||
/*
|
||||
A live block is emitted before the first token arrives, and plenty of models
|
||||
emit no reasoning at all. Hiding it until it has content means those models
|
||||
never show an empty "Thinking" box, and no JavaScript is involved either way.
|
||||
*/
|
||||
.reasoning--live:not(:has(.reasoning__body:not(:empty))) { display: none; }
|
||||
|
||||
.reasoning__summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sp-2);
|
||||
padding: var(--sp-2) var(--sp-3);
|
||||
cursor: pointer;
|
||||
color: var(--ink-muted);
|
||||
list-style: none;
|
||||
user-select: none;
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
.reasoning__summary::-webkit-details-marker { display: none; }
|
||||
.reasoning__summary:hover { color: var(--ink); background: var(--surface-hover); }
|
||||
|
||||
.reasoning__icon { color: var(--gold); flex: none; }
|
||||
.reasoning__label { flex: 1; font-style: italic; }
|
||||
|
||||
.reasoning__chevron {
|
||||
flex: none;
|
||||
transition: transform var(--transition-fast);
|
||||
}
|
||||
.reasoning[open] .reasoning__chevron { transform: rotate(180deg); }
|
||||
|
||||
.reasoning__body {
|
||||
padding: 0 var(--sp-3) var(--sp-3);
|
||||
margin-left: var(--sp-2);
|
||||
border-left: 2px solid var(--border-strong);
|
||||
padding-left: var(--sp-3);
|
||||
white-space: pre-wrap;
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--leading-relaxed);
|
||||
max-height: 26rem;
|
||||
overflow-y: auto;
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
/* Gentle pulse on the icon while thinking is still streaming. */
|
||||
.reasoning--live .reasoning__icon { animation: think-pulse 1.6s ease-in-out infinite; }
|
||||
@keyframes think-pulse {
|
||||
0%, 100% { opacity: 0.45; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
|
||||
/* --- Message actions ------------------------------------------------------ */
|
||||
.msg__actions {
|
||||
display: flex;
|
||||
@@ -326,6 +386,57 @@
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* --- Chat settings panel -------------------------------------------------- */
|
||||
.chat-settings {
|
||||
flex: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--bg-sunken);
|
||||
max-height: 60vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.chat-settings__inner {
|
||||
max-width: var(--thread-max-width);
|
||||
margin: 0 auto;
|
||||
padding: var(--sp-4) var(--sp-5);
|
||||
}
|
||||
.chat-settings__note {
|
||||
color: var(--ink-muted);
|
||||
font-size: var(--text-sm);
|
||||
font-style: italic;
|
||||
margin-bottom: var(--sp-4);
|
||||
}
|
||||
.chat-settings__params {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
|
||||
gap: var(--sp-3);
|
||||
}
|
||||
.chat-settings__params .field { margin-bottom: 0; }
|
||||
|
||||
/* --- Model avatars -------------------------------------------------------- */
|
||||
.model-avatar {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
flex: none;
|
||||
border-radius: var(--radius);
|
||||
object-fit: cover;
|
||||
background: var(--surface-active);
|
||||
}
|
||||
.model-avatar--initial {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 600;
|
||||
font-size: var(--text-sm);
|
||||
/* Hue comes from the model id (see the stable_hue filter); saturation and
|
||||
lightness are fixed so every generated badge stays legible in both themes. */
|
||||
background: hsl(var(--avatar-hue, 40) 42% 34%);
|
||||
color: hsl(var(--avatar-hue, 40) 60% 92%);
|
||||
}
|
||||
:root[data-theme="shire"] .model-avatar--initial {
|
||||
background: hsl(var(--avatar-hue, 40) 46% 82%);
|
||||
color: hsl(var(--avatar-hue, 40) 60% 22%);
|
||||
}
|
||||
|
||||
/* --- Theme toggle --------------------------------------------------------- */
|
||||
/* Only the icon for the theme you would switch TO is shown. */
|
||||
:root[data-theme="moria"] .theme-icon--dark { display: none; }
|
||||
|
||||
@@ -60,6 +60,25 @@
|
||||
<span class="brand-llm">LL</span>e<span class="brand-llm">M</span>bas
|
||||
{%- endmacro %}
|
||||
|
||||
{#
|
||||
A model's avatar: the uploaded image, or a generated initial.
|
||||
|
||||
The fallback colour is derived from the model id, so every model gets a
|
||||
stable, distinct-looking badge without an administrator having to upload
|
||||
anything. Hue only -- saturation and lightness are fixed so the result always
|
||||
sits legibly against both themes.
|
||||
#}
|
||||
{% macro model_avatar(model, cls="model-avatar") -%}
|
||||
{% if model.image_path %}
|
||||
<img class="{{ cls }}" src="/uploads/models/{{ model.image_path }}"
|
||||
alt="" loading="lazy" width="32" height="32">
|
||||
{% else %}
|
||||
<span class="{{ cls }} model-avatar--initial"
|
||||
style="--avatar-hue: {{ model.model_id | stable_hue }}"
|
||||
aria-hidden="true">{{ model.initial }}</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro brand(href="/", uid="a") -%}
|
||||
<a class="sidebar__brand" href="{{ href }}">
|
||||
{{ mark(uid=uid) }}
|
||||
|
||||
@@ -35,17 +35,25 @@
|
||||
{{ icon("sliders", "icon--sm") }}
|
||||
<span class="nav-item__label">Models</span>
|
||||
</a>
|
||||
<a class="nav-item {{ 'is-active' if section == 'users' }}" href="/admin/users">
|
||||
{{ icon("user", "icon--sm") }}
|
||||
<span class="nav-item__label">Users</span>
|
||||
</a>
|
||||
<a class="nav-item {{ 'is-active' if section == 'groups' }}" href="/admin/groups">
|
||||
{{ icon("users", "icon--sm") }}
|
||||
<span class="nav-item__label">Groups & permissions</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="nav-group">
|
||||
<div class="nav-group__label">Not yet built</div>
|
||||
<span class="nav-item is-disabled">
|
||||
{{ icon("users", "icon--sm") }}
|
||||
<span class="nav-item__label">Users & groups</span>
|
||||
{{ icon("gear", "icon--sm") }}
|
||||
<span class="nav-item__label">Tools</span>
|
||||
</span>
|
||||
<span class="nav-item is-disabled">
|
||||
{{ icon("sliders", "icon--sm") }}
|
||||
<span class="nav-item__label">Tools</span>
|
||||
{{ icon("server", "icon--sm") }}
|
||||
<span class="nav-item__label">Agents</span>
|
||||
</span>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
{% extends "admin/_layout.html" %}
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
{% set section = "groups" %}
|
||||
|
||||
{% block title %}Groups & permissions - LLeMbas{% endblock %}
|
||||
{% block heading %}Groups & permissions{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Permissions are a <strong>union</strong>: everyone starts with the baseline
|
||||
below, and each group they belong to can add more. A group never takes
|
||||
something away, so being in a second group can only widen what someone can do.
|
||||
Administrators bypass all of it.
|
||||
</p>
|
||||
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ saved }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Baseline permissions</h2>
|
||||
<p class="text-sm muted" style="margin-bottom: var(--sp-4)">
|
||||
What every signed-in user can do before any group is considered. Turn
|
||||
something off here and grant it through a group to make it opt-in.
|
||||
</p>
|
||||
|
||||
<form method="post" action="/admin/permissions/defaults">
|
||||
{% for section_name, defs in permission_groups.items() %}
|
||||
<div class="field">
|
||||
<span class="field__label">{{ section_name }}</span>
|
||||
{% for definition in defs %}
|
||||
<label class="checkbox perm-row">
|
||||
<input type="checkbox" name="permission" value="{{ definition.key }}"
|
||||
{{ 'checked' if baseline[definition.key] }}>
|
||||
<span>
|
||||
<strong>{{ definition.label }}</strong>
|
||||
<span class="perm-row__desc">{{ definition.description }}</span>
|
||||
</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button class="btn btn--primary" type="submit">Save baseline</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<h2 class="admin-section-title">
|
||||
Groups <span class="badge">{{ groups|length }}</span>
|
||||
</h2>
|
||||
|
||||
<section class="card">
|
||||
<form method="post" action="/admin/groups" class="row" style="gap: var(--sp-2)">
|
||||
<input class="input" name="name" placeholder="New group name" required
|
||||
aria-label="New group name">
|
||||
<button class="btn btn--primary" type="submit">
|
||||
{{ icon("plus", "icon--sm") }} Create group
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
{% if not groups %}
|
||||
<div class="empty" style="padding: var(--sp-8) 0">
|
||||
{{ icon("users", "empty__mark") }}
|
||||
<p class="empty__text">
|
||||
No groups yet. Create one to grant extra permissions, or to restrict a model
|
||||
to a subset of users.
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% for group in groups %}
|
||||
<section class="card">
|
||||
<form method="post" action="/admin/groups/{{ group.id }}">
|
||||
<div class="row row--between" style="margin-bottom: var(--sp-4)">
|
||||
<strong>{{ group.name }}</strong>
|
||||
<span class="text-xs faint">
|
||||
{{ group.users|length }} member{{ '' if group.users|length == 1 else 's' }},
|
||||
{{ group.models|length }} model{{ '' if group.models|length == 1 else 's' }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="gn-{{ group.id }}">Name</label>
|
||||
<input class="input" id="gn-{{ group.id }}" name="name" value="{{ group.name }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="gd-{{ group.id }}">Description</label>
|
||||
<input class="input" id="gd-{{ group.id }}" name="description"
|
||||
value="{{ group.description }}" placeholder="What is this group for?">
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="field__label">Grants</span>
|
||||
<p class="field__hint" style="margin-bottom: var(--sp-2)">
|
||||
Anything already in the baseline stays on regardless — these only add.
|
||||
</p>
|
||||
{% for section_name, defs in permission_groups.items() %}
|
||||
{% for definition in defs %}
|
||||
<label class="checkbox perm-row">
|
||||
<input type="checkbox" name="permission" value="{{ definition.key }}"
|
||||
{{ 'checked' if (group.permissions_json or {}).get(definition.key) }}>
|
||||
<span>
|
||||
<strong>{{ definition.label }}</strong>
|
||||
<span class="perm-row__desc">
|
||||
{{ definition.description }}
|
||||
{% if baseline[definition.key] %}<em>(already in the baseline)</em>{% endif %}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="field__label">Members</span>
|
||||
{% if users %}
|
||||
<div class="checkbox-row">
|
||||
{% for account in users %}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="user_ids" value="{{ account.id }}"
|
||||
{{ 'checked' if account in group.users }}>
|
||||
<span>{{ account.name }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="field__hint">No users yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="field__label">Model access</span>
|
||||
<p class="field__hint" style="margin-bottom: var(--sp-2)">
|
||||
Models marked “available to everyone” are reachable regardless. These
|
||||
grant access to the restricted ones.
|
||||
</p>
|
||||
{% if models %}
|
||||
<div class="checkbox-row">
|
||||
{% for model in models %}
|
||||
<label class="checkbox {{ 'is-muted' if model.public }}">
|
||||
<input type="checkbox" name="model_ids" value="{{ model.id }}"
|
||||
{{ 'checked' if model in group.models }}>
|
||||
<span>{{ model.label }}{% if model.public %} <em>(public)</em>{% endif %}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="field__hint">No models yet.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<button class="btn btn--primary" type="submit">Save {{ group.name }}</button>
|
||||
</form>
|
||||
|
||||
<div class="connection__footer">
|
||||
<span class="text-xs faint">Deleting a group leaves its members alone.</span>
|
||||
<form method="post" action="/admin/groups/{{ group.id }}/delete"
|
||||
onsubmit="return confirm('Delete the group “{{ group.name }}”?')">
|
||||
<button class="btn btn--sm btn--danger" type="submit">
|
||||
{{ icon("trash", "icon--sm") }} Delete
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "admin/_layout.html" %}
|
||||
{% from "_macros.html" import icon %}
|
||||
{% from "_macros.html" import icon, model_avatar %}
|
||||
{% set section = "models" %}
|
||||
|
||||
{% block title %}Models - LLeMbas{% endblock %}
|
||||
@@ -7,45 +7,186 @@
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Every model discovered on each connection. Disable the ones you do not want
|
||||
cluttering the chat picker — nothing is deleted, and re-running
|
||||
“Test & refresh” will not bring a disabled model back on.
|
||||
Every model discovered across your connections. The order here is the order
|
||||
users see. Pinned models are offered first, and the default is what a new chat
|
||||
starts with.
|
||||
</p>
|
||||
|
||||
{% for connection in connections %}
|
||||
<section class="card">
|
||||
<h2 class="card__title">
|
||||
{{ connection.name }}
|
||||
<span class="badge">{{ connection.models|length }}</span>
|
||||
{% if not connection.enabled %}<span class="badge">connection disabled</span>{% endif %}
|
||||
</h2>
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ saved }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
{% if not connection.models %}
|
||||
<p class="muted text-sm">
|
||||
No models loaded. Run “Test & refresh” on
|
||||
<a href="/admin/connections">the connections page</a>.
|
||||
</p>
|
||||
{% else %}
|
||||
<ul class="model-list">
|
||||
{% for model in connection.models %}
|
||||
<li class="model-list__item">
|
||||
<code class="model-list__id">{{ model.model_id }}</code>
|
||||
<form method="post" action="/admin/models/{{ model.id }}/toggle">
|
||||
<button class="btn btn--sm {{ 'btn--primary' if model.enabled }}" type="submit">
|
||||
{% if model.enabled %}{{ icon("check", "icon--sm") }} Enabled{% else %}Disabled{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% else %}
|
||||
{% if not models %}
|
||||
<div class="empty" style="padding: var(--sp-10) 0">
|
||||
{{ icon("server", "empty__mark") }}
|
||||
<p class="empty__text">
|
||||
No connections yet. <a href="/admin/connections">Add one</a> to load models.
|
||||
No models yet. <a href="/admin/connections">Add a connection</a> and run
|
||||
“Test & refresh”.
|
||||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
<form method="post" action="/admin/models/bulk" class="bulk-bar">
|
||||
<span class="text-sm muted">With selected:</span>
|
||||
<button class="btn btn--sm" name="action" value="enable" type="submit">Enable</button>
|
||||
<button class="btn btn--sm" name="action" value="disable" type="submit">Disable</button>
|
||||
<button class="btn btn--sm" name="action" value="public" type="submit">Make public</button>
|
||||
<button class="btn btn--sm" name="action" value="private" type="submit">Restrict</button>
|
||||
|
||||
<div class="model-rows">
|
||||
{% for model in models %}
|
||||
<div class="model-row {{ 'is-off' if not model.enabled }}">
|
||||
<input class="model-row__check" type="checkbox" name="model_ids" value="{{ model.id }}"
|
||||
aria-label="Select {{ model.label }}">
|
||||
|
||||
{{ model_avatar(model, cls="model-row__avatar") }}
|
||||
|
||||
<div class="model-row__main">
|
||||
<div class="model-row__title">
|
||||
<strong>{{ model.label }}</strong>
|
||||
{% if model.model_id == default_model %}
|
||||
<span class="badge badge--gold">{{ icon("star", "icon--sm") }} default</span>
|
||||
{% endif %}
|
||||
{% if model.pinned %}<span class="badge">pinned</span>{% endif %}
|
||||
{% if not model.enabled %}<span class="badge badge--danger">disabled</span>{% endif %}
|
||||
{% if not model.public %}
|
||||
<span class="badge">{{ model.groups|length }} group{{ '' if model.groups|length == 1 else 's' }}</span>
|
||||
{% endif %}
|
||||
{% for name, on in (model.capabilities_json or {}).items() %}
|
||||
{% if on %}<span class="badge badge--gold">{{ name }}</span>{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<code class="model-row__id">{{ model.model_id }}</code>
|
||||
<span class="text-xs faint">via {{ model.connection.name }}</span>
|
||||
</div>
|
||||
|
||||
<div class="model-row__actions">
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="Move up"
|
||||
formaction="/admin/models/{{ model.id }}/move" formmethod="post"
|
||||
name="direction" value="up" {{ 'disabled' if loop.first }}>
|
||||
{{ icon("arrow-up", "icon--sm") }}
|
||||
</button>
|
||||
<button class="btn btn--icon btn--sm" type="submit" aria-label="Move down"
|
||||
formaction="/admin/models/{{ model.id }}/move" formmethod="post"
|
||||
name="direction" value="down" {{ 'disabled' if loop.last }}>
|
||||
{{ icon("arrow-down", "icon--sm") }}
|
||||
</button>
|
||||
<a class="btn btn--sm" href="#model-{{ model.id }}">Edit</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h2 class="admin-section-title">Model settings</h2>
|
||||
|
||||
{% for model in models %}
|
||||
<section class="card" id="model-{{ model.id }}">
|
||||
<div class="row row--between" style="margin-bottom: var(--sp-4)">
|
||||
<div class="row" style="gap: var(--sp-3); min-width: 0">
|
||||
{{ model_avatar(model, cls="model-row__avatar") }}
|
||||
<div style="min-width: 0">
|
||||
<strong class="truncate">{{ model.label }}</strong>
|
||||
<div><code class="text-xs faint">{{ model.model_id }}</code></div>
|
||||
</div>
|
||||
</div>
|
||||
{% if model.model_id != default_model %}
|
||||
<form method="post" action="/admin/models/{{ model.id }}/default">
|
||||
<button class="btn btn--sm" type="submit">{{ icon("star", "icon--sm") }} Make default</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<form method="post" action="/admin/models/{{ model.id }}">
|
||||
<div class="field">
|
||||
<label class="field__label" for="dn-{{ model.id }}">Display name</label>
|
||||
<input class="input" id="dn-{{ model.id }}" name="display_name"
|
||||
value="{{ model.display_name }}" placeholder="{{ model.model_id }}">
|
||||
<p class="field__hint">Shown instead of the raw model id. Leave empty to use the id.</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="desc-{{ model.id }}">Description</label>
|
||||
<textarea class="textarea" id="desc-{{ model.id }}" name="description" rows="2"
|
||||
placeholder="What is this model good at?">{{ model.description }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="field__label">Capabilities</span>
|
||||
<div class="checkbox-row">
|
||||
{% for name in capabilities %}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="capability" value="{{ name }}"
|
||||
{{ 'checked' if (model.capabilities_json or {}).get(name) }}>
|
||||
<span>{{ name }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<p class="field__hint">
|
||||
Endpoints rarely advertise these reliably, so they are your call.
|
||||
<strong>reasoning</strong> shows the thinking block;
|
||||
<strong>vision</strong> and <strong>tools</strong> are used by features
|
||||
not built yet.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<div class="checkbox-row">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="enabled" value="true" {{ 'checked' if model.enabled }}>
|
||||
<span>Enabled</span>
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="pinned" value="true" {{ 'checked' if model.pinned }}>
|
||||
<span>Pinned — offered first in the picker</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="public" value="true" {{ 'checked' if model.public }}>
|
||||
<span>Available to everyone</span>
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Uncheck to restrict this model to specific groups. Administrators always
|
||||
have access.
|
||||
</p>
|
||||
{% if groups %}
|
||||
<div class="checkbox-row" style="margin-top: var(--sp-3)">
|
||||
{% for group in groups %}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="group_ids" value="{{ group.id }}"
|
||||
{{ 'checked' if group in model.groups }}>
|
||||
<span>{{ group.name }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="field__hint">
|
||||
No groups yet — <a href="/admin/groups">create one</a> to restrict access.
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<button class="btn btn--primary" type="submit">Save {{ model.label }}</button>
|
||||
</form>
|
||||
|
||||
<div class="connection__footer">
|
||||
<form method="post" action="/admin/models/{{ model.id }}/image"
|
||||
enctype="multipart/form-data" class="row" style="gap: var(--sp-2)">
|
||||
<input class="input input--file" type="file" name="image"
|
||||
accept="image/png,image/jpeg,image/webp,image/gif" required
|
||||
aria-label="Model image">
|
||||
<button class="btn btn--sm" type="submit">{{ icon("image", "icon--sm") }} Upload</button>
|
||||
</form>
|
||||
{% if model.image_path %}
|
||||
<form method="post" action="/admin/models/{{ model.id }}/image/delete">
|
||||
<button class="btn btn--sm btn--danger" type="submit">Remove image</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
{% extends "admin/_layout.html" %}
|
||||
{% from "_macros.html" import icon %}
|
||||
{% set section = "users" %}
|
||||
|
||||
{% block title %}Users - LLeMbas{% endblock %}
|
||||
{% block heading %}Users{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<p class="admin-lede">
|
||||
Everyone with an account on this instance. Administrators bypass every
|
||||
permission; ordinary users get the baseline permissions plus whatever their
|
||||
groups add.
|
||||
</p>
|
||||
|
||||
{% if saved %}
|
||||
<div class="alert alert--success">{{ icon("check", "icon--sm") }} <span>{{ saved }}</span></div>
|
||||
{% endif %}
|
||||
|
||||
<form method="get" action="/admin/users" class="row" style="margin-bottom: var(--sp-5)">
|
||||
<input class="input" type="search" name="q" value="{{ q }}"
|
||||
placeholder="Search by name or email" aria-label="Search users">
|
||||
<button class="btn" type="submit">{{ icon("search", "icon--sm") }} Search</button>
|
||||
{% if q %}<a class="btn btn--ghost" href="/admin/users">Clear</a>{% endif %}
|
||||
</form>
|
||||
|
||||
<details class="card">
|
||||
<summary class="card__title" style="cursor: pointer">Add a user</summary>
|
||||
<form method="post" action="/admin/users" style="margin-top: var(--sp-4)">
|
||||
<div class="field">
|
||||
<label class="field__label" for="nu-name">Name</label>
|
||||
<input class="input" id="nu-name" name="name" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="nu-email">Email</label>
|
||||
<input class="input" id="nu-email" name="email" type="email" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="nu-password">Password</label>
|
||||
<input class="input" id="nu-password" name="password" type="password"
|
||||
required minlength="8" autocomplete="new-password">
|
||||
<p class="field__hint">
|
||||
At least 8 characters. Tell them to change it — you will know it otherwise.
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="nu-role">Role</label>
|
||||
<select class="select" id="nu-role" name="role">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role }}" {{ 'selected' if role == 'user' }}>{{ role }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn--primary" type="submit">{{ icon("plus", "icon--sm") }} Create</button>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
<h2 class="admin-section-title">
|
||||
Accounts <span class="badge">{{ users|length }}</span>
|
||||
</h2>
|
||||
|
||||
{% for account in users %}
|
||||
<section class="card">
|
||||
<form method="post" action="/admin/users/{{ account.id }}">
|
||||
<div class="row row--between" style="margin-bottom: var(--sp-4); flex-wrap: wrap">
|
||||
<div class="row" style="gap: var(--sp-2); min-width: 0">
|
||||
<span class="status-dot {{ 'is-ok' if account.active else 'is-off' }}"></span>
|
||||
<strong class="truncate">{{ account.name }}</strong>
|
||||
<code class="text-xs faint">{{ account.email }}</code>
|
||||
{% if account.is_admin %}<span class="badge badge--gold">admin</span>{% endif %}
|
||||
{% if not account.active %}<span class="badge badge--danger">deactivated</span>{% endif %}
|
||||
{% if account.id == user.id %}<span class="badge">you</span>{% endif %}
|
||||
</div>
|
||||
<span class="text-xs faint">
|
||||
{% if account.last_login_at %}
|
||||
last seen {{ account.last_login_at.strftime("%Y-%m-%d %H:%M") }}
|
||||
{% else %}
|
||||
never signed in
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="un-{{ account.id }}">Name</label>
|
||||
<input class="input" id="un-{{ account.id }}" name="name" value="{{ account.name }}" required>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="ur-{{ account.id }}">Role</label>
|
||||
<select class="select" id="ur-{{ account.id }}" name="role">
|
||||
{% for role in roles %}
|
||||
<option value="{{ role }}" {{ 'selected' if role == account.role }}>{{ role }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<p class="field__hint">
|
||||
<strong>admin</strong> can do everything, including this page.
|
||||
<strong>user</strong> is an ordinary account.
|
||||
<strong>pending</strong> cannot sign in until promoted.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="active" value="true" {{ 'checked' if account.active }}>
|
||||
<span>Active — may sign in</span>
|
||||
</label>
|
||||
<p class="field__hint">
|
||||
Deactivating signs them out everywhere immediately, rather than waiting
|
||||
for their session to expire.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{% if groups %}
|
||||
<div class="field">
|
||||
<span class="field__label">Groups</span>
|
||||
<div class="checkbox-row">
|
||||
{% for group in groups %}
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="group_ids" value="{{ group.id }}"
|
||||
{{ 'checked' if group in account.groups }}>
|
||||
<span>{{ group.name }}</span>
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if account.is_admin and admin_count <= 1 %}
|
||||
<div class="alert alert--warning">
|
||||
{{ icon("warning", "alert__icon") }}
|
||||
<span>
|
||||
The only administrator. Promote someone else before demoting or
|
||||
deactivating this account — an instance with no admin can only be
|
||||
recovered with <code>lembas create-admin</code>.
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<button class="btn btn--primary" type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
<div class="connection__footer">
|
||||
<form method="post" action="/admin/users/{{ account.id }}/password" class="row"
|
||||
style="gap: var(--sp-2)">
|
||||
<input class="input" type="password" name="password" minlength="8"
|
||||
placeholder="Set a new password" autocomplete="new-password" required
|
||||
aria-label="New password for {{ account.email }}">
|
||||
<button class="btn btn--sm" type="submit">{{ icon("key", "icon--sm") }} Reset</button>
|
||||
</form>
|
||||
|
||||
{% if account.id != user.id %}
|
||||
<form method="post" action="/admin/users/{{ account.id }}/delete"
|
||||
onsubmit="return confirm('Delete {{ account.email }} and all their chats? This cannot be undone.')">
|
||||
<button class="btn btn--sm btn--danger" type="submit">
|
||||
{{ icon("trash", "icon--sm") }} Delete
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
@@ -39,6 +39,19 @@
|
||||
</header>
|
||||
|
||||
{% if streaming %}
|
||||
{# Reasoning arrives before the answer, so this block sits above it. It
|
||||
starts open (watching a model think is the point) and the :has() rule
|
||||
in chat.css hides the whole thing while it is still empty, so models
|
||||
that emit no reasoning never show an empty box. #}
|
||||
<details class="reasoning reasoning--live" id="reasoning-{{ message.id }}" open>
|
||||
<summary class="reasoning__summary">
|
||||
{{ icon("sparkle", "icon--sm reasoning__icon") }}
|
||||
<span class="reasoning__label">Thinking</span>
|
||||
{{ icon("chevron-down", "icon--sm reasoning__chevron") }}
|
||||
</summary>
|
||||
<div class="reasoning__body" sse-swap="reasoning" hx-swap="beforeend"></div>
|
||||
</details>
|
||||
|
||||
{# Tokens are appended here as they arrive. The cursor is a CSS
|
||||
pseudo-element on the empty parent, so it disappears by itself once
|
||||
the first token lands. #}
|
||||
@@ -47,6 +60,25 @@
|
||||
<div class="msg__waiting">
|
||||
<span class="dots"><i></i><i></i><i></i></span>
|
||||
</div>
|
||||
{% elif message.reasoning and not message.error %}
|
||||
{# Collapsed once finished: the answer is what the reader came for, and
|
||||
the thinking is there if they want to audit it. #}
|
||||
<details class="reasoning" id="reasoning-{{ message.id }}">
|
||||
<summary class="reasoning__summary">
|
||||
{{ icon("sparkle", "icon--sm reasoning__icon") }}
|
||||
<span class="reasoning__label">
|
||||
{% if message.reasoning_ms %}
|
||||
Thought for {{ message.reasoning_ms | duration }}
|
||||
{% else %}
|
||||
Reasoning
|
||||
{% endif %}
|
||||
</span>
|
||||
{{ icon("chevron-down", "icon--sm reasoning__chevron") }}
|
||||
</summary>
|
||||
<div class="reasoning__body">{{ message.reasoning }}</div>
|
||||
</details>
|
||||
<div class="msg__body">{{ body_html|safe }}</div>
|
||||
|
||||
{% elif message.error %}
|
||||
<div class="alert alert--error msg__error" role="alert">
|
||||
{{ icon("warning", "alert__icon") }}
|
||||
|
||||
@@ -23,22 +23,93 @@
|
||||
{% if chat %}
|
||||
<h1 class="topbar__title"><span id="chat-title">{{ chat.title }}</span></h1>
|
||||
|
||||
{% if models %}
|
||||
<form hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change from:find select">
|
||||
{% if models and can.get("chat.model_select") %}
|
||||
<form hx-patch="/api/chats/{{ chat.id }}" hx-swap="none"
|
||||
hx-trigger="change from:find select">
|
||||
<select class="select select--compact" name="model_id" aria-label="Model">
|
||||
{% for model in models %}
|
||||
<option value="{{ model.model_id }}" {{ 'selected' if model.model_id == chat.model_id }}>
|
||||
{{ model.label }}
|
||||
</option>
|
||||
{% if pinned_models %}
|
||||
<optgroup label="Pinned">
|
||||
{% for model in pinned_models %}
|
||||
<option value="{{ model.model_id }}"
|
||||
{{ 'selected' if model.model_id == chat.model_id }}>{{ model.label }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
<optgroup label="Other models">
|
||||
{% endif %}
|
||||
{% for model in other_models %}
|
||||
<option value="{{ model.model_id }}"
|
||||
{{ 'selected' if model.model_id == chat.model_id }}>{{ model.label }}</option>
|
||||
{% endfor %}
|
||||
{% if pinned_models %}</optgroup>{% endif %}
|
||||
</select>
|
||||
</form>
|
||||
{% elif current_model %}
|
||||
<span class="badge">{{ current_model.label }}</span>
|
||||
{% endif %}
|
||||
|
||||
<button class="btn btn--icon" type="button" aria-label="Chat settings"
|
||||
title="Chat settings"
|
||||
onclick="document.getElementById('chat-settings').toggleAttribute('hidden')">
|
||||
{{ icon("sliders") }}
|
||||
</button>
|
||||
{% else %}
|
||||
<h1 class="topbar__title">Chats</h1>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
||||
{% if chat and (can.get("chat.system_prompt") or can.get("chat.params")) %}
|
||||
{# Collapsed by default: these are per-chat overrides, not everyday controls.
|
||||
Each field saves on change rather than needing a Save button, so there is
|
||||
no half-applied state to reason about. #}
|
||||
<section class="chat-settings" id="chat-settings" hidden>
|
||||
<div class="chat-settings__inner">
|
||||
{% if current_model and current_model.description %}
|
||||
<p class="chat-settings__note">{{ current_model.description }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if can.get("chat.system_prompt") %}
|
||||
<div class="field">
|
||||
<label class="field__label" for="system-prompt">System prompt</label>
|
||||
<textarea class="textarea" id="system-prompt" name="system_prompt" rows="3"
|
||||
placeholder="Instructions that apply to every message in this chat."
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none"
|
||||
hx-trigger="change">{{ chat.system_prompt }}</textarea>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if can.get("chat.params") %}
|
||||
<div class="chat-settings__params">
|
||||
<div class="field">
|
||||
<label class="field__label" for="temperature">Temperature</label>
|
||||
<input class="input" id="temperature" name="temperature" type="number"
|
||||
min="0" max="2" step="0.05" placeholder="default"
|
||||
value="{{ chat.params_json.get('temperature', '') }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="top-p">Top-p</label>
|
||||
<input class="input" id="top-p" name="top_p" type="number"
|
||||
min="0" max="1" step="0.05" placeholder="default"
|
||||
value="{{ chat.params_json.get('top_p', '') }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="field__label" for="max-tokens">Max tokens</label>
|
||||
<input class="input" id="max-tokens" name="max_tokens" type="number"
|
||||
min="1" step="1" placeholder="default"
|
||||
value="{{ chat.params_json.get('max_tokens', '') }}"
|
||||
hx-patch="/api/chats/{{ chat.id }}" hx-swap="none" hx-trigger="change">
|
||||
</div>
|
||||
</div>
|
||||
<p class="field__hint">
|
||||
Leave a field empty to let the provider decide. Values outside the
|
||||
allowed range are ignored rather than clamped.
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% if not chat %}
|
||||
{# No chat selected. #}
|
||||
<div class="empty">
|
||||
|
||||
@@ -118,6 +118,24 @@
|
||||
<path d="M12 4.2 21 19.5H3Z"/>
|
||||
<path d="M12 10v4M12 16.8h.01"/>
|
||||
</symbol>
|
||||
<symbol id="i-sparkle" viewBox="0 0 24 24">
|
||||
<path d="M12 3.5 13.9 9 19.5 11l-5.6 2-1.9 5.5L10.1 13 4.5 11l5.6-2Z"/>
|
||||
<path d="M18.5 4v3M20 5.5h-3"/>
|
||||
</symbol>
|
||||
<symbol id="i-image" viewBox="0 0 24 24">
|
||||
<rect x="3.5" y="5" width="17" height="14" rx="2"/>
|
||||
<circle cx="9" cy="10" r="1.6"/>
|
||||
<path d="m4.5 17 4.2-4.2a1.5 1.5 0 0 1 2.1 0l3 3 1.9-1.9a1.5 1.5 0 0 1 2.1 0l2 2"/>
|
||||
</symbol>
|
||||
<symbol id="i-arrow-up" viewBox="0 0 24 24"><path d="M12 19V6M6 12l6-6 6 6"/></symbol>
|
||||
<symbol id="i-arrow-down" viewBox="0 0 24 24"><path d="M12 5v13M6 12l6 6 6-6"/></symbol>
|
||||
<symbol id="i-star" viewBox="0 0 24 24">
|
||||
<path d="m12 3.8 2.5 5.2 5.7.8-4.1 4 1 5.7-5.1-2.7-5.1 2.7 1-5.7-4.1-4 5.7-.8Z"/>
|
||||
</symbol>
|
||||
<symbol id="i-key" viewBox="0 0 24 24">
|
||||
<circle cx="8" cy="12" r="4"/>
|
||||
<path d="M12 12h8M17.5 12v3M20 12v2.5"/>
|
||||
</symbol>
|
||||
<symbol id="i-leaf" viewBox="0 0 64 64">
|
||||
<path d="M20.5 45.5C13.8 31.7 23.8 20.9 45.5 18.5 49.8 35 39.8 45.8 20.5 45.5Z"/>
|
||||
<path d="M20.5 45.5C28 38 36 29 45.5 18.5"/>
|
||||
|
||||
@@ -10,15 +10,24 @@
|
||||
{{ brand(uid="side") }}
|
||||
</div>
|
||||
|
||||
{# Buttons for actions the user cannot perform are omitted rather than
|
||||
disabled: a greyed-out control invites a support question, an absent one
|
||||
does not. The routes enforce the same permissions regardless. #}
|
||||
{% if can.get("chat.create") or can.get("folder.manage") %}
|
||||
<div class="sidebar__actions">
|
||||
{% if can.get("chat.create") %}
|
||||
<button class="btn btn--primary btn--block" hx-post="/api/chats" hx-swap="none">
|
||||
{{ icon("plus", "icon--sm") }} New chat
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if can.get("folder.manage") %}
|
||||
<button class="btn btn--icon" hx-post="/api/folders" hx-swap="none"
|
||||
hx-vals='{"name": "New folder"}' aria-label="New folder" title="New folder">
|
||||
{{ icon("folder") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<nav class="sidebar__scroll" id="sidebar-tree" aria-label="Chats">
|
||||
{% if folders %}
|
||||
|
||||
@@ -50,6 +50,52 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Default model</h2>
|
||||
{% if models %}
|
||||
<form method="post" action="/api/preferences/default-model">
|
||||
<div class="field">
|
||||
<select class="select" name="model_id" aria-label="Default model">
|
||||
<option value="">Use the instance default</option>
|
||||
{% for model in models %}
|
||||
<option value="{{ model.model_id }}"
|
||||
{{ 'selected' if model.model_id == user.settings_json.get('default_model') }}>
|
||||
{{ model.label }}{% if model.pinned %} — pinned{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<p class="field__hint">What a new chat starts with. Existing chats keep their model.</p>
|
||||
</div>
|
||||
<button class="btn btn--primary" type="submit">Save</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="muted text-sm">No models are available to you yet.</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Permissions</h2>
|
||||
<p class="text-sm muted" style="margin-bottom: var(--sp-3)">
|
||||
{% if user.is_admin %}
|
||||
You are an administrator, so every permission applies.
|
||||
{% else %}
|
||||
What this account may do, from the instance baseline plus your groups.
|
||||
{% endif %}
|
||||
</p>
|
||||
<div class="checkbox-row">
|
||||
{% for key, granted in can.items() %}
|
||||
<span class="badge {{ 'badge--success' if granted }}">
|
||||
{{ key }}{{ '' if granted else ' — no' }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if user.groups %}
|
||||
<p class="field__hint" style="margin-top: var(--sp-3)">
|
||||
Groups: {% for group in user.groups %}{{ group.name }}{% if not loop.last %}, {% endif %}{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2 class="card__title">Appearance</h2>
|
||||
<div class="row" style="gap: var(--sp-3)">
|
||||
|
||||
@@ -11,6 +11,7 @@ from fastapi.templating import Jinja2Templates
|
||||
from lembas import __version__
|
||||
from lembas.config import settings
|
||||
from lembas.db.models import User
|
||||
from lembas.services.reasoning import format_duration
|
||||
|
||||
TEMPLATE_DIR = Path(__file__).parent / "templates"
|
||||
STATIC_DIR = Path(__file__).parent / "static"
|
||||
@@ -19,6 +20,25 @@ templates = Jinja2Templates(directory=str(TEMPLATE_DIR))
|
||||
templates.env.trim_blocks = True
|
||||
templates.env.lstrip_blocks = True
|
||||
|
||||
# {{ message.reasoning_ms | duration }} -> "8 seconds"
|
||||
templates.env.filters["duration"] = format_duration
|
||||
|
||||
|
||||
def stable_hue(value: str) -> int:
|
||||
"""A deterministic 0-359 hue for a string.
|
||||
|
||||
Used for generated model avatars so each model gets its own colour without
|
||||
anyone choosing one, and the same model looks the same on every page and
|
||||
after every restart. Python's hash() is salted per process, hence md5.
|
||||
"""
|
||||
import hashlib
|
||||
|
||||
digest = hashlib.md5(value.encode("utf-8"), usedforsecurity=False).digest()
|
||||
return int.from_bytes(digest[:2], "big") % 360
|
||||
|
||||
|
||||
templates.env.filters["stable_hue"] = stable_hue
|
||||
|
||||
|
||||
def resolve_theme(user: User | None) -> str:
|
||||
"""Theme to render with on the server.
|
||||
|
||||
Reference in New Issue
Block a user