mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(firecrawl) fix firecrawl scrape credit usage calculation (#3583)
* fix(firecrawl) fix firecrawl scrape credit usage calculation * Update apps/sim/tools/firecrawl/scrape.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * Fix syntax --------- Co-authored-by: Theodore Li <theo@sim.ai> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
greptile-apps[bot]
Theodore Li
parent
e13f52fea2
commit
f347e3fca0
@@ -38,11 +38,11 @@ export const scrapeTool: ToolConfig<ScrapeParams, ScrapeResponse> = {
|
||||
pricing: {
|
||||
type: 'custom',
|
||||
getCost: (_params, output) => {
|
||||
if (output.creditsUsed == null) {
|
||||
const creditsUsed = (output.metadata as { creditsUsed?: number })?.creditsUsed
|
||||
if (creditsUsed == null) {
|
||||
throw new Error('Firecrawl response missing creditsUsed field')
|
||||
}
|
||||
|
||||
const creditsUsed = Number(output.creditsUsed)
|
||||
if (Number.isNaN(creditsUsed)) {
|
||||
throw new Error('Firecrawl response returned a non-numeric creditsUsed field')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user