Use discovered business info in multi-page extract flow
- Store businessInfo from discovery phase - Pre-populate from JSON-LD/meta before sub-page extraction - Only fill gaps from sub-page Claude responses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a181c1b90a
commit
bc1f8d4f4b
1 changed files with 10 additions and 5 deletions
|
|
@ -1428,6 +1428,9 @@
|
||||||
const menuPages = discoverResult.menuPages || [];
|
const menuPages = discoverResult.menuPages || [];
|
||||||
const siteName = discoverResult.siteName || '';
|
const siteName = discoverResult.siteName || '';
|
||||||
|
|
||||||
|
// Store business info from discovery (JSON-LD, meta tags, etc.)
|
||||||
|
config.discoveredBusinessInfo = discoverResult.businessInfo || {};
|
||||||
|
|
||||||
if (menuPages.length > 1) {
|
if (menuPages.length > 1) {
|
||||||
// Multiple menus found — show confirmation step
|
// Multiple menus found — show confirmation step
|
||||||
const pageListHtml = menuPages.map((p, i) => `
|
const pageListHtml = menuPages.map((p, i) => `
|
||||||
|
|
@ -1496,11 +1499,11 @@
|
||||||
|
|
||||||
document.getElementById('conversation').innerHTML = '';
|
document.getElementById('conversation').innerHTML = '';
|
||||||
|
|
||||||
// Combined results
|
// Combined results — start with business info from discovery phase
|
||||||
const allItems = [];
|
const allItems = [];
|
||||||
const allCategories = [];
|
const allCategories = [];
|
||||||
const allMenus = [];
|
const allMenus = [];
|
||||||
let businessInfo = {};
|
let businessInfo = { ...(config.discoveredBusinessInfo || {}) };
|
||||||
let totalProcessed = 0;
|
let totalProcessed = 0;
|
||||||
|
|
||||||
for (const page of pages) {
|
for (const page of pages) {
|
||||||
|
|
@ -1521,9 +1524,11 @@
|
||||||
|
|
||||||
if (result.OK && result.DATA) {
|
if (result.OK && result.DATA) {
|
||||||
const data = result.DATA;
|
const data = result.DATA;
|
||||||
// Merge business info (first non-empty wins)
|
// Merge business info — fill gaps from sub-page extractions
|
||||||
if (data.business && Object.keys(data.business).length > Object.keys(businessInfo).length) {
|
if (data.business) {
|
||||||
businessInfo = { ...businessInfo, ...data.business };
|
for (const [k, v] of Object.entries(data.business)) {
|
||||||
|
if (v && !businessInfo[k]) businessInfo[k] = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Add categories with menu tag
|
// Add categories with menu tag
|
||||||
(data.categories || []).forEach(cat => {
|
(data.categories || []).forEach(cat => {
|
||||||
|
|
|
||||||
Reference in a new issue