L Loach Docs
Ctrl K

Library

The Library keeps the texts, files and links you give your models in one place - saved once, used in any chat or Space. Sources are linked, not copied: edit an item in the Library and every chat and Space using it gets the new version with its next message.

Open it from Library in the sidebar, between Spaces and Snippets. The page has four tabs - Datasets, Texts, Files and Links, each with a count - and the button at the top right adds to whichever tab is open: New dataset, New text, Upload files or Add link. Everything is listed most recently updated first, and Loach remembers the tab you used last. The page has no search box of its own: search the Library from the search palette.

What it holds

Links are fetched with the same safety rules as web fetch: http and https only, no localhost or private-network addresses (an address without a dot can’t even be submitted), 30 seconds and 5 MB per page, and text pages only - a link to a PDF or another file has to be downloaded and uploaded under Files. A user name or password in the address is removed before the page is fetched, so it never reaches your Library or a backup.

A text body keeps up to 200,000 characters. Anything longer is cut, the item gets an amber Truncated badge, and the text ends with a note telling the model it’s incomplete. Split a long document into several items and group them in a dataset instead.

Datasets

A dataset is a named group of texts, files and links - “Thesis research”, say - so a whole set attaches to a chat or Space in one click. Create one with New dataset (a name of up to 80 characters and an optional description), or from a selection of items. Its card shows the mix (“3 texts · 2 files · 1 link”), the first few items, an estimated token count and a New chat button.

Each dataset opens on a page of its own, with a Library › name breadcrumb back to the list. There you can Add items from the Library, upload or drop files straight into it, and take an item out with the × on its row - it stays in your Library. The page’s … menu has Edit details, Upload files into it, New chat in Space, Add to Space and Delete dataset.

A dataset only groups items: they stay in the Library, and an item can sit in several datasets (a dataset can’t contain another dataset). Deleting a dataset keeps its items; deleting an item removes it from every dataset.

Managing items

Saving from elsewhere

Saving something whose content is already in the Library saves nothing and tells you the name it’s stored under.

Using sources in a chat

Attached sources show as chips above the message box: click one to preview it (or open a dataset’s page), or its × to remove it. They’re used on every message until you remove them. Sources picked on the welcome screen, or in the composer on a Space’s page, attach to the chat that message creates.

A chat in a Space also gets the Space’s sources - its uploads and the Library items linked to it - shown as one Space sources chip that opens the Space’s Sources tab, where they’re managed. Forking a chat keeps its sources. Private Chat has no Library sources.

In a Space

On a Space’s Sources tab, From Library links datasets and items to the Space, next to the files uploaded to it. Every chat in the Space can use them, and each source has a switch to keep it in the Space without using it. Library sources don’t count toward the Space’s 200 MB upload limit, and deleting the Space leaves them in your Library. You can also add an item or dataset to a Space from its … menu with Add to Space. See Spaces: reference sources.

How sources reach the model

Once a chat has sources, a Sources chip next to them sets how the chat uses them:

In a Space, the chip also offers Use the Space’s setting, which is where a chat in a Space starts. The Space’s own mode is set on its Settings tab. New Spaces start on Auto; Spaces created before Loach 1.6 - and Spaces restored from an older backup - start on Full text, which is how their sources always worked, until you switch them.

Full text goes into the system prompt and stays the same from turn to turn, so a local model’s prompt cache keeps it. When it has to leave something out, the chat’s own sources go in first, then the Space’s uploads, then the Space’s Library sources, and anything that didn’t fit is named in the reply’s sources chip. Images from your sources go with each message as images, for vision models - at most 16 per message, scaled as set under Images.

The window is the chat’s context length, and the context-usage bar shows what the sources will cost on the next message. An OpenAI-compatible server picks its own window and doesn’t say how big it is, so for those chats Loach assumes 32k tokens. If your model’s window differs, set the chat’s context length to it: it isn’t sent to the server, but it’s what sources are sized by.

Which sources a reply used

Every reply that drew on sources carries a chip above it - Read 3 sources in full, Used 6 excerpts from 3 sources or Searched 3 sources; nothing matched. Expand it to see which sources the model got (click a Library one to preview it) and, for excerpts, the passages themselves. Warnings show there too: sources cut short or left out to fit the window, images that didn’t go along, or an embedding model that couldn’t be reached, so the search used keywords only.

Every text source - Library items and a Space’s uploaded files alike - is split into passages of about 1,200 characters and indexed for keyword search as soon as it’s added. No setup, no network. Accents are folded, so gesla finds gęślą. Chinese, Japanese and Thai text isn’t split into words, though, so keyword search rarely matches it - use an embedding model for those languages.

Settings → Library adds an embedding model for search by meaning, which finds passages that answer a question even when they don’t share its words. It runs on Ollama, or on the OpenAI-compatible endpoint from Settings → Providers. Pick one of the suggestions or type a model name and click Use; Turn off goes back to keywords only. Suggested models:

Indexing runs in the background, and keyword search keeps working meanwhile. The button in the Library’s header shows where it stands: Keyword search only without a model, Indexing n / m while passages are embedded, Search by meaning once done, or Embedding paused when the model can’t be reached (hover it for the reason). Click it to open Settings → Library, which shows the same status with a progress bar, the reason when embedding is paused, and Retry. While the model is away, searches fall back to keywords and the reply’s sources chip says so; once a message couldn’t reach the model, messages in the next minute go straight to keywords instead of each waiting on it. Loach tries the model again every minute, and straight away when you change it.

Changing the model, or the address of the server it runs on, re-embeds every source. Rebuild re-embeds everything too - for example after you pull a new version of a model under the same name. A passage the model refuses on its own is set aside for keyword search rather than holding up the rest.

The keyword and meaning rankings are merged, so passages both searches like come first. When nothing matches at all, the model gets the opening part of each source instead.

Images

Library images are scaled down before they’re sent to a model, so a full-size photo doesn’t cost thousands of image tokens. Settings → Library → Images sets how, for chats and Spaces that don’t set their own: Default follows the app’s setting in Settings → Features (longest side up to 1,024 px unless you change it), Scale down sets a size in pixels or percent, and Original sends them as they are. A Space or a chat can still set its own. The image in your Library is never changed. See Image scaling.

Where your sources go

The Library lives in Loach’s local database and works offline - fetching a link and a remote embedding model are the only parts that need the network. With an Ollama embedding model, indexing and search stay on your machine (or the Ollama server you’ve set). With an OpenAI-compatible embedding model, the text of your sources - and of each message that searches them, even in a chat with a local model - is sent to that endpoint. The sources themselves reach a chat’s model like the rest of the prompt, so with a cloud provider they go to that provider.

Settings → Data → Export data includes your Library items, datasets and which chats and Spaces use them, but not the search index - Loach rebuilds it after a restore. Remove my data deletes the whole Library. See Data management.

Library item or Space upload?

Upload a file to a Space when only that Space needs it. Put it in the Library when you want it in several chats or Spaces, want to edit it in one place, or want to keep it after the Space is gone.