docs crawler logging
This commit is contained in:
parent
b5705c1d5f
commit
8a71cc6032
3 changed files with 13 additions and 7 deletions
|
|
@ -88,6 +88,7 @@ class DocsContextProvider extends BaseContextProvider {
|
|||
}
|
||||
await docsService.isInitialized;
|
||||
|
||||
console.log("DOCS REQUEST", extras.fullInput, query);
|
||||
// Get chunks
|
||||
let chunks = await docsService.retrieveChunksFromQuery(
|
||||
extras.fullInput, // confusing: fullInput = the query, query = startUrl in this case
|
||||
|
|
|
|||
|
|
@ -39,11 +39,13 @@ class DocsCrawler {
|
|||
maxRequestsPerCrawl: number = this.MAX_REQUESTS_PER_CRAWL,
|
||||
): AsyncGenerator<PageData, undefined, undefined> {
|
||||
if (startUrl.host === this.GITHUB_HOST) {
|
||||
console.log("GITHUB DETECTED: Using Github");
|
||||
yield* new GitHubCrawler(startUrl).crawl();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(`Crawling ${startUrl.toString()}: Trying default crawler`);
|
||||
const pageData = await new DefaultCrawler(startUrl).crawl();
|
||||
if (pageData.length > 0) {
|
||||
yield* pageData;
|
||||
|
|
@ -54,9 +56,11 @@ class DocsCrawler {
|
|||
}
|
||||
|
||||
if (this.shouldUseChromium()) {
|
||||
console.log(`Crawling ${startUrl.toString()}: Trying chromium crawler`);
|
||||
yield* new ChromiumCrawler(startUrl, maxRequestsPerCrawl).crawl();
|
||||
} else {
|
||||
let didCrawlSinglePage = false;
|
||||
console.log(`Crawling ${startUrl.toString()}: Trying cheerio crawler`);
|
||||
|
||||
for await (const pageData of new CheerioCrawler(
|
||||
startUrl,
|
||||
|
|
@ -73,6 +77,10 @@ class DocsCrawler {
|
|||
this.chromiumInstaller.shouldProposeUseChromiumOnCrawlFailure();
|
||||
|
||||
if (shouldProposeUseChromium) {
|
||||
console.log(
|
||||
`Crawling ${startUrl.toString()}: Cheerio failed: proposing chromium crawler`,
|
||||
);
|
||||
|
||||
const didInstall =
|
||||
await this.chromiumInstaller.proposeAndAttemptInstall(
|
||||
startUrl.toString(),
|
||||
|
|
@ -92,9 +100,4 @@ class DocsCrawler {
|
|||
}
|
||||
|
||||
export default DocsCrawler;
|
||||
export {
|
||||
CheerioCrawler,
|
||||
ChromiumCrawler,
|
||||
ChromiumInstaller,
|
||||
GitHubCrawler,
|
||||
};
|
||||
export { CheerioCrawler, ChromiumCrawler, ChromiumInstaller, GitHubCrawler };
|
||||
|
|
|
|||
|
|
@ -128,7 +128,9 @@ async function resolveEditorContent({
|
|||
selectedCode,
|
||||
selectedModelTitle,
|
||||
});
|
||||
console.log(item, stripImages(parts));
|
||||
if (result.status === "success") {
|
||||
console.log("SUCCESS", result);
|
||||
const resolvedItems = result.content;
|
||||
contextItems.push(...resolvedItems);
|
||||
for (const resolvedItem of resolvedItems) {
|
||||
|
|
@ -238,7 +240,7 @@ function resolveParagraph(
|
|||
export function hasSlashCommandOrContextProvider(
|
||||
editorState: JSONContent,
|
||||
): boolean {
|
||||
if (!editorState.content) {
|
||||
if (!editorState?.content) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue