Files
cobble/src/functions/backend/db/media/media-columns.ts
T
tbenandClaude Opus 5.5 ac3ebc43d4 Keep searchable text only in knowledgebases
Every bot file was chunked into bot_file_chunks and embedded into
bot_file_vectors, and uploads kept their extracted text in
media.text_content, which together took most of the database. Bot
files are no longer indexed: bots find them by name or path with
list_files and read them with read_file, and search_files, ingest_file
and the files modal's re-read button are gone. Attachments keep no
text; a reply reads a document from the file. Only knowledgebase
documents keep text.

The schema drops both tables and the ingest columns. At boot,
dropStoredFileText removes what older versions stored (file jobs,
upload text) and vacuums once much of the database is free. The
media:prune-text script it replaces is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 04:44:46 +01:00

39 lines
1.1 KiB
TypeScript

/**
* The `media` columns a normal read takes, with a table alias.
*
* `text_content` is deliberately left out: it holds up to
* `AppData.BotAttachmentTextStoreMaxChars` of extracted document text, and
* every caller that only needs a file's name, type or path (`SELECT m.*`
* did) pulled it into memory, into page props and into API responses.
* Only knowledgebase documents keep it now; read it explicitly where it
* is really used.
*/
export default function mediaColumns({
alias = "m",
with_text_content,
}: { alias?: string; with_text_content?: boolean } = {}) {
const columns = [
"id",
"created_at",
"updated_at",
"user_id",
"title",
"description",
"summary",
"media_type",
"media_write_path",
"media_thumbnail_write_path",
"mime_type",
"is_primary",
"is_rag_ingested",
"archived",
];
/**
* Only a caller that really uses it asks for it.
*/
if (with_text_content) columns.push("text_content");
return columns.map((column) => `${alias}.${column}`).join(", ");
}