a0f733063a
**Bases.** Documents now live in named collections rather than one flat pile, and a chat can be pointed at particular ones — "answer from the contracts folder" is a different question from "answer from everything I have ever uploaded". A chat with none attached still searches everything its owner can see, because empty means unscoped, not empty. The harness names the attached bases. Without that the model cannot tell "there is nothing about this" from "I am only allowed to see one folder", and it phrases a miss as the former. **Sharing moves to the base.** A document is visible to whoever can see the base it lives in, so `Document` is gone from the shareable types and `documents.visible()` filters through `base_id`. "This folder is the team's" is the granularity people think in; per-document grants meant answering "who can see this?" by checking every file. Moving a document between bases changes who can see it, so the destination has to be one you own. `Document.base_id` is nullable only because the column had to be added to a table that already had rows. `sweep_unfiled()` runs at startup beside the orphaned-upload sweep and files anything predating bases into its owner's default, which is what makes "always set" true everywhere else. **The file input.** `.input` gave it a fixed height and horizontal padding, so the browser's own button sat hard against the left edge while the filename floated off the centre line. A file input is two controls in one box and neither inherits anything useful, so it gets its own rule: no horizontal padding, the button sized to `--control-h` with the divider that separates it, and the text centred with line-height rather than flexbox, which file inputs do not lay out reliably. 437 tests, ruff clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
2.4 KiB
HTML
67 lines
2.4 KiB
HTML
{% extends "library/_layout.html" %}
|
|
{% from "_macros.html" import icon %}
|
|
{% set section = "knowledge" %}
|
|
|
|
{% block title %}Knowledge - LLeMbas{% endblock %}
|
|
{% block heading %}Knowledge{% endblock %}
|
|
|
|
{% block library_content %}
|
|
<p class="admin-lede">
|
|
Knowledge bases are collections of documents, images and saved web pages. Keep
|
|
them separate — one per subject, project or client — and a chat can be pointed
|
|
at just the ones it should draw on. Sharing happens here too: share a base and
|
|
everything in it comes with it.
|
|
</p>
|
|
|
|
{% if error %}
|
|
<div class="alert alert--error">{{ icon("warning", "alert__icon") }} <span>{{ error }}</span></div>
|
|
{% endif %}
|
|
|
|
{% if bases %}
|
|
<ul class="model-list">
|
|
{% for base in bases %}
|
|
<li class="model-list__item">
|
|
<div style="min-width: 0">
|
|
<a href="/library/knowledge/{{ base.id }}"><strong>{{ base.name }}</strong></a>
|
|
<div class="text-xs faint">
|
|
{{ counts.get(base.id, 0) }} document{{ '' if counts.get(base.id, 0) == 1 else 's' }}
|
|
{%- if base.description %} · {{ base.description }}{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="btn-row">
|
|
{% if base.owner_id != user.id %}<span class="badge">shared with you</span>{% endif %}
|
|
</div>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
<div class="empty">
|
|
{{ icon("archive", "empty__mark") }}
|
|
<h2 class="empty__title">No knowledge bases yet</h2>
|
|
<p class="empty__text">
|
|
Make one below, then put documents in it. A chat with no base attached
|
|
searches everything you have; a chat pointed at one searches only that.
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<section class="card" style="margin-top: var(--sp-6)">
|
|
<h2 class="card__title">New knowledge base</h2>
|
|
<form method="post" action="/api/library/bases">
|
|
<div class="grid grid--2">
|
|
<div class="field">
|
|
<label class="field__label" for="base-name">Name</label>
|
|
<input class="input" id="base-name" name="name" required maxlength="200"
|
|
placeholder="Contracts">
|
|
</div>
|
|
<div class="field">
|
|
<label class="field__label" for="base-description">Description</label>
|
|
<input class="input" id="base-description" name="description" maxlength="2000"
|
|
placeholder="What belongs in here.">
|
|
</div>
|
|
</div>
|
|
<button class="btn btn--primary" type="submit">{{ icon("plus", "icon--sm") }} Create</button>
|
|
</form>
|
|
</section>
|
|
{% endblock %}
|