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]>
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import type {
|
|
BUN_SQLITE_COBBLE_CUSTOM_TOOLS,
|
|
BUN_SQLITE_COBBLE_KNOWLEDGEBASES,
|
|
BUN_SQLITE_COBBLE_MCP_SERVERS,
|
|
BUN_SQLITE_COBBLE_SKILLS,
|
|
} from "@/db/types/db";
|
|
import botExtensionsSql from "@/src/utils/bot-extensions-sql";
|
|
import parseKnowledgebaseRow from "../knowledgebases/parse-knowledgebase-row";
|
|
import parseCustomToolRow from "./parse-custom-tool-row";
|
|
import parseMcpServerRow from "./parse-mcp-server-row";
|
|
import parseSkillRow from "./parse-skill-row";
|
|
|
|
type Params = {
|
|
bot_id: number | string;
|
|
workspace_id?: number | string | null;
|
|
};
|
|
|
|
/**
|
|
* The MCP servers, custom tools, skills and knowledgebases a bot gets on one run
|
|
* (`botExtensionsSql`): every bot's, its own, and its workspace's there.
|
|
*/
|
|
export default async function grabBotExtensions({ bot_id, workspace_id }: Params) {
|
|
const [servers, tools, skills, knowledgebases] = await Promise.all([
|
|
BunSQLite.sql<BUN_SQLITE_COBBLE_MCP_SERVERS>(botExtensionsSql({ kind: "mcp", bot_id, workspace_id })),
|
|
BunSQLite.sql<BUN_SQLITE_COBBLE_CUSTOM_TOOLS>(botExtensionsSql({ kind: "tool", bot_id, workspace_id })),
|
|
BunSQLite.sql<BUN_SQLITE_COBBLE_SKILLS>(botExtensionsSql({ kind: "skill", bot_id, workspace_id })),
|
|
BunSQLite.sql<BUN_SQLITE_COBBLE_KNOWLEDGEBASES>(
|
|
botExtensionsSql({ kind: "knowledgebase", bot_id, workspace_id }),
|
|
),
|
|
]);
|
|
|
|
return {
|
|
servers: (servers.payload || []).map((row) => parseMcpServerRow({ row })),
|
|
tools: (tools.payload || []).map((row) => parseCustomToolRow({ row })),
|
|
skills: (skills.payload || []).map((row) => parseSkillRow({ row })),
|
|
knowledgebases: (knowledgebases.payload || []).map((row) => parseKnowledgebaseRow({ row })),
|
|
};
|
|
}
|