474 lines
15 KiB
PHP
Executable File
474 lines
15 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* WEVAL MIND Playground - Test Multi-IA
|
|
*/
|
|
session_start();
|
|
|
|
try {
|
|
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
$config = [];
|
|
$stmt = $pdo->query("SELECT config_key, config_value FROM admin.hamid_config");
|
|
if ($stmt) {
|
|
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|
$config[$row['config_key']] = $row['config_value'];
|
|
}
|
|
}
|
|
} catch (Exception $e) {
|
|
$config = [];
|
|
$dbError = $e->getMessage();
|
|
}
|
|
|
|
$providers = [
|
|
'groq' => ['name' => 'Groq', 'icon' => '⚡', 'key' => 'groq_api_key', 'free' => true],
|
|
'deepseek' => ['name' => 'DeepSeek', 'icon' => '🌊', 'key' => 'deepseek_api_key', 'free' => true],
|
|
'mistral' => ['name' => 'Mistral', 'icon' => '🇫🇷', 'key' => 'mistral_api_key', 'free' => true],
|
|
'together' => ['name' => 'Together AI', 'icon' => '🤝', 'key' => 'together_api_key', 'free' => true],
|
|
'openrouter' => ['name' => 'OpenRouter', 'icon' => '🔀', 'key' => 'openrouter_api_key', 'free' => true],
|
|
'claude' => ['name' => 'Claude', 'icon' => '🧠', 'key' => 'anthropic_api_key', 'free' => false],
|
|
'openai' => ['name' => 'OpenAI', 'icon' => '🤖', 'key' => 'openai_api_key', 'free' => false],
|
|
'gemini' => ['name' => 'Gemini', 'icon' => '💎', 'key' => 'gemini_api_key', 'free' => false],
|
|
'cohere' => ['name' => 'Cohere', 'icon' => '🔶', 'key' => 'cohere_api_key', 'free' => false],
|
|
];
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>WEVAL MIND Playground - Test Multi-IA</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
:root {
|
|
--bg: #0f1419;
|
|
--bg-secondary: #1a1f2e;
|
|
--bg-tertiary: #252d3d;
|
|
--border: #2d3548;
|
|
--text: #e8eaed;
|
|
--text-dim: #9aa0a6;
|
|
--accent: #00d4aa;
|
|
--success: #4caf50;
|
|
--warning: #ff9800;
|
|
--error: #f44336;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
min-height: 100vh;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
h1 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
background: linear-gradient(135deg, var(--accent), #38bdf8);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
}
|
|
|
|
.providers-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
gap: 16px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.provider-card {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
padding: 16px;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.provider-card:hover {
|
|
border-color: var(--accent);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.provider-card.selected {
|
|
border-color: var(--accent);
|
|
background: var(--bg-tertiary);
|
|
}
|
|
|
|
.provider-card.disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.provider-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.provider-icon {
|
|
font-size: 28px;
|
|
}
|
|
|
|
.provider-name {
|
|
font-weight: 600;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.provider-badge {
|
|
margin-left: auto;
|
|
padding: 4px 8px;
|
|
border-radius: 8px;
|
|
font-size: 11px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.badge-free { background: #1b5e20; color: #a5d6a7; }
|
|
.badge-paid { background: #e65100; color: #ffcc80; }
|
|
|
|
.provider-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
color: var(--text-dim);
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.status-dot.ready { background: var(--success); }
|
|
.status-dot.missing { background: var(--error); }
|
|
|
|
.chat-section {
|
|
background: var(--bg-secondary);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.chat-header {
|
|
padding: 16px;
|
|
background: var(--bg-tertiary);
|
|
border-bottom: 1px solid var(--border);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.chat-header-provider {
|
|
font-size: 20px;
|
|
}
|
|
|
|
.chat-header-name {
|
|
font-weight: 600;
|
|
}
|
|
|
|
.chat-header-status {
|
|
margin-left: auto;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 12px;
|
|
color: var(--accent);
|
|
}
|
|
|
|
.chat-messages {
|
|
height: 400px;
|
|
overflow-y: auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.message {
|
|
margin-bottom: 16px;
|
|
display: flex;
|
|
gap: 12px;
|
|
}
|
|
|
|
.msg-avatar {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 18px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.message.user .msg-avatar { background: var(--bg-tertiary); }
|
|
.message.assistant .msg-avatar { background: linear-gradient(135deg, var(--accent), #38bdf8); }
|
|
|
|
.msg-content {
|
|
flex: 1;
|
|
background: var(--bg-tertiary);
|
|
border-radius: 12px;
|
|
padding: 12px 16px;
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.message.user .msg-content {
|
|
background: var(--accent);
|
|
color: #000;
|
|
}
|
|
|
|
.msg-meta {
|
|
margin-top: 8px;
|
|
font-size: 11px;
|
|
color: var(--text-dim);
|
|
display: flex;
|
|
gap: 12px;
|
|
}
|
|
|
|
.chat-input-area {
|
|
padding: 16px;
|
|
background: var(--bg-tertiary);
|
|
border-top: 1px solid var(--border);
|
|
display: flex;
|
|
gap: 12px;
|
|
}
|
|
|
|
.chat-input {
|
|
flex: 1;
|
|
background: var(--bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 12px 16px;
|
|
color: var(--text);
|
|
font-size: 14px;
|
|
outline: none;
|
|
}
|
|
|
|
.chat-input:focus {
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.send-btn {
|
|
padding: 12px 24px;
|
|
background: var(--accent);
|
|
border: none;
|
|
border-radius: 8px;
|
|
color: #000;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.send-btn:hover {
|
|
opacity: 0.9;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.send-btn:disabled {
|
|
background: var(--bg-tertiary);
|
|
color: var(--text-dim);
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.typing {
|
|
display: flex;
|
|
gap: 4px;
|
|
}
|
|
|
|
.typing span {
|
|
width: 8px;
|
|
height: 8px;
|
|
background: var(--accent);
|
|
border-radius: 50%;
|
|
animation: typing 1.4s ease-in-out infinite;
|
|
}
|
|
|
|
.typing span:nth-child(2) { animation-delay: 0.2s; }
|
|
.typing span:nth-child(3) { animation-delay: 0.4s; }
|
|
|
|
@keyframes typing {
|
|
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
|
40% { transform: scale(1); opacity: 1; }
|
|
}
|
|
|
|
.back-link {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
color: var(--text-dim);
|
|
text-decoration: none;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.back-link:hover { color: var(--accent); }
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<a href="/" class="back-link"><i class="fas fa-arrow-left"></i> Retour WEVAL</a>
|
|
|
|
<h1>🧠 WEVAL MIND Playground - Test Multi-IA</h1>
|
|
|
|
<?php if (isset($dbError)): ?>
|
|
<div style="background:#f44336;color:#fff;padding:12px;border-radius:8px;margin-bottom:20px;">
|
|
Erreur DB: <?= htmlspecialchars($dbError) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="providers-grid">
|
|
<?php foreach ($providers as $id => $p):
|
|
$hasKey = !empty($config[$p['key']] ?? '');
|
|
?>
|
|
<div class="provider-card <?= $hasKey ? '' : 'disabled' ?>"
|
|
data-provider="<?= $id ?>"
|
|
onclick="<?= $hasKey ? "selectProvider('$id')" : '' ?>">
|
|
<div class="provider-header">
|
|
<span class="provider-icon"><?= $p['icon'] ?></span>
|
|
<span class="provider-name"><?= $p['name'] ?></span>
|
|
<span class="provider-badge <?= $p['free'] ? 'badge-free' : 'badge-paid' ?>">
|
|
<?= $p['free'] ? 'GRATUIT' : 'PAYANT' ?>
|
|
</span>
|
|
</div>
|
|
<div class="provider-status">
|
|
<span class="status-dot <?= $hasKey ? 'ready' : 'missing' ?>"></span>
|
|
<?= $hasKey ? 'Prêt' : 'Clé API manquante' ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="chat-section">
|
|
<div class="chat-header">
|
|
<span class="chat-header-provider" id="currentProviderIcon">⚡</span>
|
|
<span class="chat-header-name" id="currentProviderName">Groq</span>
|
|
<div class="chat-header-status">
|
|
<span class="status-dot ready"></span>
|
|
<span id="statusText">Prêt</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chat-messages" id="chatMessages">
|
|
<div class="message assistant">
|
|
<div class="msg-avatar">🧠</div>
|
|
<div class="msg-content">
|
|
Salut ! Sélectionne un provider IA ci-dessus puis pose-moi une question pour tester.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="chat-input-area">
|
|
<input type="text" class="chat-input" id="chatInput" placeholder="Tape ton message..." onkeypress="if(event.key==='Enter')sendMessage()">
|
|
<button class="send-btn" id="sendBtn" onclick="sendMessage()">Envoyer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const providers = <?= json_encode($providers) ?>;
|
|
let currentProvider = 'groq';
|
|
|
|
function selectProvider(id) {
|
|
currentProvider = id;
|
|
const p = providers[id];
|
|
|
|
document.querySelectorAll('.provider-card').forEach(c => c.classList.remove('selected'));
|
|
document.querySelector(`[data-provider="${id}"]`)?.classList.add('selected');
|
|
|
|
document.getElementById('currentProviderIcon').textContent = p.icon;
|
|
document.getElementById('currentProviderName').textContent = p.name;
|
|
}
|
|
|
|
async function sendMessage() {
|
|
const input = document.getElementById('chatInput');
|
|
const msg = input.value.trim();
|
|
if (!msg) return;
|
|
|
|
const messages = document.getElementById('chatMessages');
|
|
const p = providers[currentProvider];
|
|
|
|
// User message
|
|
messages.innerHTML += `
|
|
<div class="message user">
|
|
<div class="msg-avatar">👤</div>
|
|
<div class="msg-content">${escHtml(msg)}</div>
|
|
</div>`;
|
|
|
|
input.value = '';
|
|
|
|
// Loading
|
|
const loadingId = 'loading-' + Date.now();
|
|
messages.innerHTML += `
|
|
<div class="message assistant" id="${loadingId}">
|
|
<div class="msg-avatar">${p.icon}</div>
|
|
<div class="msg-content"><div class="typing"><span></span><span></span><span></span></div></div>
|
|
</div>`;
|
|
messages.scrollTop = messages.scrollHeight;
|
|
|
|
document.getElementById('statusText').textContent = 'Réflexion...';
|
|
|
|
try {
|
|
const start = Date.now();
|
|
const res = await fetch('/hamid-brain.php', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({
|
|
message: msg,
|
|
provider: currentProvider,
|
|
auto_fallback: false
|
|
})
|
|
});
|
|
|
|
const data = await res.json();
|
|
const duration = Date.now() - start;
|
|
|
|
document.getElementById(loadingId)?.remove();
|
|
|
|
const usedProvider = providers[data.provider] || p;
|
|
|
|
messages.innerHTML += `
|
|
<div class="message assistant">
|
|
<div class="msg-avatar">${usedProvider.icon}</div>
|
|
<div>
|
|
<div class="msg-content">${escHtml(data.response || data.error || 'Erreur')}</div>
|
|
<div class="msg-meta">
|
|
<span>${usedProvider.name}</span>
|
|
<span>${duration}ms</span>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
|
|
document.getElementById('statusText').textContent = data.success ? 'Prêt' : 'Erreur';
|
|
} catch (e) {
|
|
document.getElementById(loadingId)?.remove();
|
|
messages.innerHTML += `
|
|
<div class="message assistant">
|
|
<div class="msg-avatar">❌</div>
|
|
<div class="msg-content">Erreur: ${e.message}</div>
|
|
</div>`;
|
|
document.getElementById('statusText').textContent = 'Erreur';
|
|
}
|
|
|
|
messages.scrollTop = messages.scrollHeight;
|
|
}
|
|
|
|
function escHtml(text) {
|
|
const d = document.createElement('div');
|
|
d.textContent = text;
|
|
return d.innerHTML.replace(/\n/g, '<br>');
|
|
}
|
|
|
|
// Select first available provider
|
|
selectProvider('groq');
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|