fix: strict anti-hallucination prompts, ensure full reports, disable HTML export for stability

This commit is contained in:
Gemini AI
2025-12-29 15:44:54 +04:00
Unverified
parent e6488dd74c
commit 56d24bff5b
2 changed files with 144 additions and 3 deletions

View File

@@ -391,7 +391,140 @@ export default function GoogleAdsGenerator() {
};
const exportHTML = () => {
alert("Please use 'Export CSV' for the full detailed report. HTML export is currently being upgraded.");
if (!googleAdsResult && !magicWandResult) return;
alert("Please use 'Export CSV' for the full detailed report. HTML export is disabled."); return; /*
parts.push(`<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Google Ads Strategy Report</title>`);
parts.push(`<style>
:root { --bg: #0f172a; --card: #1e293b; --text: #e2e8f0; --accent: #6366f1; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; padding: 40px; }
.container { max-width: 1000px; margin: 0 auto; }
h1 { font-size: 2.5rem; background: linear-gradient(to right, #818cf8, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 0.5rem; }
.section { background: var(--card); border-radius: 12px; padding: 24px; margin-bottom: 24px; border: 1px solid rgba(255,255,255,0.1); }
h2 { font-size: 1.25rem; color: #818cf8; margin-bottom: 1rem; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.5rem; }
h3 { font-size: 1rem; color: #94a3b8; margin: 1rem 0 0.5rem; text-transform: uppercase; letter-spacing: 0.05em; }
.tag { display: inline-block; background: rgba(99,102,241,0.2); border: 1px solid rgba(99,102,241,0.3); color: #c3dafe; padding: 4px 12px; border-radius: 99px; font-size: 0.85rem; margin: 0 6px 6px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.card { background: rgba(0,0,0,0.2); padding: 16px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.05); }
.stat { font-size: 1.5rem; font-weight: 700; color: #4ade80; }
ul { padding-left: 20px; color: #cbd5e1; }
li { margin-bottom: 4px; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.footer { text-align: center; color: #64748b; margin-top: 4rem; font-size: 0.85rem; }
</style></head><body><div class="container">`);
parts.push(`<h1>Google Ads Strategy Report</h1><p style="color:#94a3b8; margin-bottom: 2rem">Generated by PromptArch on ${new Date().toLocaleDateString()}</p>`);
if (googleAdsResult) {
// Keywords
parts.push(`<div class="section"><h2>🎯 Keyword Research</h2>`);
if (googleAdsResult.keywords) {
if (Array.isArray(googleAdsResult.keywords.primary)) {
parts.push(`<h3>Primary Keywords</h3><div style="margin-bottom:1rem">`);
for (const k of googleAdsResult.keywords.primary) {
parts.push(`<span class="tag">${k.keyword} <span style="opacity:0.6; font-size:0.8em">(${k.cpc || 'N/A'})</span></span>`);
}
parts.push(`</div>`);
}
if (Array.isArray(googleAdsResult.keywords.longTail)) {
parts.push(`<h3>Long-tail Opportunities</h3><div style="margin-bottom:1rem">`);
for (const k of googleAdsResult.keywords.longTail) {
parts.push(`<span class="tag">${k.keyword} <span style="opacity:0.6; font-size:0.8em">(${k.cpc || 'N/A'})</span></span>`);
}
parts.push(`</div>`);
}
if (Array.isArray(googleAdsResult.keywords.negative)) {
parts.push(`<h3>Negative Keywords</h3><div style="margin-bottom:1rem">`);
for (const k of googleAdsResult.keywords.negative) {
parts.push(`<span class="tag">${k.keyword} <span style="opacity:0.6; font-size:0.8em">(${k.cpc || 'N/A'})</span></span>`);
}
parts.push(`</div>`);
}
}
parts.push(`</div>`);
// Ad Copies
if (Array.isArray(googleAdsResult.adCopies)) {
parts.push(`<div class="section"><h2>✍️ Ad Copy Variations</h2><div class="grid">`);
let i = 0;
for (const ad of googleAdsResult.adCopies) {
i++;
parts.push(`<div class="card"><div style="color:#818cf8; font-size:0.8rem; margin-bottom:0.5rem">Variation ${i}</div>`);
if (Array.isArray(ad.headlines)) {
for (const h of ad.headlines) {
parts.push(`<div style="font-weight:600; color:#f1f5f9">${h}</div>`);
}
}
if (Array.isArray(ad.descriptions)) {
parts.push(`<div style="margin: 12px 0; color:#cbd5e1; font-size:0.9rem">${(ad.descriptions || []).join('<br>')}</div>`);
}
if (ad.callToAction) {
parts.push(`<div style="display:inline-block; background:#4f46e5; color:white; font-size:0.8rem; padding:4px 12px; border-radius:4px">${ad.callToAction}</div>`);
}
parts.push(`</div>`);
}
parts.push(`</div></div>`);
}
// Campaigns
if (Array.isArray(googleAdsResult.campaigns)) {
parts.push(`<div class="section"><h2>🏗️ Campaign Structure</h2><div class="grid">`);
for (const c of googleAdsResult.campaigns) {
parts.push(`<div class="card"><h3 style="color:#f8fafc; margin-top:0">${c.name}</h3>`);
parts.push(`<p style="font-size:0.9rem; color:#94a3b8">${c.type.toUpperCase()} • ${c.budget?.daily} ${c.budget?.currency}/day</p>`);
const locs = c.targeting?.locations ? c.targeting.locations.join(', ') : 'Global';
parts.push(`<div style="margin-top:1rem; font-size:0.9rem"><strong>Locations:</strong> ${locs}<br><strong>Ad Groups:</strong> ${c.adGroups ? c.adGroups.length : 0}</div></div>`);
}
parts.push(`</div></div>`);
}
// Implementation & Predictions
parts.push(`<div class="section"><h2>🚀 Implementation & Forecast</h2><div class="grid">`);
if (googleAdsResult.implementation && Array.isArray(googleAdsResult.implementation.setupSteps)) {
parts.push(`<div><h3>Setup Steps</h3><ul>`);
for (const s of googleAdsResult.implementation.setupSteps) {
parts.push(`<li>${s}</li>`);
}
parts.push(`</ul></div>`);
}
if (googleAdsResult.predictions) {
const p = googleAdsResult.predictions;
parts.push(`<div class="card" style="background:rgba(16,185,129,0.1)"><h3 style="color:#34d399; margin-top:0">Monthly Estimations</h3><div style="display:grid; grid-template-columns:1fr 1fr; gap:12px">`);
parts.push(`<div><div class="stat">${p.estimatedClicks || '-'}</div><div style="font-size:0.8rem; opacity:0.7">Clicks</div></div>`);
parts.push(`<div><div class="stat">${p.estimatedCtr || '-'}</div><div style="font-size:0.8rem; opacity:0.7">CTR</div></div>`);
parts.push(`<div><div class="stat">${p.estimatedConversions || '-'}</div><div style="font-size:0.8rem; opacity:0.7">Convs</div></div>`);
parts.push(`</div></div>`);
}
parts.push(`</div></div>`);
}
if (magicWandResult) {
parts.push(`<div class="section"><h2>🧠 Market Intelligence</h2><div class="grid">`);
parts.push(`<div class="card"><h3>Strategy Rationale</h3><p style="font-size:0.9rem; color:#cbd5e1">${magicWandResult.rationale}</p></div>`);
const ma = magicWandResult.marketAnalysis;
parts.push(`<div><h3>Market Data</h3><p><strong>Growth Rate:</strong> ${ma?.growthRate || 'N/A'}</p><h3>Top Competitors</h3><ul>`);
if (ma && Array.isArray(ma.topCompetitors)) {
for (const c of ma.topCompetitors) {
parts.push(`<li>${c}</li>`);
}
} else {
parts.push(`<li>None identified</li>`);
}
parts.push(`</ul></div></div></div>`);
}
parts.push(`<div class="footer">PromptArch • AI-Powered Marketing Tools</div></div></body></html>`);
const blob = new Blob([parts.join('')], { type: 'text/html' });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", `google-ads-report-${new Date().toISOString().split('T')[0]}.html`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
*/
};
const sections = [

View File

@@ -790,6 +790,11 @@ Generate SPECTACULAR slides with CSS3 animations, SVG charts, modern gradients,
const systemMessage: ChatMessage = {
role: "system",
content: `You are an EXPERT Google Ads strategist. Create HIGH-CONVERTING campaigns with comprehensive keyword research, compelling ad copy, and optimized campaign structures.
CRITICAL ACCURACY PROTOCOL:
1. STRICT ADHERENCE TO FACTS: Use ONLY locations, contact info, and services explicitly mentioned in the provided Website URL or Products list.
2. DO NOT HALLUCINATE LOCATIONS: If no specific location is provided, default to "National" or "Global" based on the URL TLD (e.g. .co.uk -> UK). DO NOT invent cities or streets.
3. COMPREHENSIVE OUTPUT: You MUST generate full lists (15+ keywords, 3+ ad variations). Do not truncate.
OUTPUT FORMAT - Return ONLY valid JSON with this structure:
\`\`\`json
@@ -834,7 +839,9 @@ Requirements:
- 10-15 primary keywords, 15-20 long-tail, 5-10 negative
- Headlines max 30 chars, descriptions max 90 chars
- 3-5 ad variations per campaign
- Include budget and targeting recommendations`,
- 3-5 ad variations per campaign
- Include budget and targeting recommendations
- ENSURE ALL LISTS ARE POPULATED. No empty arrays.`,
};
const userMessage: ChatMessage = {
@@ -851,7 +858,8 @@ ${campaignDuration ? `DURATION: ${campaignDuration}` : ""}
${competitors.length > 0 ? `COMPETITORS: ${competitors.join(", ")}` : ""}
${specialInstructions ? `SPECIAL INSTRUCTIONS: ${specialInstructions}` : ""}
Generate complete Google Ads package with keywords, ad copy, campaigns, and implementation guidance.`,
Generate complete Google Ads package with keywords, ad copy, campaigns, and implementation guidance.
STRICTLY FOLLOW LOCALIZATION: Use only locations relevant to the provided website. Do not invent office locations.`,
};
return this.chatCompletion([systemMessage, userMessage], model || "coder-model");