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]>
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import type { BUN_SQLITE_COBBLE_FILE_INGEST_QUEUE } from "@/db/types/db";
|
|
import ingestKnowledgebaseDocument from "@/src/functions/backend/db/knowledgebases/ingest-knowledgebase-document";
|
|
import { logError } from "@/src/functions/backend/logger";
|
|
import settleFailedIngestJob from "./settle-failed-ingest-job";
|
|
|
|
type Params = {
|
|
job: BUN_SQLITE_COBBLE_FILE_INGEST_QUEUE;
|
|
};
|
|
|
|
/**
|
|
* Ingests one queued knowledgebase document and completes (or fails) its
|
|
* job. One that was deleted meanwhile is simply done, and so is a job
|
|
* without a document (bot files are no longer indexed).
|
|
*/
|
|
export default async function processIngestJob({ job }: Params) {
|
|
if (!job.id) return;
|
|
|
|
if (!job.document_id) {
|
|
await BunSQLite.queue.complete({ table: "file_ingest_queue", id: job.id }).catch(() => {});
|
|
return;
|
|
}
|
|
|
|
try {
|
|
await ingestKnowledgebaseDocument({ document_id: job.document_id });
|
|
await BunSQLite.queue.complete({ table: "file_ingest_queue", id: job.id });
|
|
} catch (error) {
|
|
const { deferred } = await settleFailedIngestJob({ job_id: job.id, error });
|
|
|
|
if (deferred) return;
|
|
|
|
await logError({
|
|
title: `Knowledgebase document #${job.document_id} couldn't be ingested`,
|
|
error,
|
|
metadata: { document_id: job.document_id },
|
|
}).catch(() => {});
|
|
}
|
|
}
|