fix: potential chargeAmount mismatch

This commit is contained in:
yanlong.wang 2024-05-16 18:43:41 +08:00
parent 8b0916f858
commit e0e37ad4d7
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -30,12 +30,14 @@ export interface ExtraScrappingOptions extends ScrappingOptions {
export interface FormattedPage { export interface FormattedPage {
title?: string; title?: string;
description?: string;
url?: string; url?: string;
content?: string; content?: string;
publishedTime?: string; publishedTime?: string;
html?: string; html?: string;
text?: string; text?: string;
screenshotUrl?: string; screenshotUrl?: string;
screenshot?: Buffer;
toString: () => string; toString: () => string;
} }
@ -727,13 +729,13 @@ ${this.content}
return undefined; return undefined;
} }
const textContent = formatted?.content || formatted?.text || formatted?.html; const textContent = formatted?.content || formatted?.description || formatted?.text || formatted?.html;
if (typeof textContent === 'string') { if (typeof textContent === 'string') {
return estimateToken(textContent); return estimateToken(textContent);
} }
const imageContent = formatted.screenshotUrl || (formatted as any)?.screenshot; const imageContent = formatted.screenshotUrl || formatted.screenshot;
if (imageContent) { if (imageContent) {
// OpenAI image token count for 1024x1024 image // OpenAI image token count for 1024x1024 image