fix: add Authorization header to all Edge Function calls + fix Vision Analysis
- All fetch calls to Supabase Edge Functions now include Authorization: Bearer <anon_key> (was missing → 401 errors) - Fix Firecrawl screenshot API: remove invalid screenshotOptions, use "screenshot@fullPage" format (v2 API compatibility) - Fix screenshot response handling: v2 returns URL not base64, now downloads and converts to base64 for Gemini Vision - Add about page to Vision Analysis capture targets - Add retry utility, channel error tracking, pipeline resume, enrichment retry, EmptyState improvements (Sprint 2-3) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f2aa5a5b6
commit
79950925a1
12 files changed
+961
-214
No files matched your search
@@ -131,6 +131,35 @@ ${JSON.stringify(scrapeData.branding || {}, null, 2).slice(0, 1000)}
|
||||
let report;
|
||||
try { report = JSON.parse(reportText); } catch { report = { raw: reportText, parseError: true }; }
|
||||
|
||||
// ─── Post-processing: Inject Vision Analysis data directly ───
|
||||
// Perplexity may ignore Vision data in prompt, so we force-inject critical fields
|
||||
const vision = channelData.visionAnalysis as Record<string, unknown> | undefined;
|
||||
if (vision) {
|
||||
// Force-inject foundingYear if Vision found it but Perplexity didn't
|
||||
if (vision.foundingYear && (!report.clinicInfo?.established || report.clinicInfo.established === "데이터 없음")) {
|
||||
report.clinicInfo = report.clinicInfo || {};
|
||||
report.clinicInfo.established = String(vision.foundingYear);
|
||||
console.log(`[report] Injected foundingYear from Vision: ${vision.foundingYear}`);
|
||||
}
|
||||
if (vision.operationYears && (!report.clinicInfo?.established || report.clinicInfo.established === "데이터 없음")) {
|
||||
const year = new Date().getFullYear() - Number(vision.operationYears);
|
||||
report.clinicInfo = report.clinicInfo || {};
|
||||
report.clinicInfo.established = String(year);
|
||||
console.log(`[report] Calculated foundingYear from operationYears: ${vision.operationYears} → ${year}`);
|
||||
}
|
||||
|
||||
// Force-inject doctors from Vision if report has none
|
||||
const visionDoctors = vision.doctors as { name: string; specialty: string; position?: string }[] | undefined;
|
||||
if (visionDoctors?.length && (!report.clinicInfo?.doctors?.length)) {
|
||||
report.clinicInfo = report.clinicInfo || {};
|
||||
report.clinicInfo.doctors = visionDoctors;
|
||||
console.log(`[report] Injected ${visionDoctors.length} doctors from Vision`);
|
||||
}
|
||||
|
||||
// Store Vision analysis separately for frontend
|
||||
report.visionAnalysis = vision;
|
||||
}
|
||||
|
||||
// Embed channel enrichment data for frontend mergeEnrichment()
|
||||
report.channelEnrichment = channelData;
|
||||
report.enrichedAt = new Date().toISOString();
|
||||
|
||||
Reference in new issue
Block a user