mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 18:40:45 +08:00
Nick:
This commit is contained in:
parent
1805d901a9
commit
ee3e5dc69c
@ -312,12 +312,12 @@ export function legacyScrapeOptions(x: ScrapeOptions): PageOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function legacyExtractorOptions(x: ExtractOptions): ExtractorOptions {
|
export function legacyExtractorOptions(x?: ExtractOptions): ExtractorOptions {
|
||||||
return {
|
return {
|
||||||
mode: x.mode ? "llm-extraction" : "markdown",
|
mode: x?.mode ? "llm-extraction" : "markdown",
|
||||||
extractionPrompt: x.prompt ?? "Based on the information on the page, extract the information from the schema.",
|
extractionPrompt: x?.prompt ?? "Based on the information on the page, extract the information from the schema.",
|
||||||
extractionSchema: x.schema,
|
extractionSchema: x?.schema,
|
||||||
userPrompt: x.prompt ?? "",
|
userPrompt: x?.prompt ?? "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,27 +199,44 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(subscriptionError) {
|
|
||||||
Logger.error(`Subscription error: ${subscriptionError}`);
|
|
||||||
throw new Error(`Subscription error: ${subscriptionError}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Free credits, no coupons
|
// Free credits, no coupons
|
||||||
if (!subscription) {
|
if (!subscription || subscriptionError) {
|
||||||
|
|
||||||
// If there is no active subscription but there are available coupons
|
// If there is no active subscription but there are available coupons
|
||||||
if (couponCredits >= credits) {
|
if (couponCredits >= credits) {
|
||||||
return { success: true, message: "Sufficient credits available", remainingCredits: couponCredits };
|
return { success: true, message: "Sufficient credits available", remainingCredits: couponCredits };
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: creditUsages, error: creditUsageError } =
|
let creditUsages;
|
||||||
await supabase_service
|
let creditUsageError;
|
||||||
|
let retries = 0;
|
||||||
|
const maxRetries = 3;
|
||||||
|
const retryInterval = 2000; // 2 seconds
|
||||||
|
|
||||||
|
while (retries < maxRetries) {
|
||||||
|
const result = await supabase_service
|
||||||
.from("credit_usage")
|
.from("credit_usage")
|
||||||
.select("credits_used")
|
.select("credits_used")
|
||||||
.is("subscription_id", null)
|
.is("subscription_id", null)
|
||||||
.eq("team_id", team_id);
|
.eq("team_id", team_id);
|
||||||
|
|
||||||
|
creditUsages = result.data;
|
||||||
|
creditUsageError = result.error;
|
||||||
|
|
||||||
|
if (!creditUsageError) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
retries++;
|
||||||
|
if (retries < maxRetries) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, retryInterval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (creditUsageError) {
|
if (creditUsageError) {
|
||||||
Logger.error(`Credit usage error: ${creditUsageError}`);
|
Logger.error(`Credit usage error after ${maxRetries} attempts: ${creditUsageError}`);
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Failed to retrieve credit usage for team_id: ${team_id}`
|
`Failed to retrieve credit usage for team_id: ${team_id}`
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user