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