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.
70 lines
2.8 KiB
PHP
70 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* ambre-tool-3d.php — 3D scene generator (Three.js standalone HTML)
|
|
*/
|
|
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 Three.js r128. Genere une scene 3D interactive pour: \"$topic\"\n\n"
|
|
. "Contraintes:\n"
|
|
. "- Three.js via CDN https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js\n"
|
|
. "- OrbitControls via https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js\n"
|
|
. "- Fichier HTML UNIQUE complet avec <!DOCTYPE html>\n"
|
|
. "- Scene anime (animation loop)\n"
|
|
. "- OrbitControls actifs (souris)\n"
|
|
. "- Lumiere + ombre realistes\n"
|
|
. "- 5-10 objets 3D differents avec geometries/materiaux varies\n"
|
|
. "- Background degrade ou skybox\n"
|
|
. "- Fog pour profondeur\n"
|
|
. "- Resize responsive\n"
|
|
. "- Pas de NO_CAPSULE_GEOMETRY (utiliser CylinderGeometry/SphereGeometry)\n"
|
|
. "- Code propre et commente\n\n"
|
|
. "RETOURNE UNIQUEMENT LE CODE HTML sans backticks ni texte explicatif";
|
|
|
|
$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' => 6000, 'temperature' => 0.7
|
|
]),
|
|
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
|
|
CURLOPT_TIMEOUT => 120,
|
|
]);
|
|
$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 output','preview'=>substr($html,0,300)]); exit;
|
|
}
|
|
|
|
$filename = 'scene3d-' . 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'=>'Scene 3D - ' . substr($topic, 0, 50),
|
|
'topic'=>$topic,
|
|
'size'=>filesize($outpath),
|
|
'size_kb'=>round(filesize($outpath)/1024, 1),
|
|
'lines'=>substr_count($html, "\n"),
|
|
]);
|