setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Tables dédiées WEVAL MIND $pdo->exec("CREATE TABLE IF NOT EXISTS admin.hamid_config ( id SERIAL PRIMARY KEY, config_key VARCHAR(100) UNIQUE NOT NULL, config_value TEXT )"); // Sauvegarder $msg = ''; if ($_POST && isset($_POST['save'])) { $fields = ['bot_name','welcome_message','color1','color2','groq_api_key','system_prompt']; foreach ($fields as $k) { if (isset($_POST[$k])) { $stmt = $pdo->prepare("INSERT INTO admin.hamid_config (config_key, config_value) VALUES (?, ?) ON CONFLICT (config_key) DO UPDATE SET config_value = EXCLUDED.config_value"); $stmt->execute([$k, $_POST[$k]]); } } $msg = '✅ Configuration WEVAL MIND sauvegardée!'; } // Test Groq API if (isset($_GET['test_groq'])) { header('Content-Type: application/json'); $config = []; $stmt = $pdo->query("SELECT config_key, config_value FROM admin.hamid_config"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) $config[$row['config_key']] = $row['config_value']; $apiKey = $config['groq_api_key'] ?? ''; if (empty($apiKey)) { echo json_encode(['status' => 'error', 'message' => 'API Key manquante']); exit; } $start = microtime(true); $ch = curl_init('https://api.groq.com/openai/v1/chat/completions'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_TIMEOUT => 10, CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Authorization: Bearer ' . $apiKey], CURLOPT_POSTFIELDS => json_encode(['model' => 'llama-3.3-70b-versatile', 'messages' => [['role' => 'user', 'content' => 'Hi']], 'max_tokens' => 5]) ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $latency = round((microtime(true) - $start) * 1000); if ($httpCode == 200) { echo json_encode(['status' => 'ok', 'message' => "✅ Groq OK - {$latency}ms", 'latency' => $latency]); } else { echo json_encode(['status' => 'error', 'message' => "❌ Erreur HTTP $httpCode"]); } exit; } // Charger config WEVAL MIND $config = []; $stmt = $pdo->query("SELECT config_key, config_value FROM admin.hamid_config"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) $config[$row['config_key']] = $row['config_value']; // Defaults $d = [ 'bot_name' => 'Hamid Esmart', 'welcome_message' => 'Bonjour! 👋 Je suis Hamid Esmart, votre expert WEVAL.', 'color1' => '#06b6d4', 'color2' => '#0891b2', 'groq_api_key' => '', 'system_prompt' => 'Tu es Hamid Esmart, assistant IA expert WEVAL. Tu connais PowerMTA, Office365, Tracking, et toute l\'infrastructure email marketing.' ]; foreach ($d as $k => $v) if (empty($config[$k])) $config[$k] = $v; // Stats $kbCount = $pdo->query("SELECT COUNT(*) FROM admin.chatbot_knowledge")->fetchColumn() ?: 0; $catCount = $pdo->query("SELECT COUNT(DISTINCT category) FROM admin.chatbot_knowledge")->fetchColumn() ?: 0; $memCount = $pdo->query("SELECT COUNT(*) FROM admin.chatbot_memory")->fetchColumn() ?: 0; // Gestion KB $kbMsg = ''; if ($_POST && isset($_POST['add_kb'])) { $stmt = $pdo->prepare("INSERT INTO admin.chatbot_knowledge (question, answer, category) VALUES (?, ?, ?)"); $stmt->execute([$_POST['question'], $_POST['answer'], $_POST['category']]); $kbMsg = '✅ Entrée KB ajoutée!'; } if (isset($_GET['delete_kb'])) { $pdo->prepare("DELETE FROM admin.chatbot_knowledge WHERE id = ?")->execute([$_GET['delete_kb']]); header('Location: hamid-admin.php?tab=kb&deleted=1'); exit; } $tab = $_GET['tab'] ?? 'config'; // Charger KB $search = $_GET['search'] ?? ''; $catFilter = $_GET['cat'] ?? ''; $sql = "SELECT * FROM admin.chatbot_knowledge WHERE 1=1"; if ($search) $sql .= " AND (question ILIKE '%" . addslashes($search) . "%' OR answer ILIKE '%" . addslashes($search) . "%')"; if ($catFilter) $sql .= " AND category = '" . addslashes($catFilter) . "'"; $sql .= " ORDER BY id DESC LIMIT 50"; $kbEntries = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC); $categories = $pdo->query("SELECT DISTINCT category FROM admin.chatbot_knowledge ORDER BY category")->fetchAll(PDO::FETCH_COLUMN); ?> 🧠 WEVAL MIND Admin

WEVAL MIND Admin

Entrée supprimée!
Cette page configure uniquement WEVAL MIND (hamid-fullscreen.php). Pour configurer le Widget popup, utilisez Widget Admin.
Configuration Base de Connaissances ()
📚
KB Entries
📁
Catégories
🧠
Mémoires
GROQ
Provider

Groq API (Provider WEVAL MIND)

LLama 3.3 70B - Ultra rapide
Obtenir: console.groq.com/keys (gratuit)
Cliquez sur Tester pour vérifier la connexion
🤖

Personnalité WEVAL MIND

Configurez l'apparence et le comportement de Hamid

Définit comment Hamid se comporte et répond aux questions
📚

Base de Connaissances

entrées dans catégories

Ajouter une nouvelle entrée
ID Question Catégorie Action
70 ? '...' : '' ?>