* 🎨 refactor out react context * 🎨 refactor local storage * 🎨 refactor IdeMessenger * 🔥 removing unused files * 🚚 move scripts * ✅ setup VSCode integration testing * 🎨 fix test-related stuff * 🚧 testing * 🎨 tweak terminal cmd+L * 🧑💻 install biome in core * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 run biome check in binary * 🧑💻 global biome config * 🎨 run biome check on core * 🎨 run biome check in vscode * 🎨 fix a few biome warnings * 🚧 WIP on protocols * 🚧 progress, organizing, about to remove webviewCore protocol * 🚧 now running * 🚧 move indexing code to core * 🚧 WIP on JetBrains indexing implementation * 🎨 finish listDir * 🚧 gui fixes * 🏷️ update IMessenger.on return type * 🐛 fix jetbrains types + IDE detection * 🧑💻 set up debugging for binary with TcpMessenger * 👷 fix prepackage.js * 🧑💻 turn off debug mode for intellij * 🐛 merge fixes * 🐛 fixes after refactor * 🐛 merge fixes * 💄 increase font size in JB * 🔀 merge changes * 🩹 small fixes * 🐛 fix jetbrains build * 🩹 more jetbrains fixes * 🎨 jetbrains improvements * 🐛 fix lancedb prob in jetbrains build * 👷 update jetbrains build process * ✨ intellij problems context provider * 👷 add script utils file * 💚 fix jetbrains build regression * 🎨 dynamic import transformers.js * 🩹 small jetbrains updates * ✨ folder context provider in jetbrains * 🎨 many more jetbrains improvements * 🔀 merge fixes * ⚡️ small improvements * 🎨 tell users transformers.js not supported * 🎨 trial updates * 📝 update jetbrains readmej * ⚡️ only use smaller context for local autocomplete models * ⚡️ improve bracket filter * ✨ global .continue/.prompts folder * 💄 improved model setup process * 🥅 display VSCode req errs
76 lines
1.5 KiB
TypeScript
76 lines
1.5 KiB
TypeScript
import {
|
|
Chunk,
|
|
EmbeddingsProvider,
|
|
IndexingProgressUpdate,
|
|
} from "../../index.js";
|
|
|
|
import { Article, chunkArticle, pageToArticle } from "./article.js";
|
|
import { crawlPage } from "./crawl.js";
|
|
import { addDocs, hasDoc } from "./db.js";
|
|
|
|
export async function* indexDocs(
|
|
title: string,
|
|
baseUrl: URL,
|
|
embeddingsProvider: EmbeddingsProvider,
|
|
): AsyncGenerator<IndexingProgressUpdate> {
|
|
if (await hasDoc(baseUrl.toString())) {
|
|
yield {
|
|
progress: 1,
|
|
desc: "Already indexed",
|
|
status: "done",
|
|
};
|
|
return;
|
|
}
|
|
|
|
yield {
|
|
progress: 0,
|
|
desc: "Finding subpages",
|
|
status: "indexing",
|
|
};
|
|
|
|
const articles: Article[] = [];
|
|
|
|
for await (const page of crawlPage(baseUrl)) {
|
|
const article = pageToArticle(page);
|
|
if (!article) {
|
|
continue;
|
|
}
|
|
|
|
articles.push(article);
|
|
|
|
yield {
|
|
progress: 0,
|
|
desc: `Finding subpages (${page.path})`,
|
|
status: "indexing",
|
|
};
|
|
}
|
|
|
|
const chunks: Chunk[] = [];
|
|
const embeddings: number[][] = [];
|
|
|
|
for (const article of articles) {
|
|
yield {
|
|
progress: Math.max(1, Math.floor(100 / (articles.length + 1))),
|
|
desc: `${article.subpath}`,
|
|
status: "indexing",
|
|
};
|
|
|
|
const subpathEmbeddings = await embeddingsProvider.embed(
|
|
chunkArticle(article).map((chunk) => {
|
|
chunks.push(chunk);
|
|
|
|
return chunk.content;
|
|
}),
|
|
);
|
|
|
|
embeddings.push(...subpathEmbeddings);
|
|
}
|
|
|
|
await addDocs(title, baseUrl, chunks, embeddings);
|
|
|
|
yield {
|
|
progress: 1,
|
|
desc: "Done",
|
|
status: "done",
|
|
};
|
|
}
|