- 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>
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* ProposalAI API — Commercial proposal generator
|
|
* POST /api/proposalai/generate
|
|
*/
|
|
require_once __DIR__ . '/../lib/auth.php';
|
|
require_once __DIR__ . '/../lib/wevia-proxy.php';
|
|
|
|
$user = requireAuth();
|
|
rateLimitCheck($user['id'], 5, 60);
|
|
|
|
$input = json_decode(file_get_contents('php://input'), true);
|
|
$clientName = $input['client'] ?? '';
|
|
$sector = $input['sector'] ?? '';
|
|
$brief = $input['brief'] ?? '';
|
|
$services = $input['services'] ?? [];
|
|
$budget = $input['budget'] ?? 'A definir';
|
|
$tone = $input['tone'] ?? 'professionnel';
|
|
$language = $input['language'] ?? 'fr';
|
|
|
|
if (empty($clientName) || empty($brief)) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'client et brief requis']);
|
|
exit;
|
|
}
|
|
|
|
$systemPrompt = "Tu es un consultant senior dans un cabinet de conseil international. Genere une proposition commerciale complete en markdown avec tableaux. Structure: Lettre d'accompagnement, Comprehension du besoin, Approche methodologique, Equipe projet, Planning detaille, Proposition financiere, Pourquoi nous choisir, Prochaines etapes. Ton: $tone. Langue: $language.";
|
|
|
|
$userPrompt = "Client: $clientName\nSecteur: $sector\nServices: " . implode(', ', $services) . "\nBudget: $budget\nBesoin: $brief";
|
|
|
|
$result = weviaGenerate($systemPrompt, $userPrompt, ['max_tokens' => 6000, 'timeout' => 180]);
|
|
|
|
if (isset($result['error'])) {
|
|
http_response_code($result['status'] ?? 500);
|
|
echo json_encode(['error' => $result['error']]);
|
|
exit;
|
|
}
|
|
|
|
echo json_encode([
|
|
'client' => $clientName,
|
|
'content' => $result['content'],
|
|
'format' => 'markdown',
|
|
'model' => $result['model'],
|
|
'usage' => $result['usage']
|
|
]);
|