Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Nick: disable auto rech for extract requests

Nicolase026917698ed
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index 8d16acf53..db5dd229f 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -94,8 +94,9 @@ export async function getACUC(
let retries = 0;
const maxRetries = 5;
+ let isExtract = (mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus)
let rpcName =
- mode === RateLimiterMode.Extract || mode === RateLimiterMode.ExtractStatus
+ isExtract
? "auth_credit_usage_chunk_extract"
: "auth_credit_usage_chunk_test_22_credit_pack_n_extract";
while (retries < maxRetries) {
@@ -132,7 +133,7 @@ export async function getACUC(
setCachedACUC(api_key, chunk);
}
- return chunk;
+ return chunk ? { ...chunk, is_extract: isExtract } : null;
} else {
return null;
}
diff --git a/apps/api/src/controllers/v1/types.ts b/apps/api/src/controllers/v1/types.ts
index 465810baf..c3ba3a69b 100644
--- a/apps/api/src/controllers/v1/types.ts
+++ b/apps/api/src/controllers/v1/types.ts
@@ -655,6 +655,7 @@ export type AuthCreditUsageChunk = {
remaining_credits: number;
sub_user_id: string | null;
total_credits_sum: number;
+ is_extract?: boolean;
};
export interface RequestWithMaybeACUC<
diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.ts
index 082a32d29..d3827f309 100644
--- a/apps/api/src/services/billing/credit_billing.ts
+++ b/apps/api/src/services/billing/credit_billing.ts
@@ -150,7 +150,8 @@ export async function supaCheckTeamCredits(
if (
isAutoRechargeEnabled &&
- chunk.remaining_credits < autoRechargeThreshold
+ chunk.remaining_credits < autoRechargeThreshold &&
+ !chunk.is_extract
) {
const autoChargeResult = await autoCharge(chunk, autoRechargeThreshold);
if (autoChargeResult.success) {