From f6c8fbec3bd98765996801ae001b454986c025c5 Mon Sep 17 00:00:00 2001 From: German Swan Date: Thu, 21 Mar 2024 12:23:08 +0200 Subject: [PATCH] remove unnecessary async/await --- core/indexing/docs/article.ts | 11 ++++++----- core/indexing/docs/index.ts | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/core/indexing/docs/article.ts b/core/indexing/docs/article.ts index 7301625dd..6e7c60e75 100644 --- a/core/indexing/docs/article.ts +++ b/core/indexing/docs/article.ts @@ -2,7 +2,8 @@ import { Readability } from "@mozilla/readability"; import { Chunk } from "../.."; import { MAX_CHUNK_SIZE } from "../../llm/constants"; import { cleanFragment, cleanHeader } from "../chunk/markdown"; -import { PageData } from "./crawl" +import { PageData } from "./crawl"; +import type jsdom from "jsdom"; export type ArticleComponent = { title: string; @@ -138,8 +139,8 @@ export function stringToArticle( return undefined; } - let article_components = await extractTitlesAndBodies(article.content); - + let article_components = extractTitlesAndBodies(article.content); + return { url, subpath, @@ -152,9 +153,9 @@ export function stringToArticle( } } -export async function pageToArticle( +export function pageToArticle( page: PageData -): Promise
{ +): Article | undefined { try { return stringToArticle(page.url, page.html, page.path); } catch (err) { diff --git a/core/indexing/docs/index.ts b/core/indexing/docs/index.ts index 89906f0f1..79d96371c 100644 --- a/core/indexing/docs/index.ts +++ b/core/indexing/docs/index.ts @@ -29,7 +29,7 @@ export async function* indexDocs( const articles: Article[] = []; for await (const page of crawlPage(baseUrl)) { - const article = await pageToArticle(page); + const article = pageToArticle(page); if (!article) continue; articles.push(article);