mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 06:28:59 +08:00
Merge branch 'main' of https://github.com/mendableai/firecrawl
This commit is contained in:
commit
1afc6258bd
@ -75,6 +75,8 @@ export class CostLimitExceededError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nanProof = (n: number | null | undefined) => isNaN(n ?? 0) ? 0 : (n ?? 0);
|
||||||
|
|
||||||
export class CostTracking {
|
export class CostTracking {
|
||||||
calls: {
|
calls: {
|
||||||
type: "smartScrape" | "other",
|
type: "smartScrape" | "other",
|
||||||
@ -109,10 +111,10 @@ export class CostTracking {
|
|||||||
calls: this.calls,
|
calls: this.calls,
|
||||||
|
|
||||||
smartScrapeCallCount: this.calls.filter(c => c.type === "smartScrape").length,
|
smartScrapeCallCount: this.calls.filter(c => c.type === "smartScrape").length,
|
||||||
smartScrapeCost: this.calls.filter(c => c.type === "smartScrape").reduce((acc, c) => acc + c.cost, 0),
|
smartScrapeCost: this.calls.filter(c => c.type === "smartScrape").reduce((acc, c) => acc + nanProof(c.cost), 0),
|
||||||
otherCallCount: this.calls.filter(c => c.type === "other").length,
|
otherCallCount: this.calls.filter(c => c.type === "other").length,
|
||||||
otherCost: this.calls.filter(c => c.type === "other").reduce((acc, c) => acc + c.cost, 0),
|
otherCost: this.calls.filter(c => c.type === "other").reduce((acc, c) => acc + nanProof(c.cost), 0),
|
||||||
totalCost: this.calls.reduce((acc, c) => acc + c.cost, 0),
|
totalCost: this.calls.reduce((acc, c) => acc + nanProof(c.cost), 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user