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.
68 lines
2.7 KiB
PHP
68 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* ambre-tool-dataviz.php — Interactive data viz (Plotly.js)
|
|
*/
|
|
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 data-viz Plotly.js. Genere un dashboard interactif pour: \"$topic\"\n\n"
|
|
. "Contraintes:\n"
|
|
. "- Plotly.js via CDN https://cdn.plot.ly/plotly-2.27.0.min.js\n"
|
|
. "- Tailwind CSS via CDN\n"
|
|
. "- HTML complet <!DOCTYPE html> standalone\n"
|
|
. "- 3-4 graphiques differents (line+bar+pie+scatter OU area+heatmap+radar etc)\n"
|
|
. "- Chaque chart dans une card avec titre\n"
|
|
. "- Grid responsive (2x2 desktop, 1 col mobile)\n"
|
|
. "- Donnees inline cohrentes avec le sujet (15-30 points minimum par chart)\n"
|
|
. "- Couleurs modernes (indigo/emerald/amber/rose)\n"
|
|
. "- Design premium (gradient header, shadows, spacing)\n"
|
|
. "- KPI summary cards en haut (3-4 cards avec chiffres cles)\n"
|
|
. "- Pas d'API externe, pas de fetch\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' => 7000, 'temperature' => 0.7
|
|
]),
|
|
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
|
|
CURLOPT_TIMEOUT => 140,
|
|
]);
|
|
$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 = 'dataviz-' . 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'=>'Dashboard - ' . substr($topic, 0, 50),
|
|
'topic'=>$topic,
|
|
'size_kb'=>round(filesize($outpath)/1024, 1),
|
|
'lines'=>substr_count($html, "\n"),
|
|
]);
|