mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-12 09:12:40 +02:00
Fix AI extraction JSON-LD parsing and add debug logging
- Extract JSON-LD scripts BEFORE removing script tags - Add logging for prepared HTML, AI responses, and parsed data - Include more detailed error messages in test endpoint Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d98138fe7c
commit
906212e6ae
2 changed files with 28 additions and 13 deletions
|
|
@ -199,16 +199,21 @@ router.post('/ai/test', async (req: AuthRequest, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
console.log(`[AI Test] Testing URL: ${url} with provider: ${settings.ai_provider}`);
|
||||
|
||||
const { extractWithAI } = await import('../services/ai-extractor');
|
||||
const result = await extractWithAI(url, settings);
|
||||
|
||||
console.log(`[AI Test] Result:`, JSON.stringify(result, null, 2));
|
||||
|
||||
res.json({
|
||||
success: !!result.price,
|
||||
...result,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error testing AI extraction:', error);
|
||||
res.status(500).json({ error: 'Failed to test AI extraction' });
|
||||
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||
res.status(500).json({ error: `Failed to test AI extraction: ${errorMessage}` });
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue