Mark-Lasfar commited on
Commit ·
43807a2
1
Parent(s): 356ef4a
Major update: Enhanced frontend and backend
Browse files- Added Mermaid diagram support for flowcharts and sequence diagrams
- Implemented Dark/Light theme toggle with localStorage persistence
- Fixed voice synthesis (speech) with voice loading detection
- Improved RTL/LTR support for Arabic/English
- Enhanced streaming performance in renderMarkdown
- Updated system prompt for deeper technical reasoning
- Switched to better models (DeepSeek-R1 / Qwen-72B)
- Improved mobile responsiveness and chat box sizing
- Added copy buttons for code blocks
- Fixed duplicate message prevention
- Optimized CSS for better performance
- static/css/chat/bubble.css +23 -0
- static/css/chat/markdown.css +26 -0
- static/css/chat/style.css +67 -0
- static/js/chat.js +79 -14
- templates/chat.html +424 -510
static/css/chat/bubble.css
CHANGED
|
@@ -89,4 +89,27 @@
|
|
| 89 |
|
| 90 |
.action-btn:hover {
|
| 91 |
color: #60a5fa;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
|
|
|
| 89 |
|
| 90 |
.action-btn:hover {
|
| 91 |
color: #60a5fa;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/* Light theme support for bubbles (يتناغم مع tailwind) */
|
| 95 |
+
html.light .bubble {
|
| 96 |
+
background: #f3f4f6;
|
| 97 |
+
color: #1f2937;
|
| 98 |
+
border-color: #e5e7eb;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
html.light .bubble-user {
|
| 102 |
+
background: #e0f2fe;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
html.light .bubble-assist {
|
| 106 |
+
background: #ffffff;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
html.light .message-actions .action-btn {
|
| 110 |
+
color: #3b82f6;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
html.light .message-actions .action-btn:hover {
|
| 114 |
+
color: #2563eb;
|
| 115 |
}
|
static/css/chat/markdown.css
CHANGED
|
@@ -160,4 +160,30 @@
|
|
| 160 |
|
| 161 |
.md-content table td pre, .md-content table th pre {
|
| 162 |
overflow: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
}
|
|
|
|
| 160 |
|
| 161 |
.md-content table td pre, .md-content table th pre {
|
| 162 |
overflow: auto;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/* Light theme support for markdown */
|
| 166 |
+
html.light .md-content pre {
|
| 167 |
+
background: #f3f4f6;
|
| 168 |
+
border-color: #e5e7eb;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
html.light .md-content code {
|
| 172 |
+
background: #e5e7eb;
|
| 173 |
+
color: #1f2937;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
html.light .md-content th,
|
| 177 |
+
html.light .md-content td {
|
| 178 |
+
border-color: #d1d5db;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
html.light .md-content th,
|
| 182 |
+
html.light tbody tr:nth-child(odd) td {
|
| 183 |
+
background: #f9fafb;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
html.light .md-content blockquote {
|
| 187 |
+
background: #eff6ff;
|
| 188 |
+
border-left-color: #3b82f6;
|
| 189 |
}
|
static/css/chat/style.css
CHANGED
|
@@ -20,4 +20,71 @@
|
|
| 20 |
|
| 21 |
.hidden {
|
| 22 |
display: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
|
|
|
| 20 |
|
| 21 |
.hidden {
|
| 22 |
display: none !important;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
/* Mermaid diagram container */
|
| 27 |
+
.mermaid-diagram {
|
| 28 |
+
background: rgba(0, 0, 0, 0.2);
|
| 29 |
+
border-radius: 0.75rem;
|
| 30 |
+
padding: 1rem;
|
| 31 |
+
margin: 1rem 0;
|
| 32 |
+
overflow-x: auto;
|
| 33 |
+
text-align: center;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.mermaid-diagram svg {
|
| 37 |
+
max-width: 100%;
|
| 38 |
+
height: auto;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Light theme support for mermaid */
|
| 42 |
+
html.light .mermaid-diagram {
|
| 43 |
+
background: #f3f4f6;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/* Smooth scrolling for chat */
|
| 47 |
+
#chatBox, #chatArea {
|
| 48 |
+
scroll-behavior: smooth;
|
| 49 |
+
-webkit-overflow-scrolling: touch;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
/* Force theme toggle button visibility */
|
| 54 |
+
#themeToggle {
|
| 55 |
+
display: inline-flex !important;
|
| 56 |
+
align-items: center !important;
|
| 57 |
+
justify-content: center !important;
|
| 58 |
+
cursor: pointer !important;
|
| 59 |
+
background: #1f2937 !important;
|
| 60 |
+
border: none !important;
|
| 61 |
+
border-radius: 50% !important;
|
| 62 |
+
width: 2rem !important;
|
| 63 |
+
height: 2rem !important;
|
| 64 |
+
font-size: 1.2rem !important;
|
| 65 |
+
transition: all 0.3s ease !important;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
#themeToggle:hover {
|
| 69 |
+
background: #3b82f6 !important;
|
| 70 |
+
transform: scale(1.05) !important;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/* Light theme styles for body and background */
|
| 74 |
+
html.light body {
|
| 75 |
+
background: linear-gradient(135deg, #f8fafc, #e2e8f0) !important;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
html.light .bg-gradient-to-br {
|
| 79 |
+
background: var(--bg-primary) !important;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
html.light .chat-title,
|
| 83 |
+
html.light .icon-btn {
|
| 84 |
+
color: #1f2937 !important;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
html.light .icon-btn:hover {
|
| 88 |
+
background: #e2e8f0 !important;
|
| 89 |
+
color: #3b82f6 !important;
|
| 90 |
}
|
static/js/chat.js
CHANGED
|
@@ -194,6 +194,28 @@ async function updateSidebarAfterLogin() {
|
|
| 194 |
}
|
| 195 |
}
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
// ============================================================
|
| 198 |
// RENDER MARKDOWN
|
| 199 |
// ============================================================
|
|
@@ -265,9 +287,12 @@ async function renderMarkdown(el, isStreaming = false) {
|
|
| 265 |
}
|
| 266 |
});
|
| 267 |
|
|
|
|
| 268 |
// ✅ تنشيط تلوين الكود (Prism.js) بعد انتهاء التدفق مباشرةً
|
| 269 |
Prism.highlightAllUnder(wrapper);
|
| 270 |
|
|
|
|
|
|
|
| 271 |
if (uiElements.chatBox) {
|
| 272 |
uiElements.chatBox.scrollTop = uiElements.chatBox.scrollHeight;
|
| 273 |
}
|
|
@@ -329,35 +354,32 @@ function addMsg(who, text) {
|
|
| 329 |
speakBtn.title = 'Read aloud';
|
| 330 |
speakBtn.onclick = async () => {
|
| 331 |
try {
|
| 332 |
-
// إلغاء أي نطق قيد التشغيل
|
| 333 |
window.speechSynthesis.cancel();
|
| 334 |
|
| 335 |
-
// ت
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
}
|
| 341 |
|
| 342 |
const utterance = new SpeechSynthesisUtterance(text);
|
| 343 |
|
| 344 |
-
// اختر اللغة المناسبة
|
| 345 |
if (isArabicText(text)) {
|
| 346 |
utterance.lang = 'ar';
|
| 347 |
-
// محاولة استخدام صوت عربي إذا كان متاحًا
|
| 348 |
-
const voices = window.speechSynthesis.getVoices();
|
| 349 |
const arabicVoice = voices.find(v => v.lang === 'ar' || v.lang === 'ar-EG' || v.lang === 'ar-SA');
|
| 350 |
if (arabicVoice) utterance.voice = arabicVoice;
|
| 351 |
} else {
|
| 352 |
utterance.lang = 'en-US';
|
| 353 |
-
|
| 354 |
-
const voices = window.speechSynthesis.getVoices();
|
| 355 |
-
const englishVoice = voices.find(v => v.lang === 'en-US' && v.name.includes('Google')) ||
|
| 356 |
-
voices.find(v => v.lang === 'en-US');
|
| 357 |
if (englishVoice) utterance.voice = englishVoice;
|
| 358 |
}
|
| 359 |
|
| 360 |
-
utterance.rate =
|
| 361 |
utterance.pitch = 1.0;
|
| 362 |
utterance.volume = 1.0;
|
| 363 |
|
|
@@ -1553,6 +1575,49 @@ window.addEventListener('online', () => {
|
|
| 1553 |
}
|
| 1554 |
});
|
| 1555 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1556 |
// ============================================================
|
| 1557 |
// INITIALIZATION
|
| 1558 |
// ============================================================
|
|
|
|
| 194 |
}
|
| 195 |
}
|
| 196 |
|
| 197 |
+
|
| 198 |
+
async function renderMermaidDiagrams(wrapper) {
|
| 199 |
+
if (typeof mermaid === 'undefined') return;
|
| 200 |
+
const mermaidBlocks = wrapper.querySelectorAll('pre code.language-mermaid');
|
| 201 |
+
for (const block of mermaidBlocks) {
|
| 202 |
+
const pre = block.parentElement;
|
| 203 |
+
const diagramText = block.innerText;
|
| 204 |
+
const container = document.createElement('div');
|
| 205 |
+
container.className = 'mermaid-diagram';
|
| 206 |
+
try {
|
| 207 |
+
const id = `mermaid-${Date.now()}-${Math.random()}`;
|
| 208 |
+
const { svg } = await mermaid.render(id, diagramText);
|
| 209 |
+
container.innerHTML = svg;
|
| 210 |
+
pre.replaceWith(container);
|
| 211 |
+
} catch (e) {
|
| 212 |
+
console.error('Mermaid error:', e);
|
| 213 |
+
container.innerHTML = `<div class="text-red-500">Failed to render diagram: ${e.message}</div>`;
|
| 214 |
+
pre.replaceWith(container);
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
// ============================================================
|
| 220 |
// RENDER MARKDOWN
|
| 221 |
// ============================================================
|
|
|
|
| 287 |
}
|
| 288 |
});
|
| 289 |
|
| 290 |
+
|
| 291 |
// ✅ تنشيط تلوين الكود (Prism.js) بعد انتهاء التدفق مباشرةً
|
| 292 |
Prism.highlightAllUnder(wrapper);
|
| 293 |
|
| 294 |
+
await renderMermaidDiagrams(wrapper);
|
| 295 |
+
|
| 296 |
if (uiElements.chatBox) {
|
| 297 |
uiElements.chatBox.scrollTop = uiElements.chatBox.scrollHeight;
|
| 298 |
}
|
|
|
|
| 354 |
speakBtn.title = 'Read aloud';
|
| 355 |
speakBtn.onclick = async () => {
|
| 356 |
try {
|
|
|
|
| 357 |
window.speechSynthesis.cancel();
|
| 358 |
|
| 359 |
+
// انتظار تحميل الأصوات
|
| 360 |
+
let voices = window.speechSynthesis.getVoices();
|
| 361 |
+
if (voices.length === 0) {
|
| 362 |
+
await new Promise(resolve => {
|
| 363 |
+
window.speechSynthesis.onvoiceschanged = () => {
|
| 364 |
+
voices = window.speechSynthesis.getVoices();
|
| 365 |
+
resolve();
|
| 366 |
+
};
|
| 367 |
+
});
|
| 368 |
}
|
| 369 |
|
| 370 |
const utterance = new SpeechSynthesisUtterance(text);
|
| 371 |
|
|
|
|
| 372 |
if (isArabicText(text)) {
|
| 373 |
utterance.lang = 'ar';
|
|
|
|
|
|
|
| 374 |
const arabicVoice = voices.find(v => v.lang === 'ar' || v.lang === 'ar-EG' || v.lang === 'ar-SA');
|
| 375 |
if (arabicVoice) utterance.voice = arabicVoice;
|
| 376 |
} else {
|
| 377 |
utterance.lang = 'en-US';
|
| 378 |
+
const englishVoice = voices.find(v => v.lang === 'en-US' && v.name.includes('Google'));
|
|
|
|
|
|
|
|
|
|
| 379 |
if (englishVoice) utterance.voice = englishVoice;
|
| 380 |
}
|
| 381 |
|
| 382 |
+
utterance.rate = 0.9;
|
| 383 |
utterance.pitch = 1.0;
|
| 384 |
utterance.volume = 1.0;
|
| 385 |
|
|
|
|
| 1575 |
}
|
| 1576 |
});
|
| 1577 |
|
| 1578 |
+
|
| 1579 |
+
// ============================================================
|
| 1580 |
+
// THEME TOGGLE
|
| 1581 |
+
// ============================================================
|
| 1582 |
+
function initTheme() {
|
| 1583 |
+
const savedTheme = localStorage.getItem('theme');
|
| 1584 |
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 1585 |
+
|
| 1586 |
+
if (savedTheme === 'light' || (!savedTheme && !prefersDark)) {
|
| 1587 |
+
document.documentElement.classList.add('light');
|
| 1588 |
+
document.documentElement.classList.remove('dark');
|
| 1589 |
+
document.querySelector('#themeToggle').textContent = '☀️';
|
| 1590 |
+
} else {
|
| 1591 |
+
document.documentElement.classList.add('dark');
|
| 1592 |
+
document.documentElement.classList.remove('light');
|
| 1593 |
+
document.querySelector('#themeToggle').textContent = '🌙';
|
| 1594 |
+
}
|
| 1595 |
+
}
|
| 1596 |
+
|
| 1597 |
+
function toggleTheme() {
|
| 1598 |
+
const html = document.documentElement;
|
| 1599 |
+
const themeBtn = document.querySelector('#themeToggle');
|
| 1600 |
+
if (html.classList.contains('dark')) {
|
| 1601 |
+
html.classList.remove('dark');
|
| 1602 |
+
html.classList.add('light');
|
| 1603 |
+
themeBtn.textContent = '☀️';
|
| 1604 |
+
localStorage.setItem('theme', 'light');
|
| 1605 |
+
} else {
|
| 1606 |
+
html.classList.remove('light');
|
| 1607 |
+
html.classList.add('dark');
|
| 1608 |
+
themeBtn.textContent = '🌙';
|
| 1609 |
+
localStorage.setItem('theme', 'dark');
|
| 1610 |
+
}
|
| 1611 |
+
}
|
| 1612 |
+
|
| 1613 |
+
// سجل للأحداث
|
| 1614 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 1615 |
+
initTheme();
|
| 1616 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 1617 |
+
if (themeToggle) themeToggle.addEventListener('click', toggleTheme);
|
| 1618 |
+
});
|
| 1619 |
+
|
| 1620 |
+
|
| 1621 |
// ============================================================
|
| 1622 |
// INITIALIZATION
|
| 1623 |
// ============================================================
|
templates/chat.html
CHANGED
|
@@ -1,586 +1,500 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html lang="en" class="dark">
|
| 3 |
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport"
|
| 7 |
-
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=
|
| 8 |
<meta name="description"
|
| 9 |
content="Chat with MGZon Chatbot, an AI-powered tool for coding, analysis, and e-commerce queries. Supports text, image, and audio inputs." />
|
| 10 |
<meta name="keywords"
|
| 11 |
-
content="MGZon Chatbot, AI chatbot, code generation, DeepSeek, FastAPI, programming" />
|
| 12 |
<meta name="author" content="Mark Al-Asfar" />
|
| 13 |
<meta name="robots" content="index, follow" />
|
| 14 |
<title>MGZon Chatbot – AI Assistant</title>
|
|
|
|
| 15 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
|
| 16 |
<link rel="apple-touch-icon" href="/static/images/mg.svg" />
|
| 17 |
-
|
| 18 |
-
<
|
| 19 |
-
<
|
| 20 |
-
<link href="
|
| 21 |
-
|
| 22 |
-
<!--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 24 |
-
|
| 25 |
-
<!-- Markdown & Mermaid & Syntax Highlight -->
|
| 26 |
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 27 |
-
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
|
| 28 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" />
|
| 29 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
|
| 30 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
| 31 |
-
|
| 32 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
<script src="https://cdn.jsdelivr.net/npm/hammerjs@2.0.8/hammer.min.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js"></script>
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
<style>
|
| 38 |
-
* {
|
| 39 |
-
margin: 0;
|
| 40 |
-
padding: 0;
|
| 41 |
-
box-sizing: border-box;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
body {
|
| 45 |
-
font-family: 'Inter', sans-serif;
|
| 46 |
-
background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
|
| 47 |
-
min-height: 100vh;
|
| 48 |
-
color: #e2e8f0;
|
| 49 |
-
}
|
| 50 |
-
|
| 51 |
-
/* Custom Scrollbar */
|
| 52 |
-
::-webkit-scrollbar {
|
| 53 |
-
width: 6px;
|
| 54 |
-
height: 6px;
|
| 55 |
-
}
|
| 56 |
-
::-webkit-scrollbar-track {
|
| 57 |
-
background: #1e293b;
|
| 58 |
-
border-radius: 10px;
|
| 59 |
-
}
|
| 60 |
-
::-webkit-scrollbar-thumb {
|
| 61 |
-
background: #3b82f6;
|
| 62 |
-
border-radius: 10px;
|
| 63 |
-
}
|
| 64 |
-
::-webkit-scrollbar-thumb:hover {
|
| 65 |
-
background: #60a5fa;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
/* Sidebar */
|
| 69 |
-
#sidebar {
|
| 70 |
-
position: fixed;
|
| 71 |
-
top: 0;
|
| 72 |
-
left: 0;
|
| 73 |
-
bottom: 0;
|
| 74 |
-
width: 280px;
|
| 75 |
-
background: rgba(15, 23, 42, 0.95);
|
| 76 |
-
backdrop-filter: blur(12px);
|
| 77 |
-
transform: translateX(-100%);
|
| 78 |
-
transition: transform 0.3s ease;
|
| 79 |
-
z-index: 1000;
|
| 80 |
-
border-right: 1px solid rgba(59, 130, 246, 0.3);
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
#sidebar.open {
|
| 84 |
-
transform: translateX(0);
|
| 85 |
-
}
|
| 86 |
-
|
| 87 |
-
@media (min-width: 768px) {
|
| 88 |
-
#sidebar {
|
| 89 |
-
transform: translateX(0);
|
| 90 |
-
}
|
| 91 |
-
}
|
| 92 |
-
|
| 93 |
-
/* Chat Container */
|
| 94 |
-
.chat-container {
|
| 95 |
-
max-width: 1400px;
|
| 96 |
-
margin: 0 auto;
|
| 97 |
-
padding: 1rem;
|
| 98 |
-
min-height: 100vh;
|
| 99 |
-
display: flex;
|
| 100 |
-
flex-direction: column;
|
| 101 |
-
}
|
| 102 |
-
|
| 103 |
-
/* Chat Header */
|
| 104 |
-
.chat-header {
|
| 105 |
-
position: sticky;
|
| 106 |
-
top: 0;
|
| 107 |
-
background: rgba(15, 23, 42, 0.8);
|
| 108 |
-
backdrop-filter: blur(12px);
|
| 109 |
-
z-index: 100;
|
| 110 |
-
padding: 0.75rem 1.25rem;
|
| 111 |
-
border-radius: 1rem;
|
| 112 |
-
margin-bottom: 1rem;
|
| 113 |
-
border: 1px solid rgba(59, 130, 246, 0.3);
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
/* Chat Messages Area */
|
| 117 |
-
#chatBox {
|
| 118 |
-
flex: 1;
|
| 119 |
-
overflow-y: auto;
|
| 120 |
-
padding: 1rem;
|
| 121 |
-
display: flex;
|
| 122 |
-
flex-direction: column;
|
| 123 |
-
gap: 1rem;
|
| 124 |
-
min-height: 400px;
|
| 125 |
-
max-height: calc(100vh - 200px);
|
| 126 |
-
}
|
| 127 |
-
|
| 128 |
-
/* Message Bubble */
|
| 129 |
-
.message {
|
| 130 |
-
display: flex;
|
| 131 |
-
flex-direction: column;
|
| 132 |
-
max-width: 85%;
|
| 133 |
-
animation: fadeInUp 0.3s ease;
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
.message.user {
|
| 137 |
-
align-self: flex-end;
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
.message.assistant {
|
| 141 |
-
align-self: flex-start;
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.bubble {
|
| 145 |
-
padding: 0.875rem 1.25rem;
|
| 146 |
-
border-radius: 1.25rem;
|
| 147 |
-
line-height: 1.5;
|
| 148 |
-
font-size: 0.95rem;
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
.message.user .bubble {
|
| 152 |
-
background: linear-gradient(135deg, #3b82f6, #2563eb);
|
| 153 |
-
color: white;
|
| 154 |
-
border-bottom-right-radius: 0.25rem;
|
| 155 |
-
}
|
| 156 |
-
|
| 157 |
-
.message.assistant .bubble {
|
| 158 |
-
background: rgba(30, 41, 59, 0.9);
|
| 159 |
-
border: 1px solid rgba(59, 130, 246, 0.3);
|
| 160 |
-
border-bottom-left-radius: 0.25rem;
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
@keyframes fadeInUp {
|
| 164 |
-
from {
|
| 165 |
-
opacity: 0;
|
| 166 |
-
transform: translateY(10px);
|
| 167 |
-
}
|
| 168 |
-
to {
|
| 169 |
-
opacity: 1;
|
| 170 |
-
transform: translateY(0);
|
| 171 |
-
}
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/* Message Actions (Copy, Retry, Speak) */
|
| 175 |
-
.message-actions {
|
| 176 |
-
display: flex;
|
| 177 |
-
gap: 0.5rem;
|
| 178 |
-
margin-top: 0.5rem;
|
| 179 |
-
margin-left: 0.5rem;
|
| 180 |
-
opacity: 0;
|
| 181 |
-
transition: opacity 0.2s ease;
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
.message:hover .message-actions {
|
| 185 |
-
opacity: 1;
|
| 186 |
-
}
|
| 187 |
-
|
| 188 |
-
.action-btn {
|
| 189 |
-
background: transparent;
|
| 190 |
-
border: none;
|
| 191 |
-
color: #94a3b8;
|
| 192 |
-
cursor: pointer;
|
| 193 |
-
padding: 0.25rem 0.5rem;
|
| 194 |
-
border-radius: 0.375rem;
|
| 195 |
-
font-size: 0.75rem;
|
| 196 |
-
transition: all 0.2s;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
.action-btn:hover {
|
| 200 |
-
background: rgba(59, 130, 246, 0.2);
|
| 201 |
-
color: #3b82f6;
|
| 202 |
-
}
|
| 203 |
-
|
| 204 |
-
/* Input Container */
|
| 205 |
-
.input-wrapper {
|
| 206 |
-
background: rgba(30, 41, 59, 0.9);
|
| 207 |
-
backdrop-filter: blur(12px);
|
| 208 |
-
border-radius: 2rem;
|
| 209 |
-
padding: 0.5rem 1rem;
|
| 210 |
-
border: 1px solid rgba(59, 130, 246, 0.3);
|
| 211 |
-
transition: all 0.3s ease;
|
| 212 |
-
}
|
| 213 |
-
|
| 214 |
-
.input-wrapper:focus-within {
|
| 215 |
-
border-color: #3b82f6;
|
| 216 |
-
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
-
#userInput {
|
| 220 |
-
background: transparent;
|
| 221 |
-
border: none;
|
| 222 |
-
outline: none;
|
| 223 |
-
color: white;
|
| 224 |
-
resize: none;
|
| 225 |
-
font-size: 1rem;
|
| 226 |
-
padding: 0.5rem 0;
|
| 227 |
-
max-height: 120px;
|
| 228 |
-
font-family: inherit;
|
| 229 |
-
}
|
| 230 |
-
|
| 231 |
-
#userInput::placeholder {
|
| 232 |
-
color: #64748b;
|
| 233 |
-
}
|
| 234 |
-
|
| 235 |
-
/* Icon Buttons */
|
| 236 |
-
.icon-btn {
|
| 237 |
-
background: transparent;
|
| 238 |
-
border: none;
|
| 239 |
-
color: #94a3b8;
|
| 240 |
-
cursor: pointer;
|
| 241 |
-
padding: 0.5rem;
|
| 242 |
-
border-radius: 50%;
|
| 243 |
-
transition: all 0.2s ease;
|
| 244 |
-
display: inline-flex;
|
| 245 |
-
align-items: center;
|
| 246 |
-
justify-content: center;
|
| 247 |
-
}
|
| 248 |
-
|
| 249 |
-
.icon-btn:hover {
|
| 250 |
-
background: rgba(59, 130, 246, 0.2);
|
| 251 |
-
color: #3b82f6;
|
| 252 |
-
}
|
| 253 |
-
|
| 254 |
-
#sendBtn {
|
| 255 |
-
background: #3b82f6;
|
| 256 |
-
color: white;
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
-
#sendBtn:hover {
|
| 260 |
-
background: #2563eb;
|
| 261 |
-
transform: scale(1.05);
|
| 262 |
-
}
|
| 263 |
-
|
| 264 |
-
#sendBtn:disabled {
|
| 265 |
-
opacity: 0.5;
|
| 266 |
-
cursor: not-allowed;
|
| 267 |
-
transform: none;
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
#stopBtn {
|
| 271 |
-
background: #ef4444;
|
| 272 |
-
color: white;
|
| 273 |
-
}
|
| 274 |
-
|
| 275 |
-
#stopBtn:hover {
|
| 276 |
-
background: #dc2626;
|
| 277 |
-
transform: scale(1.05);
|
| 278 |
-
}
|
| 279 |
-
|
| 280 |
-
/* Prompt Items */
|
| 281 |
-
.prompt-card {
|
| 282 |
-
background: rgba(30, 41, 59, 0.6);
|
| 283 |
-
border: 1px solid rgba(59, 130, 246, 0.2);
|
| 284 |
-
border-radius: 2rem;
|
| 285 |
-
padding: 0.625rem 1.25rem;
|
| 286 |
-
transition: all 0.2s ease;
|
| 287 |
-
cursor: pointer;
|
| 288 |
-
font-size: 0.875rem;
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
.prompt-card:hover {
|
| 292 |
-
background: rgba(59, 130, 246, 0.2);
|
| 293 |
-
border-color: #3b82f6;
|
| 294 |
-
transform: translateY(-2px);
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
/* Markdown Content */
|
| 298 |
-
.md-content {
|
| 299 |
-
line-height: 1.6;
|
| 300 |
-
}
|
| 301 |
-
.md-content pre {
|
| 302 |
-
background: #0f172a;
|
| 303 |
-
border-radius: 0.75rem;
|
| 304 |
-
padding: 1rem;
|
| 305 |
-
overflow-x: auto;
|
| 306 |
-
margin: 0.75rem 0;
|
| 307 |
-
}
|
| 308 |
-
.md-content code {
|
| 309 |
-
font-family: 'Fira Code', monospace;
|
| 310 |
-
font-size: 0.85rem;
|
| 311 |
-
}
|
| 312 |
-
.md-content table {
|
| 313 |
-
width: 100%;
|
| 314 |
-
border-collapse: collapse;
|
| 315 |
-
margin: 1rem 0;
|
| 316 |
-
}
|
| 317 |
-
.md-content th, .md-content td {
|
| 318 |
-
border: 1px solid #334155;
|
| 319 |
-
padding: 0.5rem;
|
| 320 |
-
text-align: left;
|
| 321 |
-
}
|
| 322 |
-
.md-content th {
|
| 323 |
-
background: #1e293b;
|
| 324 |
-
}
|
| 325 |
-
.md-content p {
|
| 326 |
-
margin: 0.5rem 0;
|
| 327 |
-
}
|
| 328 |
-
.md-content ul, .md-content ol {
|
| 329 |
-
padding-left: 1.5rem;
|
| 330 |
-
margin: 0.5rem 0;
|
| 331 |
-
}
|
| 332 |
-
|
| 333 |
-
/* Mermaid Diagrams */
|
| 334 |
-
.mermaid {
|
| 335 |
-
background: #1e293b;
|
| 336 |
-
padding: 1rem;
|
| 337 |
-
border-radius: 0.75rem;
|
| 338 |
-
margin: 1rem 0;
|
| 339 |
-
text-align: center;
|
| 340 |
-
}
|
| 341 |
-
|
| 342 |
-
/* Thinking Animation */
|
| 343 |
-
.thinking {
|
| 344 |
-
display: inline-flex;
|
| 345 |
-
gap: 0.25rem;
|
| 346 |
-
align-items: center;
|
| 347 |
-
}
|
| 348 |
-
.thinking span {
|
| 349 |
-
width: 8px;
|
| 350 |
-
height: 8px;
|
| 351 |
-
background: #3b82f6;
|
| 352 |
-
border-radius: 50%;
|
| 353 |
-
animation: bounce 1.4s infinite ease-in-out both;
|
| 354 |
-
}
|
| 355 |
-
.thinking span:nth-child(1) { animation-delay: -0.32s; }
|
| 356 |
-
.thinking span:nth-child(2) { animation-delay: -0.16s; }
|
| 357 |
-
@keyframes bounce {
|
| 358 |
-
0%, 80%, 100% { transform: scale(0); }
|
| 359 |
-
40% { transform: scale(1); }
|
| 360 |
-
}
|
| 361 |
-
|
| 362 |
-
/* Code Copy Button */
|
| 363 |
-
.copy-btn {
|
| 364 |
-
position: absolute;
|
| 365 |
-
top: 0.5rem;
|
| 366 |
-
right: 0.5rem;
|
| 367 |
-
background: #334155;
|
| 368 |
-
border: none;
|
| 369 |
-
border-radius: 0.375rem;
|
| 370 |
-
padding: 0.25rem 0.5rem;
|
| 371 |
-
cursor: pointer;
|
| 372 |
-
font-size: 0.7rem;
|
| 373 |
-
color: #e2e8f0;
|
| 374 |
-
}
|
| 375 |
-
|
| 376 |
-
.copy-btn:hover {
|
| 377 |
-
background: #3b82f6;
|
| 378 |
-
}
|
| 379 |
|
| 380 |
-
/* Responsive */
|
| 381 |
-
@media (max-width: 768px) {
|
| 382 |
-
.message {
|
| 383 |
-
max-width: 95%;
|
| 384 |
-
}
|
| 385 |
-
.chat-container {
|
| 386 |
-
padding: 0.5rem;
|
| 387 |
-
}
|
| 388 |
-
#chatBox {
|
| 389 |
-
max-height: calc(100vh - 160px);
|
| 390 |
-
}
|
| 391 |
-
.bubble {
|
| 392 |
-
padding: 0.625rem 1rem;
|
| 393 |
-
font-size: 0.875rem;
|
| 394 |
-
}
|
| 395 |
-
}
|
| 396 |
|
| 397 |
-
/* RTL Support */
|
| 398 |
-
.rtl {
|
| 399 |
-
direction: rtl;
|
| 400 |
-
text-align: right;
|
| 401 |
-
}
|
| 402 |
-
.ltr {
|
| 403 |
-
direction: ltr;
|
| 404 |
-
text-align: left;
|
| 405 |
-
}
|
| 406 |
-
</style>
|
| 407 |
-
</head>
|
| 408 |
|
| 409 |
-
<body>
|
| 410 |
<!-- Sidebar -->
|
| 411 |
-
<aside id="sidebar"
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
<
|
|
|
|
| 416 |
</div>
|
| 417 |
-
<button id="sidebarToggle" class="md:hidden text-
|
| 418 |
-
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 419 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
| 420 |
</svg>
|
| 421 |
</button>
|
| 422 |
</div>
|
| 423 |
<nav class="p-4">
|
| 424 |
<ul class="space-y-2">
|
| 425 |
-
<li>
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
{% if user %}
|
| 430 |
-
<li>
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
{% else %}
|
| 433 |
-
<li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 434 |
{% endif %}
|
| 435 |
</ul>
|
| 436 |
{% if user %}
|
| 437 |
-
<div class="mt-
|
| 438 |
-
<div class="flex justify-between items-center mb-
|
| 439 |
-
<
|
| 440 |
-
<button id="newConversationBtn" class="text-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
</div>
|
| 442 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
</div>
|
| 444 |
{% endif %}
|
| 445 |
</nav>
|
| 446 |
</aside>
|
| 447 |
|
| 448 |
-
<!--
|
| 449 |
-
<div
|
| 450 |
-
<
|
| 451 |
-
|
| 452 |
-
<button id="mobileSidebarToggle" class="md:hidden text-gray-400 hover:text-white">
|
| 453 |
-
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 454 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"></path>
|
| 455 |
-
</svg>
|
| 456 |
-
</button>
|
| 457 |
-
<span id="conversationTitle" class="font-semibold text-white">{{ conversation_title | default('MGZon AI Assistant') }}</span>
|
| 458 |
-
<button id="clearBtn" class="text-gray-400 hover:text-red-400 transition-colors">
|
| 459 |
-
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 460 |
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5-4h4M3 7h18"></path>
|
| 461 |
-
</svg>
|
| 462 |
-
</button>
|
| 463 |
-
</div>
|
| 464 |
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
<div class="
|
| 470 |
-
<
|
| 471 |
-
<div class="prompt-card" data-prompt="Write a Python function to reverse a linked list with explanation">🐍 Reverse Linked List</div>
|
| 472 |
-
<div class="prompt-card" data-prompt="Design a real-time analytics architecture for 10,000 events/sec">🏗️ Real-time Analytics Design</div>
|
| 473 |
-
<div class="prompt-card" data-prompt="Draw a flowchart showing how WebSocket works with load balancer">📈 WebSocket Flowchart</div>
|
| 474 |
</div>
|
| 475 |
-
<div
|
| 476 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
</div>
|
| 478 |
-
</
|
| 479 |
|
| 480 |
<!-- Chat Area -->
|
| 481 |
-
<
|
| 482 |
-
<div id="
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
<
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 493 |
</svg>
|
| 494 |
-
|
| 495 |
-
<
|
| 496 |
-
|
| 497 |
-
|
|
|
|
| 498 |
</svg>
|
| 499 |
-
|
| 500 |
-
<
|
| 501 |
-
|
| 502 |
-
|
|
|
|
| 503 |
</svg>
|
| 504 |
-
|
| 505 |
-
<
|
| 506 |
-
|
| 507 |
-
|
|
|
|
| 508 |
</svg>
|
| 509 |
-
|
|
|
|
| 510 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
</div>
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
<input type="file" id="fileInput" accept="image/*" class="hidden">
|
| 515 |
-
<input type="file" id="audioInput" accept="audio/*" class="hidden">
|
| 516 |
-
</form>
|
| 517 |
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
</div>
|
| 522 |
-
|
|
|
|
|
|
|
| 523 |
|
| 524 |
<!-- Settings Modal -->
|
| 525 |
-
<div id="settingsModal" class="fixed inset-0 bg-black
|
| 526 |
-
<div class="bg-gray-800
|
| 527 |
<div class="flex justify-between items-center mb-4">
|
| 528 |
-
<h2 class="text-xl font-bold text-white">Settings</h2>
|
| 529 |
-
<button id="closeSettingsBtn" class="text-gray-400 hover:text-white">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 530 |
</div>
|
| 531 |
<form id="settingsForm" class="space-y-4">
|
| 532 |
-
<div>
|
| 533 |
-
<div
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
<
|
| 537 |
-
<div>
|
| 538 |
-
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
</form>
|
| 541 |
</div>
|
| 542 |
</div>
|
| 543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
<!-- Scripts -->
|
| 545 |
-
<script src="/static/js/chat.js?v=
|
| 546 |
-
|
| 547 |
-
// Initialize Mermaid
|
| 548 |
-
if (typeof mermaid !== 'undefined') {
|
| 549 |
-
mermaid.initialize({
|
| 550 |
-
startOnLoad: false,
|
| 551 |
-
theme: 'dark',
|
| 552 |
-
securityLevel: 'loose',
|
| 553 |
-
flowchart: { useMaxWidth: true, htmlLabels: true }
|
| 554 |
-
});
|
| 555 |
-
}
|
| 556 |
|
| 557 |
-
// Mobile sidebar toggle
|
| 558 |
-
const sidebar = document.getElementById('sidebar');
|
| 559 |
-
const mobileToggle = document.getElementById('mobileSidebarToggle');
|
| 560 |
-
const sidebarToggle = document.getElementById('sidebarToggle');
|
| 561 |
-
|
| 562 |
-
function openSidebar() { if (sidebar) sidebar.classList.add('open'); }
|
| 563 |
-
function closeSidebar() { if (sidebar) sidebar.classList.remove('open'); }
|
| 564 |
-
|
| 565 |
-
if (mobileToggle) mobileToggle.addEventListener('click', openSidebar);
|
| 566 |
-
if (sidebarToggle) sidebarToggle.addEventListener('click', closeSidebar);
|
| 567 |
-
|
| 568 |
-
if (sidebar) {
|
| 569 |
-
document.addEventListener('click', (e) => {
|
| 570 |
-
if (window.innerWidth < 768 && sidebar.classList.contains('open')) {
|
| 571 |
-
if (!sidebar.contains(e.target) && !mobileToggle?.contains(e.target)) {
|
| 572 |
-
closeSidebar();
|
| 573 |
-
}
|
| 574 |
-
}
|
| 575 |
-
});
|
| 576 |
-
}
|
| 577 |
|
| 578 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
{% if conversation_id %}
|
| 580 |
window.conversationId = "{{ conversation_id }}";
|
| 581 |
window.conversationTitle = "{{ conversation_title }}";
|
|
|
|
|
|
|
|
|
|
| 582 |
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 583 |
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
</body>
|
| 585 |
|
| 586 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" class="dark-theme">
|
| 3 |
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport"
|
| 7 |
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
| 8 |
<meta name="description"
|
| 9 |
content="Chat with MGZon Chatbot, an AI-powered tool for coding, analysis, and e-commerce queries. Supports text, image, and audio inputs." />
|
| 10 |
<meta name="keywords"
|
| 11 |
+
content="MGZon Chatbot, AI chatbot, code generation, DeepSeek, Gradio, FastAPI, e-commerce, programming, Mark Al-Asfar" />
|
| 12 |
<meta name="author" content="Mark Al-Asfar" />
|
| 13 |
<meta name="robots" content="index, follow" />
|
| 14 |
<title>MGZon Chatbot – AI Assistant</title>
|
| 15 |
+
<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml" />
|
| 16 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
|
| 17 |
<link rel="apple-touch-icon" href="/static/images/mg.svg" />
|
| 18 |
+
<!-- Open Graph -->
|
| 19 |
+
<meta property="og:title" content="MGZon Chatbot – AI Assistant" />
|
| 20 |
+
<!-- manifest for Android/Chrome -->
|
| 21 |
+
<link rel="manifest" href="/static/manifest.json">
|
| 22 |
+
|
| 23 |
+
<!-- iOS Web App Support -->
|
| 24 |
+
<link rel="apple-touch-icon" sizes="180x180" href="/static/images/icons/mg-180.png">
|
| 25 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 26 |
+
<meta name="apple-mobile-web-app-title" content="MGZon">
|
| 27 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
| 28 |
+
|
| 29 |
+
<!-- General Theme -->
|
| 30 |
+
<meta name="theme-color" content="#2d3748">
|
| 31 |
+
|
| 32 |
+
<meta property="og:description"
|
| 33 |
+
content="Chat with MGZon Chatbot for coding, analysis, and e-commerce queries with text, image, and audio support." />
|
| 34 |
+
<meta property="og:image" content="/static/images/mg.svg" />
|
| 35 |
+
<meta property="og:url" content="https://mgzon-mgzon-app.hf.space/chat" />
|
| 36 |
+
<meta property="og:type" content="website" />
|
| 37 |
+
<!-- Twitter Card -->
|
| 38 |
+
<meta name="twitter:card" content="summary_large_image" />
|
| 39 |
+
<meta name="twitter:title" content="MGZon Chatbot – AI Assistant" />
|
| 40 |
+
<meta name="twitter:description"
|
| 41 |
+
content="Chat with MGZon Chatbot for coding, analysis, and e-commerce queries with text, image, and audio support." />
|
| 42 |
+
<meta name="twitter:image" content="/static/images/mg.svg" />
|
| 43 |
+
<!-- JSON-LD -->
|
| 44 |
+
<script type="application/ld+json">
|
| 45 |
+
{
|
| 46 |
+
"@context": "https://schema.org",
|
| 47 |
+
"@type": "WebPage",
|
| 48 |
+
"name": "MGZon Chatbot",
|
| 49 |
+
"url": "https://mgzon-mgzon-app.hf.space/chat",
|
| 50 |
+
"description": "An AI-powered chatbot for coding, analysis, and e-commerce queries."
|
| 51 |
+
}
|
| 52 |
+
</script>
|
| 53 |
+
<!-- Fonts & Styles -->
|
| 54 |
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
| 55 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap"
|
| 56 |
+
rel="stylesheet" />
|
| 57 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
| 58 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 59 |
+
<!-- Markdown & Syntax Highlight -->
|
|
|
|
| 60 |
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
|
|
| 61 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" />
|
| 62 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
|
| 63 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
| 64 |
+
<!-- Animations -->
|
| 65 |
+
<script src="https://cdn.jsdelivr.net/npm/aos@2.3.4/dist/aos.js"></script>
|
| 66 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aos@2.3.4/dist/aos.css" />
|
| 67 |
+
<!-- Carousel -->
|
| 68 |
+
<script src="https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/js/splide.min.js"></script>
|
| 69 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@splidejs/splide@4.1.4/dist/css/splide.min.css" />
|
| 70 |
+
<!-- Smooth Scroll -->
|
| 71 |
+
<script src="https://cdn.jsdelivr.net/npm/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.js"></script>
|
| 72 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll@4.1.4/dist/locomotive-scroll.min.css" />
|
| 73 |
+
<!-- Hammer.js for touch gestures -->
|
| 74 |
<script src="https://cdn.jsdelivr.net/npm/hammerjs@2.0.8/hammer.min.js"></script>
|
| 75 |
+
<!-- Project-Specific Styles -->
|
| 76 |
+
<link rel="stylesheet" href="/static/css/animation/style.css" />
|
| 77 |
+
<link rel="stylesheet" href="/static/css/button.css" />
|
| 78 |
+
<link rel="stylesheet" href="/static/css/chat/bubble.css" />
|
| 79 |
+
<link rel="stylesheet" href="/static/css/chat/markdown.css" />
|
| 80 |
+
<link rel="stylesheet" href="/static/css/chat/style.css" />
|
| 81 |
+
<link rel="stylesheet" href="/static/css/header.css" />
|
| 82 |
+
<link rel="stylesheet" href="/static/css/icon.css" />
|
| 83 |
+
<link rel="stylesheet" href="/static/css/input.css" />
|
| 84 |
+
<link rel="stylesheet" href="/static/css/logo.css" />
|
| 85 |
+
<link rel="stylesheet" href="/static/css/prompts.css" />
|
| 86 |
+
<link rel="stylesheet" href="/static/css/screen/1200.css" />
|
| 87 |
+
<link rel="stylesheet" href="/static/css/screen/2000.css" />
|
| 88 |
+
<link rel="stylesheet" href="/static/css/screen/320.css" />
|
| 89 |
+
<link rel="stylesheet" href="/static/css/screen/360.css" />
|
| 90 |
+
<link rel="stylesheet" href="/static/css/screen/3840.css" />
|
| 91 |
+
<link rel="stylesheet" href="/static/css/screen/480.css" />
|
| 92 |
+
<link rel="stylesheet" href="/static/css/screen/720.css" />
|
| 93 |
+
<link rel="stylesheet" href="/static/css/screen/7680.css" />
|
| 94 |
+
<link rel="stylesheet" href="/static/css/screen/common.css" />
|
| 95 |
+
<link rel="stylesheet" href="/static/css/style.css" />
|
| 96 |
+
<link rel="stylesheet" href="/static/css/webkit.css" />
|
| 97 |
+
<link rel="stylesheet" href="/static/css/sidebar.css" />
|
| 98 |
+
<!-- Preload Resources -->
|
| 99 |
+
<link rel="preload" href="/static/js/chat.js" as="script">
|
| 100 |
+
<link rel="preload" href="/static/css/chat/style.css" as="style">
|
| 101 |
+
<link rel="preload" href="/static/images/mg.svg" as="image">
|
| 102 |
+
<link rel="preload" href="https://raw.githubusercontent.com/4gels/icons/refs/heads/main/splash-screen.png" as="image">
|
| 103 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js"></script>
|
| 104 |
+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
| 105 |
|
| 106 |
+
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
+
<body class="min-h-screen flex flex-col bg-gradient-to-br from-gray-900 via-teal-900 to-emerald-900">
|
| 111 |
<!-- Sidebar -->
|
| 112 |
+
<aside id="sidebar"
|
| 113 |
+
class="fixed inset-y-0 left-0 w-64 bg-gray-800/90 backdrop-blur-md transform -translate-x-full md:translate-x-0 transition-transform duration-300 ease-in-out z-50">
|
| 114 |
+
<div class="flex items-center justify-between p-4 border-b border-gray-700">
|
| 115 |
+
<div class="flex items-center">
|
| 116 |
+
<img src="/static/images/mg.svg" alt="MGZon Logo" class="w-10 h-10 mr-2 animate-pulse" />
|
| 117 |
+
<h2 class="text-lg font-bold text-white">MGZon</h2>
|
| 118 |
</div>
|
| 119 |
+
<button id="sidebarToggle" class="md:hidden text-white" aria-label="Close Sidebar">
|
| 120 |
+
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
| 121 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
| 122 |
</svg>
|
| 123 |
</button>
|
| 124 |
</div>
|
| 125 |
<nav class="p-4">
|
| 126 |
<ul class="space-y-2">
|
| 127 |
+
<li>
|
| 128 |
+
<a href="/" class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors">
|
| 129 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 130 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 131 |
+
<path d="M3 11.5L12 4l9 7.5M5 21V11.5h14V21"></path>
|
| 132 |
+
</svg>
|
| 133 |
+
Home
|
| 134 |
+
</a>
|
| 135 |
+
</li>
|
| 136 |
+
<li>
|
| 137 |
+
<a href="/about" class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors">
|
| 138 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 139 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 140 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 141 |
+
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
| 142 |
+
</svg>
|
| 143 |
+
About
|
| 144 |
+
</a>
|
| 145 |
+
</li>
|
| 146 |
+
<li>
|
| 147 |
+
<a href="/blog" class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors">
|
| 148 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 149 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 150 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 151 |
+
d="M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 006 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25">
|
| 152 |
+
</path>
|
| 153 |
+
</svg>
|
| 154 |
+
Blog
|
| 155 |
+
</a>
|
| 156 |
+
</li>
|
| 157 |
+
<li>
|
| 158 |
+
<a href="/docs" class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors">
|
| 159 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 160 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 161 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 162 |
+
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z">
|
| 163 |
+
</path>
|
| 164 |
+
</svg>
|
| 165 |
+
Docs
|
| 166 |
+
</a>
|
| 167 |
+
</li>
|
| 168 |
{% if user %}
|
| 169 |
+
<li>
|
| 170 |
+
<button id="settingsBtn"
|
| 171 |
+
class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors w-full text-left">
|
| 172 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 173 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 174 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 175 |
+
d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4">
|
| 176 |
+
</path>
|
| 177 |
+
</svg>
|
| 178 |
+
Settings
|
| 179 |
+
</button>
|
| 180 |
+
</li>
|
| 181 |
+
<li>
|
| 182 |
+
<button id="logoutBtn"
|
| 183 |
+
class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors w-full text-left">
|
| 184 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 185 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 186 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 187 |
+
d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path>
|
| 188 |
+
</svg>
|
| 189 |
+
Logout
|
| 190 |
+
</button>
|
| 191 |
+
</li>
|
| 192 |
{% else %}
|
| 193 |
+
<li>
|
| 194 |
+
<a href="/login" class="flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors">
|
| 195 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 196 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 197 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 198 |
+
d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"></path>
|
| 199 |
+
</svg>
|
| 200 |
+
Login
|
| 201 |
+
</a>
|
| 202 |
+
</li>
|
| 203 |
{% endif %}
|
| 204 |
</ul>
|
| 205 |
{% if user %}
|
| 206 |
+
<div class="mt-4">
|
| 207 |
+
<div class="flex justify-between items-center px-2 mb-2">
|
| 208 |
+
<h3 class="text-sm font-semibold text-white">Conversations</h3>
|
| 209 |
+
<button id="newConversationBtn" class="text-white hover:bg-gray-700 p-1 rounded" title="New Conversation">
|
| 210 |
+
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 211 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 212 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
| 213 |
+
</svg>
|
| 214 |
+
</button>
|
| 215 |
</div>
|
| 216 |
+
<button id="historyToggle"
|
| 217 |
+
class="md:hidden flex items-center text-white hover:bg-gray-700 p-2 rounded transition-colors w-full text-left">
|
| 218 |
+
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"
|
| 219 |
+
xmlns="http://www.w3.org/2000/svg">
|
| 220 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
| 221 |
+
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
| 222 |
+
</svg>
|
| 223 |
+
Show History
|
| 224 |
+
</button>
|
| 225 |
+
<ul id="conversationList" class="space-y-2 max-h-[calc(100vh-300px)] overflow-y-auto hidden md:block">
|
| 226 |
+
<!-- Conversations will be populated by JavaScript -->
|
| 227 |
+
</ul>
|
| 228 |
</div>
|
| 229 |
{% endif %}
|
| 230 |
</nav>
|
| 231 |
</aside>
|
| 232 |
|
| 233 |
+
<!-- Swipe Hint for Mobile -->
|
| 234 |
+
<div id="swipeHint" class="md:hidden fixed top-1/2 left-4 z-50 animate-pulse">
|
| 235 |
+
<img src="/static/images/swipe-hint.svg" alt="Swipe to open sidebar" class="w-8 h-8" />
|
| 236 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
|
| 238 |
+
<!-- Main Content -->
|
| 239 |
+
<div class="flex-1 flex flex-col max-w-screen-xl w-full mx-auto md:ml-64">
|
| 240 |
+
<!-- Chat Header -->
|
| 241 |
+
<header class="chat-header p-3 flex justify-between items-center">
|
| 242 |
+
<div class="chat-title text-xl font-semibold text-white">
|
| 243 |
+
<span id="conversationTitle">{{ conversation_title | default('MGZon AI Assistant') }}</span>
|
|
|
|
|
|
|
|
|
|
| 244 |
</div>
|
| 245 |
+
<div class="chat-controls flex gap-2">
|
| 246 |
+
<button id="clearBtn" class="icon-btn" aria-label="Clear All Messages" title="Clear All Messages">
|
| 247 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"
|
| 248 |
+
stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
| 249 |
+
<path d="M3 6h18" />
|
| 250 |
+
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
|
| 251 |
+
<path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6" />
|
| 252 |
+
<path d="M10 11v6" />
|
| 253 |
+
<path d="M14 11v6" />
|
| 254 |
+
</svg>
|
| 255 |
+
</button>
|
| 256 |
+
<button id="themeToggle" class="icon-btn" aria-label="Toggle Theme" title="Toggle Theme">
|
| 257 |
+
🌙
|
| 258 |
+
</button>
|
| 259 |
</div>
|
| 260 |
+
</header>
|
| 261 |
|
| 262 |
<!-- Chat Area -->
|
| 263 |
+
<main class="flex-1 flex flex-col">
|
| 264 |
+
<div id="initialContent" class="flex flex-col items-center justify-center text-center h-full">
|
| 265 |
+
<div class="title mb-4 gradient-text text-3xl font-bold">
|
| 266 |
+
How can I help you today?
|
| 267 |
+
</div>
|
| 268 |
+
<p class="system text-gray-300 mb-4">
|
| 269 |
+
A versatile chatbot powered by DeepSeek, GPT-OSS, CLIP, Whisper, and TTS.<br>
|
| 270 |
+
Type your query, upload images/files, or hold the send button to record audio!
|
| 271 |
+
</p>
|
| 272 |
+
<!-- Prompts -->
|
| 273 |
+
<div class="prompts w-full max-w-md mx-auto grid gap-2">
|
| 274 |
+
<div class="prompt-item" data-prompt="What's the capital of France?">
|
| 275 |
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 276 |
+
<path
|
| 277 |
+
d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M18.66 18.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M18.66 5.34l1.41-1.41"
|
| 278 |
+
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
| 279 |
+
<circle cx="12" cy="12" r="4" stroke-width="2" />
|
| 280 |
</svg>
|
| 281 |
+
<span>What's the capital of France?</span>
|
| 282 |
+
</div>
|
| 283 |
+
<div class="prompt-item" data-prompt="Generate a Python script for a simple web server">
|
| 284 |
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 285 |
+
<path d="M4 7h16M4 12h16M4 17h16" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
| 286 |
</svg>
|
| 287 |
+
<span>Generate a Python script for a simple web server</span>
|
| 288 |
+
</div>
|
| 289 |
+
<div class="prompt-item" data-prompt="Analyze this image for me">
|
| 290 |
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 291 |
+
<path d="M3 12h18M12 3v18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
| 292 |
</svg>
|
| 293 |
+
<span>Analyze this image for me</span>
|
| 294 |
+
</div>
|
| 295 |
+
<div class="prompt-item" data-prompt="Convert this text to audio">
|
| 296 |
+
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
| 297 |
+
<path d="M12 3v18M7 12h10" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
| 298 |
</svg>
|
| 299 |
+
<span>Convert this text to audio</span>
|
| 300 |
+
</div>
|
| 301 |
</div>
|
| 302 |
+
<div id="messageLimitWarning" class="text-red-500 text-center hidden mt-4">
|
| 303 |
+
You have reached the message limit. Please <a href="/login" class="text-blue-300 underline">login</a> to
|
| 304 |
+
continue.
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
<div id="chatArea" class="flex-1 overflow-y-auto hidden" aria-live="polite">
|
| 308 |
+
<div id="chatBox" class="flex flex-col w-full" aria-live="polite"></div>
|
| 309 |
</div>
|
| 310 |
+
</main>
|
| 311 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
+
<!-- Footer Form (منقول خارج main) -->
|
| 314 |
+
<form id="footerForm" class="flex p-4">
|
| 315 |
+
<div id="inputContainer" class="w-full">
|
| 316 |
+
<textarea id="userInput" placeholder="Ask anything..." required></textarea>
|
| 317 |
+
<div id="rightIconGroup" class="flex gap-2">
|
| 318 |
+
<button type="button" id="fileBtn" class="icon-btn" aria-label="Upload File" title="Upload File">
|
| 319 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"
|
| 320 |
+
stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
| 321 |
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
|
| 322 |
+
<path d="M14 2v6h6" />
|
| 323 |
+
</svg>
|
| 324 |
+
</button>
|
| 325 |
+
<input type="file" id="fileInput" accept="image/*,.mp3,.wav" style="display: none;" />
|
| 326 |
+
<button type="button" id="audioBtn" class="icon-btn" aria-label="Upload Audio File" title="Upload Audio File">
|
| 327 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"
|
| 328 |
+
stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
|
| 329 |
+
<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" />
|
| 330 |
+
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
|
| 331 |
+
<path d="M12 19v4" />
|
| 332 |
+
</svg>
|
| 333 |
+
</button>
|
| 334 |
+
<input type="file" id="audioInput" accept="audio/*" style="display: none;" />
|
| 335 |
+
<button type="submit" id="sendBtn" class="icon-btn" disabled aria-label="Send or Hold to Record"
|
| 336 |
+
title="Click to Send or Hold to Record Voice">
|
| 337 |
+
<svg id="sendIcon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 338 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7-7 7M3 12h11" />
|
| 339 |
+
</svg>
|
| 340 |
+
</button>
|
| 341 |
+
<button id="stopBtn" class="icon-btn" aria-label="Stop" title="Stop" style="display: none;">
|
| 342 |
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg">
|
| 343 |
+
<rect x="6" y="6" width="12" height="12" rx="2" fill="white" />
|
| 344 |
+
</svg>
|
| 345 |
+
</button>
|
| 346 |
+
</div>
|
| 347 |
</div>
|
| 348 |
+
<div id="filePreview" class="upload-preview" style="display: none;"></div>
|
| 349 |
+
<div id="audioPreview" class="audio-preview" style="display: none;"></div>
|
| 350 |
+
</form>
|
| 351 |
|
| 352 |
<!-- Settings Modal -->
|
| 353 |
+
<div id="settingsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 354 |
+
<div class="bg-gray-800 p-6 rounded-lg w-full max-w-md">
|
| 355 |
<div class="flex justify-between items-center mb-4">
|
| 356 |
+
<h2 class="text-xl font-bold text-white">User Settings</h2>
|
| 357 |
+
<button id="closeSettingsBtn" class="text-gray-400 hover:text-white">
|
| 358 |
+
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
| 359 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
| 360 |
+
</svg>
|
| 361 |
+
</button>
|
| 362 |
</div>
|
| 363 |
<form id="settingsForm" class="space-y-4">
|
| 364 |
+
<div>
|
| 365 |
+
<div id="user-info">Loading...</div>
|
| 366 |
+
<label for="display_name" class="block text-sm text-gray-300">Display Name</label>
|
| 367 |
+
<input type="text" id="display_name" name="display_name" class="w-full p-2 bg-gray-700 text-white rounded">
|
| 368 |
+
</div>
|
| 369 |
+
<div>
|
| 370 |
+
<label for="preferred_model" class="block text-sm text-gray-300">Preferred Model</label>
|
| 371 |
+
<select id="preferred_model" name="preferred_model" class="w-full p-2 bg-gray-700 text-white rounded">
|
| 372 |
+
<option value="">Default</option>
|
| 373 |
+
<option value="advanced">Advanced (High-performance)</option>
|
| 374 |
+
<option value="standard">Standard (Balanced)</option>
|
| 375 |
+
<option value="light">Light (Quick)</option>
|
| 376 |
+
</select>
|
| 377 |
+
</div>
|
| 378 |
+
<div>
|
| 379 |
+
<label for="job_title" class="block text-sm text-gray-300">Job Title</label>
|
| 380 |
+
<input type="text" id="job_title" name="job_title" class="w-full p-2 bg-gray-700 text-white rounded">
|
| 381 |
+
</div>
|
| 382 |
+
<div>
|
| 383 |
+
<label for="education" class="block text-sm text-gray-300">Education</label>
|
| 384 |
+
<input type="text" id="education" name="education" class="w-full p-2 bg-gray-700 text-white rounded">
|
| 385 |
+
</div>
|
| 386 |
+
<div>
|
| 387 |
+
<label for="interests" class="block text-sm text-gray-300">Interests</label>
|
| 388 |
+
<textarea id="interests" name="interests" class="w-full p-2 bg-gray-700 text-white rounded"></textarea>
|
| 389 |
+
</div>
|
| 390 |
+
<div>
|
| 391 |
+
<label for="additional_info" class="block text-sm text-gray-300">Additional Info</label>
|
| 392 |
+
<textarea id="additional_info" name="additional_info"
|
| 393 |
+
class="w-full p-2 bg-gray-700 text-white rounded"></textarea>
|
| 394 |
+
</div>
|
| 395 |
+
<div>
|
| 396 |
+
<label for="conversation_style" class="block text-sm text-gray-300">Conversation Style</label>
|
| 397 |
+
<select id="conversation_style" name="conversation_style" class="w-full p-2 bg-gray-700 text-white rounded">
|
| 398 |
+
<option value="default">Default</option>
|
| 399 |
+
<option value="concise">Concise</option>
|
| 400 |
+
<option value="analytical">Analytical</option>
|
| 401 |
+
<option value="creative">Creative</option>
|
| 402 |
+
</select>
|
| 403 |
+
</div>
|
| 404 |
+
<div class="flex justify-end gap-2">
|
| 405 |
+
<button type="button" id="closeSettingsBtn" class="px-4 py-2 bg-gray-600 text-white rounded">Cancel</button>
|
| 406 |
+
<button type="submit" class="px-4 py-2 bg-blue-600 text-white rounded">Save</button>
|
| 407 |
+
</div>
|
| 408 |
</form>
|
| 409 |
</div>
|
| 410 |
</div>
|
| 411 |
|
| 412 |
+
<!-- Copyright -->
|
| 413 |
+
<div class="text-center text-xs text-gray-400 py-2">
|
| 414 |
+
© 2025 Mark Al-Asfar & MGZon AI. All rights reserved.
|
| 415 |
+
</div>
|
| 416 |
+
<!-- Install Button -->
|
| 417 |
+
<button id="installAppBtn" style="display: none;"
|
| 418 |
+
class="fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded shadow-lg z-50">
|
| 419 |
+
📲 Install MG Chat
|
| 420 |
+
</button>
|
| 421 |
+
<!-- PWA Install Instructions -->
|
| 422 |
+
<div id="pwa-instructions" class="fixed bottom-4 left-4 right-4 bg-blue-600 text-white p-4 rounded-lg z-50 hidden">
|
| 423 |
+
<p><strong>Add to Home Screen:</strong> Tap the share button in your browser, then "Add to Home Screen" for a
|
| 424 |
+
native-like experience!</p>
|
| 425 |
+
<button onclick="document.getElementById('pwa-instructions').classList.add('hidden')"
|
| 426 |
+
class="ml-2 text-sm">Close</button>
|
| 427 |
+
</div>
|
| 428 |
+
|
| 429 |
<!-- Scripts -->
|
| 430 |
+
<script src="/static/js/chat.js?v=1.2"></script>
|
| 431 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 433 |
|
| 434 |
+
<script>
|
| 435 |
+
// تهيئة مكتبة AOS
|
| 436 |
+
AOS.init();
|
| 437 |
+
|
| 438 |
+
// تمرير conversation_id و conversation_title إذا كانا موجودين
|
| 439 |
{% if conversation_id %}
|
| 440 |
window.conversationId = "{{ conversation_id }}";
|
| 441 |
window.conversationTitle = "{{ conversation_title }}";
|
| 442 |
+
if (window.loadConversation) {
|
| 443 |
+
window.loadConversation("{{ conversation_id }}");
|
| 444 |
+
}
|
| 445 |
{% endif %}
|
| 446 |
+
|
| 447 |
+
// تسجيل Service Worker لتفعيل الـ PWA
|
| 448 |
+
if ('serviceWorker' in navigator) {
|
| 449 |
+
navigator.serviceWorker.register('/static/js/sw.js')
|
| 450 |
+
.then(function (reg) {
|
| 451 |
+
console.log('✅ Service Worker Registered', reg);
|
| 452 |
+
}).catch(function (err) {
|
| 453 |
+
console.error('❌ Service Worker registration failed', err);
|
| 454 |
+
});
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
// التعامل مع حدث beforeinstallprompt لتثبيت التطبيق
|
| 458 |
+
let deferredPrompt;
|
| 459 |
+
window.addEventListener('beforeinstallprompt', (e) => {
|
| 460 |
+
e.preventDefault();
|
| 461 |
+
deferredPrompt = e;
|
| 462 |
+
const installBtn = document.getElementById('installAppBtn');
|
| 463 |
+
if (installBtn) {
|
| 464 |
+
installBtn.style.display = 'block';
|
| 465 |
+
installBtn.addEventListener('click', () => {
|
| 466 |
+
deferredPrompt.prompt();
|
| 467 |
+
deferredPrompt.userChoice.then(choice => {
|
| 468 |
+
if (choice.outcome === 'accepted') {
|
| 469 |
+
console.log('✅ User accepted the install prompt');
|
| 470 |
+
} else {
|
| 471 |
+
console.log('❌ User dismissed the install prompt');
|
| 472 |
+
}
|
| 473 |
+
deferredPrompt = null;
|
| 474 |
+
});
|
| 475 |
+
});
|
| 476 |
+
}
|
| 477 |
+
});
|
| 478 |
+
|
| 479 |
+
// Show PWA instructions on first visit
|
| 480 |
+
if (localStorage.getItem('pwa-instructions-shown') !== 'true') {
|
| 481 |
+
document.getElementById('pwa-instructions').classList.remove('hidden');
|
| 482 |
+
localStorage.setItem('pwa-instructions-shown', 'true');
|
| 483 |
+
}
|
| 484 |
</script>
|
| 485 |
+
|
| 486 |
+
<!-- Mermaid.js for diagrams -->
|
| 487 |
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
|
| 488 |
+
<script>
|
| 489 |
+
mermaid.initialize({
|
| 490 |
+
startOnLoad: false,
|
| 491 |
+
theme: 'dark',
|
| 492 |
+
securityLevel: 'loose',
|
| 493 |
+
flowchart: { useMaxWidth: true, htmlLabels: true },
|
| 494 |
+
sequence: { useMaxWidth: true }
|
| 495 |
+
});
|
| 496 |
+
</script>
|
| 497 |
+
|
| 498 |
</body>
|
| 499 |
|
| 500 |
</html>
|