Add knowledgebases
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]>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
type Params = {
|
||||
/**
|
||||
* The document's whole text.
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* One of its passages, which may start with a heading carried over and
|
||||
* a stretch repeated from the passage before.
|
||||
*/
|
||||
passage: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Where a passage sits in its document, roughly: found by its last line
|
||||
* (the part least likely to be a carried heading or an overlap), counted
|
||||
* back by where that line sits in the passage. 0 when it can't be found.
|
||||
*/
|
||||
export default function locatePassage({ text, passage }: Params) {
|
||||
const lines = passage.split("\n").map((line) => line.trim()).filter(Boolean);
|
||||
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
const line = lines[i]!;
|
||||
const at = text.indexOf(line);
|
||||
|
||||
if (at < 0) continue;
|
||||
|
||||
return Math.max(0, at - passage.lastIndexOf(line));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user