Knowledgebases give bots RAG over documents, scoped like extensions: to particular bots, to a workspace, or to every bot, with their own button beside Tools in the composer. Documents are chunked and embedded by the file-ingest worker with the install's embedding model, which is now an install-wide setting rather than a per-bot one. - Word search runs on an FTS5 index ranked by BM25, with a scored LIKE fallback for scripts written without spaces. - Changing the embedding model re-indexes documents automatically. - Ingest jobs wait without spending attempts while every embedding model rests, fail at once on errors retrying can't fix, and keep passages searchable by words when the model refuses. - Settings > Knowledgebases shows each knowledgebase's and document's index state: spinner, warning, grey check (words only) or green check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
28 lines
954 B
TypeScript
28 lines
954 B
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import { AppData } from "@/src/data/app-data";
|
|
|
|
type Params = {
|
|
job_id: number | string;
|
|
/**
|
|
* Unix ms before which the job can't be claimed again.
|
|
*/
|
|
until: number;
|
|
};
|
|
|
|
/**
|
|
* Puts a claimed ingest job back to wait, giving back the attempt it
|
|
* used: every embedding model was resting, so nothing was tried. Capped
|
|
* at `AppData.HarnessMaxCooldownMs` from now.
|
|
*/
|
|
export default async function deferIngestJob({ job_id, until }: Params) {
|
|
const now = Date.now();
|
|
const at = Math.min(Math.max(until, now + AppData.HarnessCooldownMs), now + AppData.HarnessMaxCooldownMs);
|
|
|
|
await BunSQLite.sql({
|
|
sql: `UPDATE file_ingest_queue SET status = 'pending', locked_at = NULL, locked_by = NULL,
|
|
attempts = MAX(attempts - 1, 0), available_at = ?, updated_at = ?
|
|
WHERE id = ? AND status = 'processing'`,
|
|
values: [at, now, job_id],
|
|
});
|
|
}
|