File size: 8,561 Bytes
bde793d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Chatbot Performance Analyzer</title>
<link rel="stylesheet" href="/static/css/style.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Advanced Chatbot Performance</h1>
<p class="subtitle">Multi-context Evaluation with Attention LSTM</p>
<div id="status-bar"
style="margin-bottom: 1rem; text-align: center; font-size: 0.85rem; color: #fbbf24; background: rgba(251, 191, 36, 0.1); padding: 0.5rem; border-radius: 8px; border: 1px solid rgba(251, 191, 36, 0.2);">
⚠️ Model Initialization in Progress... (Epoch 1/2)
</div>
<div class="tabs">
<div class="tab active" onclick="switchTab('analyzer')">Analyzer</div>
<div class="tab" onclick="switchTab('dashboard')">Analytics Dashboard</div>
</div>
<!-- Analyzer View -->
<div id="analyzer-view" class="view active">
<div class="form-group">
<label for="facts">Related Context / Facts</label>
<textarea id="facts" rows="3" placeholder="Paste the knowledge base or facts here..."></textarea>
</div>
<div class="form-group">
<label for="question">User Question</label>
<textarea id="question" rows="2" placeholder="Enter the user question..."></textarea>
</div>
<div class="form-group">
<label for="response">Chatbot Response</label>
<textarea id="response" rows="3" placeholder="Enter the chatbot response..."></textarea>
</div>
<button id="analyze-btn">
<span class="loader" id="loader"></span>
Perform Deep Analysis
</button>
<div id="result" class="result-container">
<div class="result-header">Expert Verdict:</div>
<div id="result-text"></div>
<div id="score-badge" class="score-badge"></div>
<div id="probability" style="margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted);"></div>
</div>
</div>
<!-- Dashboard View -->
<div id="dashboard-view" class="view">
<h2 style="margin-bottom: 1rem;">Dataset Insights</h2>
<div class="dashboard-grid">
<div class="stat-card">
<div>Total Queries</div>
<div class="stat-value" id="total-queries">40,152</div>
</div>
<div class="stat-card">
<div>Overall Accuracy</div>
<div class="stat-value" id="overall-quality">31.4%</div>
</div>
</div>
<div class="engine-list">
<h3 style="margin-bottom: 0.5rem;">Engine Performance Breakdown</h3>
<div class="engine-item">
<span>Openbook Performance</span>
<span style="color: var(--success)">67.3% Top Responses</span>
</div>
<div class="engine-item">
<span>Dialogflow Performance</span>
<span style="color: #6366f1">24.2% Top Responses</span>
</div>
<div class="engine-item">
<span>Watson Performance</span>
<span style="color: var(--accent)">19.3% Top Responses</span>
</div>
<div class="engine-item">
<span>Rasa Performance</span>
<span style="color: var(--accent)">14.6% Top Responses</span>
</div>
</div>
</div>
</div>
<script>
// Check model status on load and every 30 seconds
async function checkStatus() {
try {
const res = await fetch('/predict', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ping: true })
});
if (res.ok) {
const statusBar = document.getElementById('status-bar');
statusBar.style.color = '#10b981';
statusBar.style.background = 'rgba(16, 185, 129, 0.1)';
statusBar.style.borderColor = 'rgba(16, 185, 129, 0.2)';
statusBar.innerText = '✅ Advanced Intelligence Engine Active';
setTimeout(() => statusBar.style.display = 'none', 5000);
}
} catch (e) { }
}
checkStatus();
const statusInterval = setInterval(() => {
const statusBar = document.getElementById('status-bar');
if (statusBar && statusBar.style.display !== 'none') {
checkStatus();
} else {
clearInterval(statusInterval);
}
}, 15000);
function switchTab(tab) {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.view').forEach(v => v.classList.remove('active'));
if (tab === 'analyzer') {
document.querySelector('.tab:nth-child(1)').classList.add('active');
document.getElementById('analyzer-view').classList.add('active');
} else {
document.querySelector('.tab:nth-child(2)').classList.add('active');
document.getElementById('dashboard-view').classList.add('active');
}
}
document.getElementById('analyze-btn').addEventListener('click', async () => {
const facts = document.getElementById('facts').value;
const question = document.getElementById('question').value;
const response = document.getElementById('response').value;
const loader = document.getElementById('loader');
const resultDiv = document.getElementById('result');
const resultText = document.getElementById('result-text');
const scoreBadge = document.getElementById('score-badge');
const probDiv = document.getElementById('probability');
if (!question || !response) {
alert('Please fill in the question and response.');
return;
}
loader.style.display = 'inline-block';
document.getElementById('analyze-btn').disabled = true;
resultDiv.style.display = 'none';
try {
const res = await fetch('/predict', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ facts, question, response })
});
const data = await res.json();
if (!res.ok) {
if (res.status === 503) {
alert(data.error);
} else {
alert('Analysis Error: ' + (data.error || 'Server error'));
}
return;
}
resultDiv.style.display = 'block';
if (data.is_best) {
resultText.innerText = "Advanced analysis confirms this is a high-fidelity response.";
scoreBadge.innerText = "OPTIMIZED";
scoreBadge.className = "score-badge score-good";
} else {
resultText.innerText = "Analysis suggests potential inaccuracies or linguistic flaws.";
scoreBadge.innerText = "SUB-OPTIMAL";
scoreBadge.className = "score-badge score-bad";
}
probDiv.innerText = `Attention Confidence: ${(data.probability * 100).toFixed(2)}%`;
} catch (err) {
alert('Analysis failed. Ensure server is running.');
} finally {
loader.style.display = 'none';
document.getElementById('analyze-btn').disabled = false;
}
});
</script>
</body>
</html> |