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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="vi">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Dạ Hành AI Studio</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary-color: #00ff88;
|
| 10 |
+
--bg-color: #121212;
|
| 11 |
+
--chat-bg: #1e1e1e;
|
| 12 |
+
--user-msg-bg: #2a2a2a;
|
| 13 |
+
--ai-msg-bg: #0a3a2a;
|
| 14 |
+
}
|
| 15 |
+
body {
|
| 16 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 17 |
+
background-color: var(--bg-color);
|
| 18 |
+
color: white;
|
| 19 |
+
margin: 0;
|
| 20 |
+
display: flex;
|
| 21 |
+
height: 100vh;
|
| 22 |
+
}
|
| 23 |
+
.sidebar {
|
| 24 |
+
width: 250px;
|
| 25 |
+
background-color: #000;
|
| 26 |
+
padding: 20px;
|
| 27 |
+
border-right: 1px solid #333;
|
| 28 |
+
display: flex;
|
| 29 |
+
flex-direction: column;
|
| 30 |
+
}
|
| 31 |
+
.main {
|
| 32 |
+
flex: 1;
|
| 33 |
+
display: flex;
|
| 34 |
+
flex-direction: column;
|
| 35 |
+
padding: 20px;
|
| 36 |
+
}
|
| 37 |
+
h1 { font-size: 1.2rem; color: var(--primary-color); margin-bottom: 20px; }
|
| 38 |
+
.bot-selector {
|
| 39 |
+
margin-bottom: 20px;
|
| 40 |
+
}
|
| 41 |
+
select {
|
| 42 |
+
width: 100%;
|
| 43 |
+
padding: 10px;
|
| 44 |
+
background: #333;
|
| 45 |
+
color: white;
|
| 46 |
+
border: 1px solid #555;
|
| 47 |
+
border-radius: 5px;
|
| 48 |
+
}
|
| 49 |
+
#chat-box {
|
| 50 |
+
flex: 1;
|
| 51 |
+
overflow-y: auto;
|
| 52 |
+
border: 1px solid #333;
|
| 53 |
+
background: var(--chat-bg);
|
| 54 |
+
border-radius: 10px;
|
| 55 |
+
padding: 20px;
|
| 56 |
+
margin-bottom: 20px;
|
| 57 |
+
display: flex;
|
| 58 |
+
flex-direction: column;
|
| 59 |
+
gap: 15px;
|
| 60 |
+
}
|
| 61 |
+
.message {
|
| 62 |
+
max-width: 80%;
|
| 63 |
+
padding: 10px 15px;
|
| 64 |
+
border-radius: 15px;
|
| 65 |
+
line-height: 1.5;
|
| 66 |
+
}
|
| 67 |
+
.message.ai {
|
| 68 |
+
align-self: flex-start;
|
| 69 |
+
background-color: var(--ai-msg-bg);
|
| 70 |
+
border-bottom-left-radius: 2px;
|
| 71 |
+
}
|
| 72 |
+
.message.user {
|
| 73 |
+
align-self: flex-end;
|
| 74 |
+
background-color: var(--user-msg-bg);
|
| 75 |
+
border-bottom-right-radius: 2px;
|
| 76 |
+
color: #ddd;
|
| 77 |
+
}
|
| 78 |
+
.input-area {
|
| 79 |
+
display: flex;
|
| 80 |
+
gap: 10px;
|
| 81 |
+
}
|
| 82 |
+
input[type="text"] {
|
| 83 |
+
flex: 1;
|
| 84 |
+
padding: 15px;
|
| 85 |
+
border-radius: 25px;
|
| 86 |
+
border: 1px solid #444;
|
| 87 |
+
background: #222;
|
| 88 |
+
color: white;
|
| 89 |
+
outline: none;
|
| 90 |
+
}
|
| 91 |
+
button {
|
| 92 |
+
padding: 10px 25px;
|
| 93 |
+
border-radius: 25px;
|
| 94 |
+
border: none;
|
| 95 |
+
background: var(--primary-color);
|
| 96 |
+
color: black;
|
| 97 |
+
font-weight: bold;
|
| 98 |
+
cursor: pointer;
|
| 99 |
+
transition: 0.2s;
|
| 100 |
+
}
|
| 101 |
+
button:hover { background: #00cc6a; }
|
| 102 |
+
.loading { font-style: italic; color: #888; font-size: 0.9rem; }
|
| 103 |
+
</style>
|
| 104 |
+
</head>
|
| 105 |
+
<body>
|
| 106 |
+
|
| 107 |
+
<div class="sidebar">
|
| 108 |
+
<h1>DẠ HÀNH STUDIO</h1>
|
| 109 |
+
<div class="bot-selector">
|
| 110 |
+
<label>Chọn Bot:</label>
|
| 111 |
+
<select id="role-select">
|
| 112 |
+
<option value="talk2people">Talk2People (Đạo diễn)</option>
|
| 113 |
+
<option value="coder">Coder Expert</option>
|
| 114 |
+
<option value="default">Trợ lý cơ bản</option>
|
| 115 |
+
</select>
|
| 116 |
+
</div>
|
| 117 |
+
<div style="margin-top: auto; font-size: 0.8rem; color: #666;">
|
| 118 |
+
Running on Qwen 1.7B<br>Local Privacy First
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<div class="main">
|
| 123 |
+
<div id="chat-box">
|
| 124 |
+
<!-- Messages go here -->
|
| 125 |
+
</div>
|
| 126 |
+
<div class="input-area">
|
| 127 |
+
<input type="text" id="user-input" placeholder="Nhập tin nhắn..." autocomplete="off">
|
| 128 |
+
<button onclick="sendMessage()">Gửi</button>
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
|
| 132 |
+
<script>
|
| 133 |
+
const chatBox = document.getElementById('chat-box');
|
| 134 |
+
const userInput = document.getElementById('user-input');
|
| 135 |
+
const roleSelect = document.getElementById('role-select');
|
| 136 |
+
let chatHistory = [];
|
| 137 |
+
|
| 138 |
+
// Load Welcome Message
|
| 139 |
+
async function init() {
|
| 140 |
+
try {
|
| 141 |
+
const res = await fetch('/info');
|
| 142 |
+
const data = await res.json();
|
| 143 |
+
addMessage('ai', data.welcome);
|
| 144 |
+
} catch (e) {
|
| 145 |
+
addMessage('ai', "Xin chào đây là hệ thống bot AI hoạt động riêng tư được đào tạo bởi Dạ Hành Studio , Ko phụ thuộc vào Google");
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
function addMessage(role, text) {
|
| 150 |
+
const div = document.createElement('div');
|
| 151 |
+
div.className = `message ${role}`;
|
| 152 |
+
div.textContent = text; // Safe text
|
| 153 |
+
chatBox.appendChild(div);
|
| 154 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
async function sendMessage() {
|
| 158 |
+
const text = userInput.value.trim();
|
| 159 |
+
if (!text) return;
|
| 160 |
+
|
| 161 |
+
addMessage('user', text);
|
| 162 |
+
userInput.value = '';
|
| 163 |
+
chatHistory.push({ role: 'user', content: text });
|
| 164 |
+
|
| 165 |
+
// Show loading
|
| 166 |
+
const loadingDiv = document.createElement('div');
|
| 167 |
+
loadingDiv.className = 'message ai loading';
|
| 168 |
+
loadingDiv.textContent = 'Đang suy nghĩ...';
|
| 169 |
+
chatBox.appendChild(loadingDiv);
|
| 170 |
+
|
| 171 |
+
try {
|
| 172 |
+
const response = await fetch('/chat', {
|
| 173 |
+
method: 'POST',
|
| 174 |
+
headers: { 'Content-Type': 'application/json' },
|
| 175 |
+
body: JSON.stringify({
|
| 176 |
+
message: text,
|
| 177 |
+
history: chatHistory.slice(-10), // Keep last 10 messages
|
| 178 |
+
role: roleSelect.value
|
| 179 |
+
})
|
| 180 |
+
});
|
| 181 |
+
|
| 182 |
+
const data = await response.json();
|
| 183 |
+
|
| 184 |
+
chatBox.removeChild(loadingDiv); // Remove loading
|
| 185 |
+
addMessage('ai', data.reply);
|
| 186 |
+
chatHistory.push({ role: 'ai', content: data.reply });
|
| 187 |
+
|
| 188 |
+
} catch (error) {
|
| 189 |
+
chatBox.removeChild(loadingDiv);
|
| 190 |
+
addMessage('ai', 'Lỗi kết nối: ' + error.message);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
userInput.addEventListener('keypress', (e) => {
|
| 195 |
+
if (e.key === 'Enter') sendMessage();
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
// Reset history when role changes
|
| 199 |
+
roleSelect.addEventListener('change', () => {
|
| 200 |
+
chatHistory = [];
|
| 201 |
+
chatBox.innerHTML = '';
|
| 202 |
+
init(); // Show welcome again
|
| 203 |
+
});
|
| 204 |
+
|
| 205 |
+
init();
|
| 206 |
+
</script>
|
| 207 |
+
|
| 208 |
+
</body>
|
| 209 |
+
</html>
|