Add AI fallback for multi-recipe detection#74
Merged
Conversation
Root cause: most multi-recipe listicle pages don't embed separate JSON-LD Recipe blocks per recipe. They typically have 0-1 JSON-LD blocks (article-level or for a featured recipe), with the rest as plain HTML. The detection relied entirely on JSON-LD, so it always fell through to single-recipe extraction. Fix: when JSON-LD finds <=1 recipes, use Claude (via CookingQA) to scan the page HTML and list all distinct recipe titles. If multiple found, create cards and start background extraction for each. - detectMultipleRecipesFromHTML(): AI-based detection with truncated HTML (80KB), returns card list or nil - ResolveFromHTML() now tries JSON-LD first, then AI fallback - PreviewFromURLWithMultiCheck simplified: delegates all detection (JSON-LD + AI) to ResolveFromHTML instead of checking JSON-LD separately Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e307e7233b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Prevents untrusted page HTML from producing unbounded card lists via prompt injection or malformed CookingQA responses. Also drops lines longer than 200 chars (not recipe titles). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes multi-recipe pages always showing a single recipe.
Root cause: Detection relied entirely on JSON-LD
Recipeblocks, but most listicle pages ("Top 10 Pasta Recipes") don't embed separate JSON-LD per recipe — they use plain HTML cards. So detection always returned <=1 recipes and fell through to single-recipe extraction.Fix: When JSON-LD finds <=1 recipes, use Claude (via
CookingQA) to scan the page and list all distinct recipe titles. If multiple found, create cards and start background extraction.detectMultipleRecipesFromHTML(): AI-based detection with truncated HTML (80KB)ResolveFromHTML(): tries JSON-LD first, then AI fallbackPreviewFromURLWithMultiCheck: delegates all detection toResolveFromHTMLTest plan
go build && go vet && go test ./internal/...passis_multi: truewith individual cards🤖 Generated with Claude Code