Skip to content

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

fix(llmExtract): arbitrary objects caused error to be thrown

Gergő Móriczf5e5bdb710ef
diff --git a/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts b/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
index e3c76362e..74b3ff9df 100644
--- a/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
+++ b/apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts
@@ -74,9 +74,9 @@ function normalizeSchema(x: any): any {
return {
...x,
properties: Object.fromEntries(
- Object.entries(x.properties).map(([k, v]) => [k, normalizeSchema(v)]),
+ Object.entries(x.properties || {}).map(([k, v]) => [k, normalizeSchema(v)]),
),
- required: Object.keys(x.properties),
+ required: Object.keys(x.properties || {}),
additionalProperties: false,
};
} else if (x && x.type === "array") {