mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-11 21:09:00 +08:00
fix(queue-worker, scrape): match billing logic and add billing for stealth proxies (#1521)
This commit is contained in:
parent
0f32500149
commit
e06c7cc234
@ -155,6 +155,10 @@ export async function scrapeController(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.body.proxy === "stealth") {
|
||||||
|
creditsToBeBilled += 4;
|
||||||
|
}
|
||||||
|
|
||||||
billTeam(req.auth.team_id, req.acuc?.sub_id, creditsToBeBilled).catch(
|
billTeam(req.auth.team_id, req.acuc?.sub_id, creditsToBeBilled).catch(
|
||||||
(error) => {
|
(error) => {
|
||||||
logger.error(
|
logger.error(
|
||||||
|
@ -1331,12 +1331,21 @@ async function processJob(job: Job & { id: string }, token: string) {
|
|||||||
|
|
||||||
if (job.data.is_scrape !== true) {
|
if (job.data.is_scrape !== true) {
|
||||||
let creditsToBeBilled = 1; // Assuming 1 credit per document
|
let creditsToBeBilled = 1; // Assuming 1 credit per document
|
||||||
if (job.data.scrapeOptions.extract) {
|
if ((job.data.scrapeOptions.extract && job.data.scrapeOptions.formats?.includes("extract")) || (job.data.scrapeOptions.formats?.includes("changeTracking") && job.data.scrapeOptions.changeTrackingOptions?.modes?.includes("json"))) {
|
||||||
creditsToBeBilled = 5;
|
creditsToBeBilled = 5;
|
||||||
}
|
}
|
||||||
if (job.data.scrapeOptions.agent?.model?.toLowerCase() === "fire-1") {
|
|
||||||
|
if (job.data.scrapeOptions.agent?.model?.toLowerCase() === "fire-1" || job.data.scrapeOptions.extract?.agent?.model?.toLowerCase() === "fire-1" || job.data.scrapeOptions.jsonOptions?.agent?.model?.toLowerCase() === "fire-1") {
|
||||||
|
if (process.env.USE_DB_AUTHENTICATION === "true") {
|
||||||
|
creditsToBeBilled = Math.ceil((costTracking.toJSON().totalCost ?? 1) * 1800);
|
||||||
|
} else {
|
||||||
creditsToBeBilled = 150;
|
creditsToBeBilled = 150;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (job.data.scrapeOptions.proxy === "stealth") {
|
||||||
|
creditsToBeBilled += 4;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
job.data.team_id !== process.env.BACKGROUND_INDEX_TEAM_ID! &&
|
job.data.team_id !== process.env.BACKGROUND_INDEX_TEAM_ID! &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user