Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix(api): require entity keys in schema analysis output (#4541)
Gergő Móricz7cacd5a06eb9
diff --git a/apps/api/src/lib/extract/build-prompts.ts b/apps/api/src/lib/extract/build-prompts.tsindex fc1eeb11a..39a7f2ee3 100644--- a/apps/api/src/lib/extract/build-prompts.ts+++ b/apps/api/src/lib/extract/build-prompts.ts@@ -51,7 +51,7 @@ Examples:- "Is this company a non-profit?" -> Single-Answer- "Extract all product prices" -> Multi-Entity-For Single-Answer, arrays may be present but are typically small. For Multi-Entity, if arrays have multiple items not from a single page, return keys with large arrays. If nested, return the full key (e.g., 'ecommerce.products').`;+For Single-Answer, arrays may be present but are typically small; return an empty array for multiEntityKeys. For Multi-Entity, if arrays have multiple items not from a single page, return keys with large arrays in multiEntityKeys. If nested, return the full key (e.g., 'ecommerce.products').`;}export function buildAnalyzeSchemaUserPrompt(@@ -59,6 +59,6 @@ export function buildAnalyzeSchemaUserPrompt(prompt: string,urls: string[],): string {- return `Classify the query as Single-Answer or Multi-Entity. For Multi-Entity, return keys with large arrays; otherwise, return none:+ return `Classify the query as Single-Answer or Multi-Entity. For Multi-Entity, return keys with large arrays in multiEntityKeys; otherwise, return an empty array for multiEntityKeys:Schema: ${schemaString}\nPrompt: ${prompt}\n URLs: ${urls}`;}diff --git a/apps/api/src/lib/extract/fire-0/completions/analyzeSchemaAndPrompt-f0.ts b/apps/api/src/lib/extract/fire-0/completions/analyzeSchemaAndPrompt-f0.tsindex 6d21ffd3a..0aa544b2a 100644--- a/apps/api/src/lib/extract/fire-0/completions/analyzeSchemaAndPrompt-f0.ts+++ b/apps/api/src/lib/extract/fire-0/completions/analyzeSchemaAndPrompt-f0.ts@@ -34,7 +34,7 @@ export async function analyzeSchemaAndPrompt_F0(const checkSchema = z.object({isMultiEntity: z.boolean(),- multiEntityKeys: z.array(z.string()).optional().prefault([]),+ multiEntityKeys: z.array(z.string()),reasoning: z.string(),keyIndicators: z.array(z.string()),})