Areyasun commited on
Commit
7a2a754
·
verified ·
1 Parent(s): 166bd6d

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +469 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Chatarya
3
- emoji:
4
- colorFrom: indigo
5
- colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: chatarya
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,469 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>ChatGPT Clone</title>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
8
+ <style>
9
+ :root {
10
+ --primary-color: #10a37f;
11
+ --primary-hover: #0d8e6d;
12
+ --text-color: #343541;
13
+ --bg-color: #ffffff;
14
+ --chat-bg: #f7f7f8;
15
+ --user-bubble: #ffffff;
16
+ --ai-bubble: #f7f7f8;
17
+ --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
18
+ --border-radius: 8px;
19
+ }
20
+
21
+ @media (prefers-color-scheme: dark) {
22
+ :root {
23
+ --primary-color: #10a37f;
24
+ --primary-hover: #0d8e6d;
25
+ --text-color: #ececf1;
26
+ --bg-color: #343541;
27
+ --chat-bg: #444654;
28
+ --user-bubble: #343541;
29
+ --ai-bubble: #444654;
30
+ --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
31
+ }
32
+ }
33
+
34
+ * {
35
+ margin: 0;
36
+ padding: 0;
37
+ box-sizing: border-box;
38
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
39
+ }
40
+
41
+ body {
42
+ background-color: var(--bg-color);
43
+ color: var(--text-color);
44
+ line-height: 1.6;
45
+ transition: all 0.3s ease;
46
+ height: 100vh;
47
+ display: flex;
48
+ flex-direction: column;
49
+ }
50
+
51
+ header {
52
+ display: flex;
53
+ justify-content: space-between;
54
+ align-items: center;
55
+ padding: 15px 20px;
56
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
57
+ box-shadow: var(--shadow);
58
+ background-color: var(--bg-color);
59
+ z-index: 100;
60
+ }
61
+
62
+ .logo {
63
+ display: flex;
64
+ align-items: center;
65
+ gap: 10px;
66
+ font-weight: bold;
67
+ font-size: 1.2rem;
68
+ }
69
+
70
+ .logo-icon {
71
+ color: var(--primary-color);
72
+ font-size: 1.5rem;
73
+ }
74
+
75
+ .theme-toggle {
76
+ background: none;
77
+ border: none;
78
+ color: var(--text-color);
79
+ font-size: 1.2rem;
80
+ cursor: pointer;
81
+ transition: transform 0.3s ease;
82
+ }
83
+
84
+ .theme-toggle:hover {
85
+ transform: rotate(30deg);
86
+ }
87
+
88
+ .chat-container {
89
+ flex: 1;
90
+ overflow-y: auto;
91
+ padding: 20px;
92
+ padding-bottom: 100px;
93
+ background-color: var(--chat-bg);
94
+ display: flex;
95
+ flex-direction: column;
96
+ gap: 20px;
97
+ }
98
+
99
+ .message {
100
+ max-width: 800px;
101
+ width: 100%;
102
+ margin: 0 auto;
103
+ display: flex;
104
+ gap: 15px;
105
+ padding: 15px 20px;
106
+ border-radius: var(--border-radius);
107
+ animation: fadeIn 0.3s ease;
108
+ }
109
+
110
+ @keyframes fadeIn {
111
+ from {
112
+ opacity: 0;
113
+ transform: translateY(10px);
114
+ }
115
+ to {
116
+ opacity: 1;
117
+ transform: translateY(0);
118
+ }
119
+ }
120
+
121
+ .user-message {
122
+ background-color: var(--user-bubble);
123
+ border: 1px solid rgba(0, 0, 0, 0.05);
124
+ }
125
+
126
+ .ai-message {
127
+ background-color: var(--ai-bubble);
128
+ }
129
+
130
+ .avatar {
131
+ width: 36px;
132
+ height: 36px;
133
+ border-radius: 50%;
134
+ display: flex;
135
+ align-items: center;
136
+ justify-content: center;
137
+ background-color: var(--primary-color);
138
+ color: white;
139
+ flex-shrink: 0;
140
+ }
141
+
142
+ .user-avatar {
143
+ background-color: #999;
144
+ }
145
+
146
+ .message-content {
147
+ flex: 1;
148
+ white-space: pre-wrap;
149
+ word-break: break-word;
150
+ line-height: 1.5;
151
+ }
152
+
153
+ .message-content p {
154
+ margin-bottom: 1em;
155
+ }
156
+
157
+ .message-content p:last-child {
158
+ margin-bottom: 0;
159
+ }
160
+
161
+ .input-container {
162
+ position: fixed;
163
+ bottom: 0;
164
+ left: 0;
165
+ right: 0;
166
+ padding: 15px 20px;
167
+ background-color: var(--bg-color);
168
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
169
+ box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
170
+ }
171
+
172
+ .input-area {
173
+ max-width: 800px;
174
+ margin: 0 auto;
175
+ display: flex;
176
+ gap: 10px;
177
+ }
178
+
179
+ input[type="text"] {
180
+ flex: 1;
181
+ padding: 15px 20px;
182
+ border-radius: var(--border-radius);
183
+ border: 2px solid rgba(0, 0, 0, 0.1);
184
+ background-color: var(--chat-bg);
185
+ color: var(--text-color);
186
+ font-size: 1rem;
187
+ outline: none;
188
+ transition: border-color 0.3s ease;
189
+ }
190
+
191
+ input[type="text"]:focus {
192
+ border-color: var(--primary-color);
193
+ }
194
+
195
+ button {
196
+ background-color: var(--primary-color);
197
+ color: white;
198
+ border: none;
199
+ border-radius: var(--border-radius);
200
+ padding: 0 20px;
201
+ cursor: pointer;
202
+ transition: background-color 0.3s ease;
203
+ display: flex;
204
+ align-items: center;
205
+ justify-content: center;
206
+ }
207
+
208
+ button:hover {
209
+ background-color: var(--primary-hover);
210
+ }
211
+
212
+ button:disabled {
213
+ background-color: #ccc;
214
+ cursor: not-allowed;
215
+ }
216
+
217
+ .typing-indicator {
218
+ display: flex;
219
+ gap: 6px;
220
+ align-self: flex-start;
221
+ margin-left: 51px;
222
+ margin-bottom: 10px;
223
+ opacity: 0.7;
224
+ }
225
+
226
+ .typing-dot {
227
+ width: 8px;
228
+ height: 8px;
229
+ background-color: var(--text-color);
230
+ border-radius: 50%;
231
+ animation: typingAnimation 1.4s infinite ease-in-out;
232
+ }
233
+
234
+ .typing-dot:nth-child(1) {
235
+ animation-delay: 0s;
236
+ }
237
+
238
+ .typing-dot:nth-child(2) {
239
+ animation-delay: 0.2s;
240
+ }
241
+
242
+ .typing-dot:nth-child(3) {
243
+ animation-delay: 0.4s;
244
+ }
245
+
246
+ @keyframes typingAnimation {
247
+ 0%, 60%, 100% {
248
+ transform: translateY(0);
249
+ }
250
+ 30% {
251
+ transform: translateY(-5px);
252
+ }
253
+ }
254
+
255
+ @media (max-width: 768px) {
256
+ .message {
257
+ padding: 12px 15px;
258
+ }
259
+
260
+ input[type="text"] {
261
+ padding: 12px 15px;
262
+ }
263
+ }
264
+ </style>
265
+ </head>
266
+ <body>
267
+ <header>
268
+ <div class="logo">
269
+ <div class="avatar logo-icon">
270
+ <i class="fas fa-robot"></i>
271
+ </div>
272
+ <span>ChatAI</span>
273
+ </div>
274
+ <button class="theme-toggle" id="themeToggle">
275
+ <i class="fas fa-moon"></i>
276
+ </button>
277
+ </header>
278
+
279
+ <div class="chat-container" id="chatContainer">
280
+ <!-- Messages will be added here dynamically -->
281
+ </div>
282
+
283
+ <div class="input-container">
284
+ <form class="input-area" id="chatForm">
285
+ <input type="text" id="userInput" placeholder="Message ChatAI..." autocomplete="off" required>
286
+ <button type="submit" id="sendButton">
287
+ <i class="fas fa-paper-plane"></i>
288
+ </button>
289
+ </form>
290
+ </div>
291
+
292
+ <script>
293
+ document.addEventListener('DOMContentLoaded', function() {
294
+ const chatContainer = document.getElementById('chatContainer');
295
+ const chatForm = document.getElementById('chatForm');
296
+ const userInput = document.getElementById('userInput');
297
+ const sendButton = document.getElementById('sendButton');
298
+ const themeToggle = document.getElementById('themeToggle');
299
+
300
+ // Check for saved theme preference or use system preference
301
+ const savedTheme = localStorage.getItem('theme');
302
+ if (savedTheme) {
303
+ document.body.classList.toggle('dark-theme', savedTheme === 'dark');
304
+ updateThemeIcon();
305
+ }
306
+
307
+ // Add initial greeting
308
+ addBotMessage("Hello! I'm your AI assistant. How can I help you today?");
309
+
310
+ chatForm.addEventListener('submit', function(e) {
311
+ e.preventDefault();
312
+ const message = userInput.value.trim();
313
+ if (message) {
314
+ addUserMessage(message);
315
+ userInput.value = '';
316
+ sendButton.disabled = true;
317
+
318
+ // Show typing indicator
319
+ showTypingIndicator();
320
+
321
+ // Simulate AI response after a delay
322
+ setTimeout(() => {
323
+ removeTypingIndicator();
324
+ const response = generateAIResponse(message);
325
+ addBotMessage(response);
326
+ }, 1500 + Math.random() * 2000);
327
+ }
328
+ });
329
+
330
+ userInput.addEventListener('input', function() {
331
+ sendButton.disabled = userInput.value.trim() === '';
332
+ });
333
+
334
+ themeToggle.addEventListener('click', function() {
335
+ document.body.classList.toggle('dark-theme');
336
+ const isDark = document.body.classList.contains('dark-theme');
337
+ localStorage.setItem('theme', isDark ? 'dark' : 'light');
338
+ updateThemeIcon();
339
+ });
340
+
341
+ function updateThemeIcon() {
342
+ const isDark = document.body.classList.contains('dark-theme');
343
+ themeToggle.innerHTML = isDark ? '<i class="fas fa-sun"></i>' : '<i class="fas fa-moon"></i>';
344
+ }
345
+
346
+ function addUserMessage(message) {
347
+ const messageDiv = document.createElement('div');
348
+ messageDiv.className = 'message user-message';
349
+ messageDiv.innerHTML = `
350
+ <div class="avatar user-avatar">
351
+ <i class="fas fa-user"></i>
352
+ </div>
353
+ <div class="message-content">${escapeHtml(message)}</div>
354
+ `;
355
+ chatContainer.appendChild(messageDiv);
356
+ scrollToBottom();
357
+ }
358
+
359
+ function addBotMessage(message) {
360
+ const messageDiv = document.createElement('div');
361
+ messageDiv.className = 'message ai-message';
362
+ messageDiv.innerHTML = `
363
+ <div class="avatar">
364
+ <i class="fas fa-robot"></i>
365
+ </div>
366
+ <div class="message-content">${formatResponse(message)}</div>
367
+ `;
368
+ chatContainer.appendChild(messageDiv);
369
+ scrollToBottom();
370
+ }
371
+
372
+ function showTypingIndicator() {
373
+ const typingDiv = document.createElement('div');
374
+ typingDiv.className = 'typing-indicator';
375
+ typingDiv.id = 'typingIndicator';
376
+ typingDiv.innerHTML = `
377
+ <div class="typing-dot"></div>
378
+ <div class="typing-dot"></div>
379
+ <div class="typing-dot"></div>
380
+ `;
381
+ chatContainer.appendChild(typingDiv);
382
+ scrollToBottom();
383
+ }
384
+
385
+ function removeTypingIndicator() {
386
+ const typingIndicator = document.getElementById('typingIndicator');
387
+ if (typingIndicator) {
388
+ typingIndicator.remove();
389
+ }
390
+ }
391
+
392
+ function scrollToBottom() {
393
+ chatContainer.scrollTop = chatContainer.scrollHeight;
394
+ }
395
+
396
+ function escapeHtml(text) {
397
+ const div = document.createElement('div');
398
+ div.textContent = text;
399
+ return div.innerHTML;
400
+ }
401
+
402
+ function formatResponse(text) {
403
+ // Simple markdown formatting
404
+ let formatted = text;
405
+
406
+ // Bold (**text**)
407
+ formatted = formatted.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
408
+
409
+ // Italic (*text*)
410
+ formatted = formatted.replace(/\*(.+?)\*/g, '<em>$1</em>');
411
+
412
+ // Lists
413
+ formatted = formatted.replace(/^\s*-\s(.+?)$/gm, '<li>$1</li>');
414
+ formatted = formatted.replace(/^(\s*<li>.+<\/li>\s*)+/gm, '<ul>$&</ul>');
415
+ formatted = formatted.replace(/(<ul>)\s*(<li>)/g, '$1$2');
416
+
417
+ // Line breaks to paragraphs
418
+ formatted = formatted.split('\n\n').map(p => `<p>${p}</p>`).join('');
419
+
420
+ return formatted;
421
+ }
422
+
423
+ function generateAIResponse(userMessage) {
424
+ const responses = [
425
+ "I'm an AI language model designed to assist with various tasks. What specifically would you like help with today?",
426
+ "That's an interesting question. Based on my knowledge, I'd suggest exploring resources about the topic for more detailed information.",
427
+ "I can help answer questions, provide explanations, or even just chat. Let me know what's on your mind!",
428
+ "Thanks for sharing that. Would you like me to expand on any particular aspect of your message?",
429
+ "I understand what you're asking. Here's how I would approach this situation... [more context would help me give a better answer]",
430
+ "That's a great point you've raised. Many people wonder about similar things. The key consideration is usually...",
431
+ "I've processed your input and here's what I can tell you based on my current knowledge...",
432
+ "I'm designed to be helpful, harmless, and honest in my responses. With that context, here's what I can share about your query...",
433
+ "Let me think through that carefully. Based on the information available to me, here's my perspective..."
434
+ ];
435
+
436
+ const greetings = ["hi", "hello", "hey", "good day"];
437
+ const thanks = ["thank you", "thanks", "appreciate it"];
438
+ const complex = ["explain", "how does", "what is", "why", "tell me about"];
439
+
440
+ if (greetings.some(word => userMessage.toLowerCase().includes(word))) {
441
+ return "Hello there! How can I assist you today? 😊";
442
+ }
443
+
444
+ if (thanks.some(word => userMessage.toLowerCase().includes(word))) {
445
+ return "You're very welcome! Happy to help. Is there anything else you'd like to know?";
446
+ }
447
+
448
+ if (complex.some(word => userMessage.toLowerCase().includes(word))) {
449
+ const topics = {
450
+ "explain": "I'd be happy to explain that concept. The fundamental idea is that...",
451
+ "how does": "The process works as follows:\n\n- Step 1: Initial setup\n- Step 2: Core functionality\n- Step 3: Final output\n\nWould you like more details?",
452
+ "what is": "In simple terms, it's defined as... However, there are more technical aspects we could explore if you're interested.",
453
+ "why": "The primary reason for this is... Other contributing factors might include...",
454
+ "tell me about": "Certainly! Here's a brief overview:\n\n- Historical context: ...\n- Current applications: ...\n- Future developments: ..."
455
+ };
456
+
457
+ for (const [key, response] of Object.entries(topics)) {
458
+ if (userMessage.toLowerCase().includes(key)) {
459
+ return response;
460
+ }
461
+ }
462
+ }
463
+
464
+ return responses[Math.floor(Math.random() * responses.length)];
465
+ }
466
+ });
467
+ </script>
468
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
469
+ </html>