Skip to content

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

Debug logs to Extract Updates (#2539)

Abimael Martell7cda4944e5b7
diff --git a/apps/api/src/lib/extract/extraction-service.ts b/apps/api/src/lib/extract/extraction-service.ts
index c9b730146..71a1894f6 100644
--- a/apps/api/src/lib/extract/extraction-service.ts
+++ b/apps/api/src/lib/extract/extraction-service.ts
@@ -1005,6 +1005,13 @@ export async function performExtraction(
);
// Log job with token usage and sources
+ logger.debug("Logging extract to database", {
+ extractId,
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ });
logExtract({
id: extractId,
request_id: extractId,
@@ -1016,20 +1023,35 @@ export async function performExtraction(
result: finalResult ?? {},
model_kind: "fire-1",
cost_tracking: costTracking.toJSON(),
- }).then(() => {
- updateExtract(extractId, {
- status: "completed",
- llmUsage,
- sources,
- tokensBilled: tokensToBill,
- creditsBilled: creditsToBill,
- // costTracking,
- }).catch(error => {
+ })
+ .then(() => {
+ logger.debug("Updating extract status to completed", {
+ extractId,
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ });
+ updateExtract(extractId, {
+ status: "completed",
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ // costTracking,
+ }).catch(error => {
+ logger.error("Failed to update extract status to completed", {
+ extractId,
+ error,
+ });
+ });
+ })
+ .catch(error => {
logger.error(
- `Failed to update extract ${extractId} status to completed: ${error}`,
+ "Failed to log extract to database",
+ { extractId, error },
);
});
- });
logger.debug("Done!");
diff --git a/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts b/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts
index 1b70bc4ab..9f4ec51ef 100644
--- a/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts
+++ b/apps/api/src/lib/extract/fire-0/extraction-service-f0.ts
@@ -875,6 +875,14 @@ export async function performExtraction_F0(
);
});
+ logger.debug("Logging extract to database", {
+ extractId,
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ });
+
// Log job with token usage and sources
logExtract({
id: extractId,
@@ -904,19 +912,32 @@ export async function performExtraction_F0(
otherCost: llmUsage,
totalCost: llmUsage,
},
- }).then(() => {
- updateExtract(extractId, {
- status: "completed",
- llmUsage,
- sources,
- tokensBilled: tokensToBill,
- creditsBilled: creditsToBill,
- }).catch(error => {
- logger.error(
- `Failed to update extract ${extractId} status to completed: ${error}`,
- );
+ })
+ .then(() => {
+ logger.debug("Updating extract status to completed", {
+ extractId,
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ });
+
+ updateExtract(extractId, {
+ status: "completed",
+ llmUsage,
+ sources,
+ tokensBilled: tokensToBill,
+ creditsBilled: creditsToBill,
+ }).catch(error => {
+ logger.error("Failed to update extract status to completed", {
+ extractId,
+ error,
+ });
+ });
+ })
+ .catch(error => {
+ logger.error("Failed to log extract to database", { extractId, error });
});
- });
logger.debug("Done!");