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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Advanced AI Assistant</title>
|
7 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
8 |
+
<style>
|
9 |
+
* {
|
10 |
+
margin: 0;
|
11 |
+
padding: 0;
|
12 |
+
box-sizing: border-box;
|
13 |
+
font-family: 'Inter', sans-serif;
|
14 |
+
}
|
15 |
+
body {
|
16 |
+
background: linear-gradient(135deg, #1a1a2e, #16213e);
|
17 |
+
color: #fff;
|
18 |
+
height: 100vh;
|
19 |
+
display: flex;
|
20 |
+
justify-content: center;
|
21 |
+
align-items: center;
|
22 |
+
line-height: 1.6;
|
23 |
+
}
|
24 |
+
.container {
|
25 |
+
width: 95%;
|
26 |
+
max-width: 1200px;
|
27 |
+
display: flex;
|
28 |
+
gap: 20px;
|
29 |
+
height: 90vh;
|
30 |
+
}
|
31 |
+
.chat-container {
|
32 |
+
flex: 2;
|
33 |
+
background: rgba(255, 255, 255, 0.05);
|
34 |
+
backdrop-filter: blur(10px);
|
35 |
+
border-radius: 20px;
|
36 |
+
overflow: hidden;
|
37 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
38 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
39 |
+
}
|
40 |
+
.suggestions {
|
41 |
+
flex: 1;
|
42 |
+
background: rgba(255, 255, 255, 0.03);
|
43 |
+
border-radius: 20px;
|
44 |
+
padding: 20px;
|
45 |
+
overflow-y: auto;
|
46 |
+
display: none;
|
47 |
+
}
|
48 |
+
@media (min-width: 1024px) {
|
49 |
+
.suggestions {
|
50 |
+
display: block;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
.suggestion-item {
|
54 |
+
padding: 10px;
|
55 |
+
background: rgba(255, 255, 255, 0.05);
|
56 |
+
border-radius: 10px;
|
57 |
+
margin-bottom: 10px;
|
58 |
+
cursor: pointer;
|
59 |
+
transition: all 0.3s;
|
60 |
+
}
|
61 |
+
.suggestion-item:hover {
|
62 |
+
background: rgba(255, 255, 255, 0.1);
|
63 |
+
transform: translateY(-2px);
|
64 |
+
}
|
65 |
+
.chat-header {
|
66 |
+
background: rgba(255, 255, 255, 0.05);
|
67 |
+
padding: 20px;
|
68 |
+
text-align: center;
|
69 |
+
font-weight: 600;
|
70 |
+
font-size: 1.2em;
|
71 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
72 |
+
}
|
73 |
+
.chat-box {
|
74 |
+
height: calc(90vh - 140px);
|
75 |
+
overflow-y: auto;
|
76 |
+
padding: 20px;
|
77 |
+
}
|
78 |
+
.message {
|
79 |
+
margin: 10px 0;
|
80 |
+
padding: 12px 16px;
|
81 |
+
border-radius: 15px;
|
82 |
+
max-width: 80%;
|
83 |
+
animation: fadeIn 0.3s ease-in;
|
84 |
+
position: relative;
|
85 |
+
font-size: 0.95em;
|
86 |
+
}
|
87 |
+
@keyframes fadeIn {
|
88 |
+
from { opacity: 0; transform: translateY(10px); }
|
89 |
+
to { opacity: 1; transform: translateY(0); }
|
90 |
+
}
|
91 |
+
.user-message {
|
92 |
+
background: #4a4af4;
|
93 |
+
margin-left: auto;
|
94 |
+
border-bottom-right-radius: 5px;
|
95 |
+
}
|
96 |
+
.ai-message {
|
97 |
+
background: rgba(255, 255, 255, 0.05);
|
98 |
+
margin-right: auto;
|
99 |
+
border-bottom-left-radius: 5px;
|
100 |
+
}
|
101 |
+
.typing-indicator {
|
102 |
+
display: none;
|
103 |
+
padding: 12px 16px;
|
104 |
+
background: rgba(255, 255, 255, 0.05);
|
105 |
+
border-radius: 15px;
|
106 |
+
margin: 10px 0;
|
107 |
+
width: fit-content;
|
108 |
+
}
|
109 |
+
.dot {
|
110 |
+
display: inline-block;
|
111 |
+
width: 6px;
|
112 |
+
height: 6px;
|
113 |
+
background: #fff;
|
114 |
+
border-radius: 50%;
|
115 |
+
margin-right: 3px;
|
116 |
+
animation: bounce 1s infinite;
|
117 |
+
}
|
118 |
+
.dot:nth-child(2) { animation-delay: 0.2s; }
|
119 |
+
.dot:nth-child(3) { animation-delay: 0.4s; }
|
120 |
+
@keyframes bounce {
|
121 |
+
0%, 100% { transform: translateY(0); }
|
122 |
+
50% { transform: translateY(-5px); }
|
123 |
+
}
|
124 |
+
.input-area {
|
125 |
+
padding: 20px;
|
126 |
+
background: rgba(255, 255, 255, 0.05);
|
127 |
+
display: flex;
|
128 |
+
gap: 10px;
|
129 |
+
align-items: center;
|
130 |
+
}
|
131 |
+
input {
|
132 |
+
flex: 1;
|
133 |
+
padding: 12px 16px;
|
134 |
+
border: none;
|
135 |
+
border-radius: 10px;
|
136 |
+
background: rgba(255, 255, 255, 0.1);
|
137 |
+
color: #fff;
|
138 |
+
font-size: 0.95em;
|
139 |
+
transition: all 0.3s;
|
140 |
+
}
|
141 |
+
input:focus {
|
142 |
+
outline: none;
|
143 |
+
background: rgba(255, 255, 255, 0.15);
|
144 |
+
box-shadow: 0 0 0 2px rgba(74, 74, 244, 0.3);
|
145 |
+
}
|
146 |
+
button {
|
147 |
+
padding: 12px 24px;
|
148 |
+
border: none;
|
149 |
+
border-radius: 10px;
|
150 |
+
background: #4a4af4;
|
151 |
+
color: #fff;
|
152 |
+
cursor: pointer;
|
153 |
+
transition: all 0.3s;
|
154 |
+
font-weight: 500;
|
155 |
+
}
|
156 |
+
button:hover {
|
157 |
+
background: #3a3ad4;
|
158 |
+
transform: translateY(-2px);
|
159 |
+
}
|
160 |
+
::-webkit-scrollbar {
|
161 |
+
width: 6px;
|
162 |
+
}
|
163 |
+
::-webkit-scrollbar-track {
|
164 |
+
background: transparent;
|
165 |
+
}
|
166 |
+
::-webkit-scrollbar-thumb {
|
167 |
+
background: rgba(255, 255, 255, 0.2);
|
168 |
+
border-radius: 3px;
|
169 |
+
}
|
170 |
+
.category {
|
171 |
+
color: rgba(255, 255, 255, 0.6);
|
172 |
+
font-size: 0.9em;
|
173 |
+
margin-bottom: 15px;
|
174 |
+
font-weight: 500;
|
175 |
+
}
|
176 |
+
</style>
|
177 |
+
</head>
|
178 |
+
<body>
|
179 |
+
<div class="container">
|
180 |
+
<div class="chat-container">
|
181 |
+
<div class="chat-header">Advanced AI Assistant</div>
|
182 |
+
<div class="chat-box" id="chatBox">
|
183 |
+
<div class="message ai-message">Hello! I'm your advanced AI assistant. I can help you with a wide range of tasks including calculations, conversions, coding help, general knowledge questions, and more!</div>
|
184 |
+
<div class="typing-indicator" id="typingIndicator">
|
185 |
+
<span class="dot"></span>
|
186 |
+
<span class="dot"></span>
|
187 |
+
<span class="dot"></span>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
<div class="input-area">
|
191 |
+
<input type="text" id="userInput" placeholder="Type your message...">
|
192 |
+
<button onclick="sendMessage()">Send</button>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
<div class="suggestions">
|
196 |
+
<div class="category">Suggested Topics</div>
|
197 |
+
<div class="suggestion-item" onclick="useSuggestion('Tell me about quantum computing')">Quantum Computing</div>
|
198 |
+
<div class="suggestion-item" onclick="useSuggestion('How do I start learning programming?')">Programming Basics</div>
|
199 |
+
<div class="suggestion-item" onclick="useSuggestion('Explain machine learning in simple terms')">Machine Learning</div>
|
200 |
+
<div class="suggestion-item" onclick="useSuggestion('What are some productivity tips?')">Productivity Tips</div>
|
201 |
+
<div class="suggestion-item" onclick="useSuggestion('Help me with JavaScript promises')">JavaScript Help</div>
|
202 |
+
</div>
|
203 |
+
</div>
|
204 |
+
|
205 |
+
<script>
|
206 |
+
// Large predefined knowledge base (sample - extend with more)
|
207 |
+
const knowledgeBase = {
|
208 |
+
// General Knowledge
|
209 |
+
"quantum computing": "Quantum computing is a type of computing that uses quantum-mechanical phenomena like superposition and entanglement to perform calculations. Unlike classical computers that use bits (0 or 1), quantum computers use quantum bits or qubits that can exist in multiple states simultaneously.",
|
210 |
+
|
211 |
+
"machine learning": "Machine learning is a subset of artificial intelligence that enables systems to learn and improve from experience without being explicitly programmed. It uses algorithms and statistical models to analyze patterns in data.",
|
212 |
+
|
213 |
+
"programming basics": "Programming is the process of creating a set of instructions that tell a computer how to perform a task. Key concepts include variables, control structures (if/else, loops), functions, and data structures. Popular beginner languages include Python and JavaScript.",
|
214 |
+
|
215 |
+
// Technical Help
|
216 |
+
"javascript promises": "Promises in JavaScript are objects representing the eventual completion (or failure) of an asynchronous operation. They help manage asynchronous code more elegantly. Example:\n\nnew Promise((resolve, reject) => {\n // async code here\n if(success) resolve(result);\n else reject(error);\n});",
|
217 |
+
|
218 |
+
"css flexbox": "Flexbox is a CSS layout model that allows you to design flexible responsive layouts. Key properties include:\n- display: flex\n- flex-direction\n- justify-content\n- align-items",
|
219 |
+
|
220 |
+
// Math Operations
|
221 |
+
"calculate": (input) => {
|
222 |
+
const expression = input.replace("calculate", "").trim();
|
223 |
+
try {
|
224 |
+
return `The result is: ${eval(expression)}`;
|
225 |
+
} catch {
|
226 |
+
return "Sorry, I couldn't perform that calculation. Please check the format.";
|
227 |
+
}
|
228 |
+
},
|
229 |
+
// Unit Conversions
|
230 |
+
"convert": (input) => {
|
231 |
+
const conversions = {
|
232 |
+
"celsius_to_fahrenheit": (c) => (c * 9/5 + 32).toFixed(2),
|
233 |
+
"fahrenheit_to_celsius": (f) => ((f - 32) * 5/9).toFixed(2),
|
234 |
+
"km_to_miles": (km) => (km * 0.621371).toFixed(2),
|
235 |
+
"miles_to_km": (mi) => (mi * 1.60934).toFixed(2)
|
236 |
+
};
|
237 |
+
const parts = input.toLowerCase().split(" ");
|
238 |
+
|
239 |
+
if(parts.includes("celsius") && parts.includes("fahrenheit")) {
|
240 |
+
const temp = parseFloat(parts[1]);
|
241 |
+
return `${temp}°C is equal to ${conversions.celsius_to_fahrenheit(temp)}°F`;
|
242 |
+
}
|
243 |
+
// Add more conversion types here
|
244 |
+
|
245 |
+
return "I can convert between various units. Try: 'convert 20 celsius to fahrenheit'";
|
246 |
+
},
|
247 |
+
// Productivity Tips
|
248 |
+
"productivity tips": "Here are some key productivity tips:\n1. Use the Pomodoro Technique\n2. Break large tasks into smaller ones\n3. Set clear goals and deadlines\n4. Minimize distractions\n5. Take regular breaks\n6. Use task management tools\n7. Practice time-blocking",
|
249 |
+
|
250 |
+
// Add thousands more entries here for different topics
|
251 |
+
};
|
252 |
+
// General responses for common queries
|
253 |
+
const generalResponses = {
|
254 |
+
"hello": ["Hi there! How can I help you today?", "Hello! What would you like to learn about?", "Greetings! I'm here to assist you."],
|
255 |
+
"thank you": ["You're welcome!", "Happy to help!", "Anytime! Let me know if you need anything else."],
|
256 |
+
"bye": ["Goodbye! Have a great day!", "See you later! Feel free to return if you have more questions.", "Bye! Thanks for chatting!"],
|
257 |
+
};
|
258 |
+
const chatBox = document.getElementById("chatBox");
|
259 |
+
const userInput = document.getElementById("userInput");
|
260 |
+
const typingIndicator = document.getElementById("typingIndicator");
|
261 |
+
userInput.addEventListener("keypress", (e) => {
|
262 |
+
if (e.key === "Enter") {
|
263 |
+
sendMessage();
|
264 |
+
}
|
265 |
+
});
|
266 |
+
function useSuggestion(text) {
|
267 |
+
userInput.value = text;
|
268 |
+
sendMessage();
|
269 |
+
}
|
270 |
+
function sendMessage() {
|
271 |
+
const message = userInput.value.trim();
|
272 |
+
if (!message) return;
|
273 |
+
addMessage(message, "user-message");
|
274 |
+
userInput.value = "";
|
275 |
+
typingIndicator.style.display = "block";
|
276 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
277 |
+
setTimeout(() => {
|
278 |
+
typingIndicator.style.display = "none";
|
279 |
+
|
280 |
+
let response = generateResponse(message.toLowerCase());
|
281 |
+
addMessage(response, "ai-message");
|
282 |
+
}, 1000 + Math.random() * 1000); // Random delay for more natural feel
|
283 |
+
}
|
284 |
+
function generateResponse(input) {
|
285 |
+
// Check general responses first
|
286 |
+
for (let key in generalResponses) {
|
287 |
+
if (input.includes(key)) {
|
288 |
+
return generalResponses[key][Math.floor(Math.random() * generalResponses[key].length)];
|
289 |
+
}
|
290 |
+
}
|
291 |
+
// Check knowledge base
|
292 |
+
for (let key in knowledgeBase) {
|
293 |
+
if (input.includes(key)) {
|
294 |
+
return typeof knowledgeBase[key] === 'function'
|
295 |
+
? knowledgeBase[key](input)
|
296 |
+
: knowledgeBase[key];
|
297 |
+
}
|
298 |
+
}
|
299 |
+
// Handle calculations
|
300 |
+
if (input.startsWith("calculate")) {
|
301 |
+
return knowledgeBase.calculate(input);
|
302 |
+
}
|
303 |
+
// Handle conversions
|
304 |
+
if (input.startsWith("convert")) {
|
305 |
+
return knowledgeBase.convert(input);
|
306 |
+
}
|
307 |
+
return "I'm not sure about that. Could you try rephrasing your question? Or ask me about topics like programming, quantum computing, or machine learning.";
|
308 |
+
}
|
309 |
+
function addMessage(text, className) {
|
310 |
+
const messageDiv = document.createElement("div");
|
311 |
+
messageDiv.className = `message ${className}`;
|
312 |
+
messageDiv.textContent = text;
|
313 |
+
chatBox.insertBefore(messageDiv, typingIndicator);
|
314 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
315 |
+
}
|
316 |
+
</script>
|
317 |
+
</body>
|
318 |
+
</html>
|