Skip to content

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

Nick: extract fixes

Nicolasd49f62fb5641
diff --git a/apps/api/src/__tests__/e2e_extract/index.test.ts b/apps/api/src/__tests__/e2e_extract/index.test.ts
index 31f14f4a8..346958dab 100644
--- a/apps/api/src/__tests__/e2e_extract/index.test.ts
+++ b/apps/api/src/__tests__/e2e_extract/index.test.ts
@@ -86,7 +86,8 @@ describe("E2E Tests for Extract API Routes", () => {
type: "array",
items: {
type: "string"
- }
+ },
+ required: ["items"]
},
});
expect(response.statusCode).toBe(200);
diff --git a/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts b/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
index 7c2a66968..41d767791 100644
--- a/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
+++ b/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
@@ -165,7 +165,9 @@ export async function generateOpenAICompletions(logger: Logger, options: Extract
}
}
- if (options.schema && options.schema.type === "array") {
+ // If the users actually wants the items object, they can specify it as 'required' in the schema
+ // otherwise, we just return the items array
+ if (options.schema && options.schema.type === "array" && !schema?.required?.includes("items")) {
extract = extract?.items;
}
return { extract, warning };