mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-08 17:19:04 +08:00
Nick:
This commit is contained in:
parent
260a726f37
commit
9cd48d7f73
@ -704,6 +704,7 @@ export async function performExtraction(
|
||||
scrapeOptions: request,
|
||||
origin: request.origin ?? "api",
|
||||
num_tokens: totalTokensUsed,
|
||||
tokens_billed: tokensToBill,
|
||||
}).then(() => {
|
||||
updateExtract(extractId, {
|
||||
status: "completed",
|
||||
|
@ -12,7 +12,7 @@ const tokenPerCharacter = 4;
|
||||
const baseTokenCost = 200;
|
||||
|
||||
export function calculateFinalResultCost(data: any): number {
|
||||
return JSON.stringify(data).length / tokenPerCharacter + baseTokenCost;
|
||||
return Math.floor((JSON.stringify(data).length / tokenPerCharacter) + baseTokenCost);
|
||||
}
|
||||
|
||||
export function estimateTotalCost(tokenUsage: TokenUsage[]): number {
|
||||
|
@ -59,6 +59,7 @@ export async function logJob(job: FirecrawlJob, force: boolean = false) {
|
||||
num_tokens: job.num_tokens,
|
||||
retry: !!job.retry,
|
||||
crawl_id: job.crawl_id,
|
||||
tokens_billed: job.tokens_billed,
|
||||
};
|
||||
|
||||
if (force) {
|
||||
@ -128,6 +129,7 @@ export async function logJob(job: FirecrawlJob, force: boolean = false) {
|
||||
origin: job.origin,
|
||||
num_tokens: job.num_tokens,
|
||||
retry: job.retry,
|
||||
tokens_billed: job.tokens_billed,
|
||||
},
|
||||
};
|
||||
if (job.mode !== "single_urls") {
|
||||
|
@ -87,6 +87,7 @@ export interface FirecrawlJob {
|
||||
num_tokens?: number;
|
||||
retry?: boolean;
|
||||
crawl_id?: string;
|
||||
tokens_billed?: number;
|
||||
}
|
||||
|
||||
export interface FirecrawlScrapeResponse {
|
||||
|
Loading…
x
Reference in New Issue
Block a user