- StoreForge API: e-commerce site generator via WEVIA - LeadForge API: B2B lead generation + ICP + sequences - ProposalAI API: commercial proposal generator - BlueprintAI API: process/architecture document generator - MailWarm API: email warmup status/start/history - OutreachAI API: cold outreach sequences + subject lines - FormBuilder API: AI form generator - EmailVerify API: email validation (MX, disposable, format) - Auth OTP: replaces email-only auth with OTP/magic-link - SQL migration: auth_otp + auth_attempts tables - WEVIA proxy library: routes all AI calls through server-side Ollama - Auth library: API key validation + rate limiting via Redis Co-authored-by: Yacineutt <Yacineutt@users.noreply.github.com>
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* FormBuilder API — AI form generator
|
|
* POST /api/formbuilder/generate
|
|
*/
|
|
require_once __DIR__ . '/../lib/auth.php';
|
|
require_once __DIR__ . '/../lib/wevia-proxy.php';
|
|
|
|
$user = requireAuth();
|
|
rateLimitCheck($user['id'], 10, 60);
|
|
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
$formType = $input['type'] ?? 'contact';
|
|
$fields = $input['fields'] ?? [];
|
|
$style = $input['style'] ?? 'modern';
|
|
$description = $input['description'] ?? '';
|
|
$language = $input['language'] ?? 'fr';
|
|
|
|
if (empty($description) && empty($fields)) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'description ou fields requis']);
|
|
exit;
|
|
}
|
|
|
|
$systemPrompt = "Expert UX/UI. Genere le code HTML/CSS complet d'un formulaire professionnel. Style: $style. Type: $formType. Responsive, accessible (ARIA), validation JS, design moderne. Code pret a deployer. Langue labels: $language.";
|
|
|
|
$userPrompt = empty($description)
|
|
? "Formulaire avec les champs: " . implode(', ', $fields)
|
|
: $description;
|
|
|
|
$result = weviaGenerate($systemPrompt, $userPrompt, ['max_tokens' => 4000]);
|
|
|
|
if (isset($result['error'])) {
|
|
http_response_code($result['status'] ?? 500);
|
|
echo json_encode(['error' => $result['error']]);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode([
|
|
'type' => $formType,
|
|
'html' => $result['content'],
|
|
'model' => $result['model']
|
|
]);
|