Sheelu Katiyar commited on
Commit
f4a40f2
·
verified ·
1 Parent(s): 19fff5d

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +274 -0
index.html ADDED
@@ -0,0 +1,274 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="hi">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Creative Aura Gen 2.0</title>
7
+ <style>
8
+ body {
9
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
10
+ background-color: #ffffff;
11
+ margin: 0;
12
+ padding: 0;
13
+ display: flex;
14
+ height: 100vh;
15
+ color: #222;
16
+ }
17
+ .chat-container {
18
+ flex: 1;
19
+ display: flex;
20
+ flex-direction: column;
21
+ max-width: 850px;
22
+ margin: 0 auto;
23
+ border-left: 1px solid #eaeaea;
24
+ border-right: 1px solid #eaeaea;
25
+ background: rgba(255, 255, 255, 0.7);
26
+ backdrop-filter: blur(25px);
27
+ -webkit-backdrop-filter: blur(25px);
28
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.02);
29
+ }
30
+ .header {
31
+ padding: 22px;
32
+ text-align: center;
33
+ border-bottom: 1px solid #eaeaea;
34
+ background: rgba(255, 255, 255, 0.85);
35
+ backdrop-filter: blur(10px);
36
+ font-weight: 600;
37
+ font-size: 1.25rem;
38
+ color: #111;
39
+ letter-spacing: -0.3px;
40
+ }
41
+ .chat-box {
42
+ flex: 1;
43
+ padding: 25px;
44
+ overflow-y: auto;
45
+ display: flex;
46
+ flex-direction: column;
47
+ gap: 24px;
48
+ }
49
+ .message {
50
+ max-width: 82%;
51
+ padding: 14px 20px;
52
+ border-radius: 22px;
53
+ line-height: 1.6;
54
+ font-size: 1.05rem;
55
+ word-wrap: break-word;
56
+ }
57
+ .user-message {
58
+ align-self: flex-end;
59
+ background-color: #f3f3f3;
60
+ color: #000;
61
+ border-bottom-right-radius: 5px;
62
+ }
63
+ .bot-message {
64
+ align-self: flex-start;
65
+ background-color: #ffffff;
66
+ border: 1px solid #eaeaea;
67
+ color: #232323;
68
+ border-bottom-left-radius: 5px;
69
+ box-shadow: 0 4px 14px rgba(0,0,0,0.02);
70
+ }
71
+ .input-area {
72
+ padding: 20px;
73
+ border-top: 1px solid #eaeaea;
74
+ background: rgba(255, 255, 255, 0.95);
75
+ display: flex;
76
+ gap: 14px;
77
+ align-items: center;
78
+ }
79
+ .file-upload {
80
+ position: relative;
81
+ overflow: hidden;
82
+ display: inline-block;
83
+ }
84
+ .file-upload input[type=file] {
85
+ font-size: 100px;
86
+ position: absolute;
87
+ left: 0;
88
+ top: 0;
89
+ opacity: 0;
90
+ cursor: pointer;
91
+ }
92
+ .upload-btn {
93
+ background-color: #fafafa;
94
+ border: 1px solid #eaeaea;
95
+ border-radius: 50%;
96
+ width: 48px;
97
+ height: 48px;
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: center;
101
+ font-size: 1.3rem;
102
+ color: #444;
103
+ cursor: pointer;
104
+ transition: all 0.2s ease;
105
+ }
106
+ .upload-btn:hover {
107
+ background-color: #f0f0f0;
108
+ transform: scale(1.02);
109
+ }
110
+ input[type="text"] {
111
+ flex: 1;
112
+ padding: 15px 22px;
113
+ border: 1px solid #eaeaea;
114
+ border-radius: 26px;
115
+ outline: none;
116
+ font-size: 1.02rem;
117
+ background: #ffffff;
118
+ transition: all 0.2s ease;
119
+ }
120
+ input[type="text"]:focus {
121
+ border-color: #b5b5b5;
122
+ box-shadow: 0 0 0 4px rgba(0,0,0,0.03);
123
+ }
124
+ button.send-btn {
125
+ background-color: #000000;
126
+ color: #ffffff;
127
+ border: none;
128
+ border-radius: 26px;
129
+ padding: 14px 28px;
130
+ font-size: 1rem;
131
+ font-weight: 500;
132
+ cursor: pointer;
133
+ transition: all 0.2s ease;
134
+ }
135
+ button.send-btn:hover {
136
+ background-color: #222;
137
+ }
138
+ button.send-btn:active {
139
+ transform: scale(0.97);
140
+ }
141
+ .attachment-preview {
142
+ display: none;
143
+ padding: 12px 25px;
144
+ background: #fbfbfb;
145
+ border-top: 1px solid #eaeaea;
146
+ font-size: 0.95rem;
147
+ color: #555;
148
+ }
149
+ .preview-img {
150
+ max-height: 220px;
151
+ border-radius: 14px;
152
+ margin-top: 12px;
153
+ border: 1px solid #e2e2e2;
154
+ }
155
+ </style>
156
+ </head>
157
+ <body>
158
+ <div class="chat-container">
159
+ <div class="header">Creative Aura Gen 2.0 ✨</div>
160
+ <div class="chat-box" id="chat-box">
161
+ <div class="message bot-message">नमस्ते अभय भाई! मैं Creative Aura Gen 2.0 हूँ। यह एक एडवांस मल्टीमोडल सिस्��म है। आप मुझसे कोई भी सवाल पूछ सकते हैं, या इमेज और ऑडियो अपलोड करके उसपर चर्चा कर सकते हैं।</div>
162
+ </div>
163
+ <div class="attachment-preview" id="attachment-preview"></div>
164
+ <div class="input-area">
165
+ <div class="file-upload">
166
+ <button class="upload-btn">📎</button>
167
+ <input type="file" id="file-input" accept="image/*,audio/*" onchange="handleFile(event)">
168
+ </div>
169
+ <input type="text" id="user-input" placeholder="कुछ पूछें या फ़ाइल अपलोड करें..." onkeypress="handleEnter(event)">
170
+ <button class="send-btn" onclick="sendMessage()">Send</button>
171
+ </div>
172
+ </div>
173
+
174
+ <script>
175
+ let currentAttachment = null;
176
+
177
+ function handleFile(event) {
178
+ const file = event.target.files[0];
179
+ if (!file) return;
180
+
181
+ const reader = new FileReader();
182
+ reader.onload = function(e) {
183
+ const base64Data = e.target.result.split(',')[1];
184
+ let type = 'file';
185
+ if (file.type.startsWith('image/')) type = 'image';
186
+ else if (file.type.startsWith('audio/')) type = 'audio';
187
+
188
+ currentAttachment = { type: type, data: base64Data };
189
+
190
+ const preview = document.getElementById('attachment-preview');
191
+ preview.style.display = 'block';
192
+ preview.innerHTML = `संलग्न फ़ाइल: <strong>${file.name}</strong> <button onclick="clearAttachment()" style="margin-left:12px; border:none; background:none; color:#ff3b30; cursor:pointer; font-weight:bold;">❌</button>`;
193
+ };
194
+ reader.readAsDataURL(file);
195
+ }
196
+
197
+ function clearAttachment() {
198
+ currentAttachment = null;
199
+ document.getElementById('attachment-preview').style.display = 'none';
200
+ document.getElementById('file-input').value = '';
201
+ }
202
+
203
+ function handleEnter(event) {
204
+ if (event.key === "Enter") sendMessage();
205
+ }
206
+
207
+ async function sendMessage() {
208
+ const inputField = document.getElementById('user-input');
209
+ const message = inputField.value.trim();
210
+ if (!message && !currentAttachment) return;
211
+
212
+ const chatBox = document.getElementById('chat-box');
213
+
214
+ let userHTML = `<div class="message user-message">${message}`;
215
+ if (currentAttachment && currentAttachment.type === 'image') {
216
+ userHTML += `<br><img src="data:image/jpeg;base64,${currentAttachment.data}" class="preview-img">`;
217
+ } else if (currentAttachment && currentAttachment.type === 'audio') {
218
+ userHTML += `<br><em>🎵 [ऑडियो इनपुट संलग्न]</em>`;
219
+ }
220
+ userHTML += `</div>`;
221
+ chatBox.innerHTML += userHTML;
222
+
223
+ let attachments = [];
224
+ if (currentAttachment) attachments.push(currentAttachment);
225
+
226
+ inputField.value = '';
227
+ clearAttachment();
228
+ chatBox.scrollTop = chatBox.scrollHeight;
229
+
230
+ const botMsgId = "bot-" + Date.now();
231
+ chatBox.innerHTML += `<div class="message bot-message" id="${botMsgId}">सोच रहा हूँ...</div>`;
232
+ chatBox.scrollTop = chatBox.scrollHeight;
233
+
234
+ try {
235
+ const response = await fetch('/api/chat', {
236
+ method: 'POST',
237
+ headers: { 'Content-Type': 'application/json' },
238
+ body: JSON.stringify({ message: message, attachments: attachments })
239
+ });
240
+
241
+ const reader = response.body.getReader();
242
+ const decoder = new TextDecoder();
243
+ const botDiv = document.getElementById(botMsgId);
244
+ botDiv.innerHTML = "";
245
+
246
+ while (true) {
247
+ const { done, value } = await reader.read();
248
+ if (done) break;
249
+
250
+ const chunk = decoder.decode(value, {stream: true});
251
+ const lines = chunk.split('\n');
252
+ for (let line of lines) {
253
+ if (line.startsWith('data: ')) {
254
+ const dataStr = line.substring(6);
255
+ if (dataStr.trim() === '[DONE]') continue;
256
+ try {
257
+ const dataObj = JSON.parse(dataStr);
258
+ if (dataObj.choices && dataObj.choices[0].delta.content) {
259
+ let text = dataObj.choices[0].delta.content;
260
+ text = text.replace(/\n/g, '<br>');
261
+ botDiv.innerHTML += text;
262
+ chatBox.scrollTop = chatBox.scrollHeight;
263
+ }
264
+ } catch (e) { }
265
+ }
266
+ }
267
+ }
268
+ } catch (error) {
269
+ document.getElementById(botMsgId).innerHTML = "त्रुटि: सर्वर से प्रतिक्रिया नहीं मिल सकी।";
270
+ }
271
+ }
272
+ </script>
273
+ </body>
274
+ </html>