From 8a71cc603288f7badb4b82521c19fc22b2d30165 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 9 Jan 2025 11:41:52 +0000 Subject: [PATCH] docs crawler logging --- core/context/providers/DocsContextProvider.ts | 1 + core/indexing/docs/DocsCrawler.ts | 15 +++++++++------ gui/src/components/mainInput/resolveInput.ts | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/core/context/providers/DocsContextProvider.ts b/core/context/providers/DocsContextProvider.ts index 9ee50c256..0d296c71d 100644 --- a/core/context/providers/DocsContextProvider.ts +++ b/core/context/providers/DocsContextProvider.ts @@ -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 diff --git a/core/indexing/docs/DocsCrawler.ts b/core/indexing/docs/DocsCrawler.ts index 8854d8e87..d8a13e80f 100644 --- a/core/indexing/docs/DocsCrawler.ts +++ b/core/indexing/docs/DocsCrawler.ts @@ -39,11 +39,13 @@ class DocsCrawler { maxRequestsPerCrawl: number = this.MAX_REQUESTS_PER_CRAWL, ): AsyncGenerator { 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 }; diff --git a/gui/src/components/mainInput/resolveInput.ts b/gui/src/components/mainInput/resolveInput.ts index 535a3074f..1707dfe21 100644 --- a/gui/src/components/mainInput/resolveInput.ts +++ b/gui/src/components/mainInput/resolveInput.ts @@ -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; }