Files
html/api/ambre-tool-site.php
Opus d7871f7f73 feat(wevia-godmode-v3): 17 generators auto-intent router + 7 new premium APIs
NEW GENERATORS (V3 GODMODE):
- ambre-tool-3d.php: Three.js r128 scenes interactives (OrbitControls + anim loop + fog)
- ambre-tool-dataviz.php: Dashboards Plotly.js (3-4 charts + KPI cards + responsive grid)
- ambre-tool-site.php: Landing pages SaaS COMPLETES 10 sections (header/hero/features/pricing/FAQ/footer)
- ambre-tool-sql.php: NL -> SQL multi-dialect (PG/MySQL/SQLite) avec explanation + indexes suggested
- ambre-tool-brainstorm.php: Multi-IA PARALLELE 5 providers (cerebras+groq+sambanova+gemini+cloudflare) + synthese
- ambre-tool-image-gen.php: Text2Image avec cascade sovereign + fallback ambre-image
- ambre-tool-translate-code.php: Code translator multi-langages (Python/JS/TS/Go/Rust/Java/Ruby)

ROUTER V3:
- 17 generators catalogues (4 docs + 7 GODMODE + 6 utilities)
- detectIntent() NL regex français/anglais
- extractPayload() nettoyage intelligent
- Rendering adapte par kind: docx/xlsx/pptx/react (preview panel), 3d (three.js iframe), image (inline img), code (pre+copy btn), json (summary card OR brainstorm providers_used), inline (calc), audio (player)

SAFETY PUBLIC:
- Zero secret WEVAL divulgue dans prompts
- Zero acces vault/credentials/serveurs internes
- Sovereign cascade uniquement (0€ LLM cost)
- Tous prompts contraints 'info generique safe'

TESTED LIVE:
- SQL generator PostgreSQL validated (json_agg + INNER JOIN + GROUP BY)
- DOCX 7 sections + XLSX 3 sheets + PPTX 10 slides + REACT standalone (all previously tested 1d24e243c commit)

17 intents auto-detectes dans wevia.html public widget.
WEVIA public maintenant aussi capable qu'un copilot grand public tout en restant safe sur secrets WEVAL.
2026-04-24 21:44:55 +02:00

80 lines
3.4 KiB
PHP

<?php
/**
* ambre-tool-site.php — Full SaaS landing page generator
*/
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { echo json_encode(['ok'=>false,'error'=>'POST only']); exit; }
$input = json_decode(file_get_contents('php://input'), true);
$topic = trim($input['topic'] ?? '');
if (strlen($topic) < 3) { echo json_encode(['ok'=>false,'error'=>'topic too short']); exit; }
$topic = substr($topic, 0, 400);
$prompt = "Expert frontend designer SaaS. Genere une landing page COMPLETE premium pour: \"$topic\"\n\n"
. "Sections obligatoires (dans cet ordre):\n"
. "1. Header sticky avec logo, menu (5-6 items), CTA button\n"
. "2. Hero section avec headline + sub-headline + 2 CTA + visual mockup/illustration\n"
. "3. Logo bar (6-8 companies trust)\n"
. "4. Features grid (6 features avec icons SVG, titres, descriptions)\n"
. "5. How it works (3-4 etapes numerotees)\n"
. "6. Testimonials (3 cards avec rating 5 etoiles, photo avatar circulaire initiales, nom, entreprise)\n"
. "7. Pricing table (3 tiers: Starter/Pro/Enterprise) avec features check/cross\n"
. "8. FAQ accordeon (5-6 questions)\n"
. "9. CTA final section\n"
. "10. Footer riche (4 colonnes links + newsletter + social)\n\n"
. "Tech:\n"
. "- Tailwind CSS via CDN\n"
. "- HTML complet standalone <!DOCTYPE html>\n"
. "- Mobile responsive (breakpoints sm/md/lg)\n"
. "- Dark/light mode toggle avec localStorage ... NON, pas localStorage. Juste toggle simple via class.\n"
. "- Palette: indigo/purple/slate pour bg, emerald pour succes CTAs\n"
. "- Hover effects (scale, shadow, color transitions)\n"
. "- Smooth scroll anchors\n"
. "- Animations CSS (fade-in, slide-up)\n"
. "- Typography: Inter / system-ui\n"
. "- Design ultra moderne 2026\n"
. "- Contenu realiste et coherent avec le sujet\n"
. "- Pas de localStorage, pas de fetch externe\n\n"
. "RETOURNE UNIQUEMENT LE CODE HTML complet (sans backticks)";
$ch = curl_init('http://127.0.0.1:4000/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode([
'model' => 'auto',
'messages' => [['role'=>'user', 'content'=>$prompt]],
'max_tokens' => 12000, 'temperature' => 0.75
]),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_TIMEOUT => 180,
]);
$resp = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http !== 200) { echo json_encode(['ok'=>false,'error'=>"LLM HTTP $http"]); exit; }
$data = json_decode($resp, true);
$html = $data['choices'][0]['message']['content'] ?? '';
$html = preg_replace('/^```(?:html)?\s*\n/', '', $html);
$html = preg_replace('/\n```\s*$/', '', trim($html));
if (stripos($html, '<!DOCTYPE') === false && stripos($html, '<html') === false) {
echo json_encode(['ok'=>false,'error'=>'invalid HTML','preview'=>substr($html,0,300)]); exit;
}
$filename = 'site-' . substr(md5($topic . microtime(true)), 0, 10) . '.html';
$outpath = '/var/www/html/files/' . $filename;
if (!is_dir('/var/www/html/files')) { mkdir('/var/www/html/files', 0755, true); }
file_put_contents($outpath, $html);
echo json_encode([
'ok'=>true,
'url'=>'/files/'.$filename,
'preview_url'=>'/files/'.$filename,
'title'=>'Landing Page - ' . substr($topic, 0, 50),
'topic'=>$topic,
'size_kb'=>round(filesize($outpath)/1024, 1),
'lines'=>substr_count($html, "\n"),
]);