From 7d0ef683dcd1b15ed39e2ef7e3f2c859e79de2b7 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 19 Jun 2024 02:42:50 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- legacy/src/services/scraper-client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/legacy/src/services/scraper-client.ts b/legacy/src/services/scraper-client.ts index 2f7e6e53..3ccd074f 100644 --- a/legacy/src/services/scraper-client.ts +++ b/legacy/src/services/scraper-client.ts @@ -13,7 +13,7 @@ export namespace scraper { strict: true }) - export type ScrapeResult = { + export type ScrapeResult = Partial<{ author: string byline: string description: string @@ -36,7 +36,7 @@ export namespace scraper { /** The text for the main content of the page. */ textContent: string - } + }> } /** @@ -97,7 +97,7 @@ export class ScraperClient extends AIFunctionsProvider { format?: 'html' | 'markdown' | 'plaintext' | 'all' timeoutMs?: number } - ): Promise> { + ): Promise { const { timeoutMs = 60_000, format = 'markdown', @@ -111,7 +111,7 @@ export class ScraperClient extends AIFunctionsProvider { }) .json() - if (res.length <= 40) { + if (res.length && res.length <= 40) { try { const message = (JSON.parse(res.textContent as string) as any).message throw new Error(`Failed to scrape URL "${opts.url}": ${message}`)