Dooratre commited on
Commit
0a28f3e
·
verified ·
1 Parent(s): 1aeb88a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +321 -36
index.html CHANGED
@@ -1,43 +1,328 @@
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>API Interaction</title>
7
- <script>
8
- async function callAPI() {
9
- const url = "https://huggingface.co/chat/conversation";
10
- const headers = {
11
- "Content-Type": "application/json",
12
- "Cookie": "token=LdeOqPFByfVHXYRcTqdmowtNLCxediADEHZFBibXkaZcHYHtMrYKFEPndUUEyPFTajezjuHTHeStDeabkwbMUoLKzpCFmhmZSIFKvvwWiWHSFdNfoRVKbWuIVTLikIdR; __stripe_mid=06f6506e-e1bc-41c6-88f9-a8b3802c925085fa8e; hf-chat=8881bae7-9647-4cf3-8f8a-59de9f530c82; aws-waf-token=c27f90fe-f8c3-4742-90c7-68e483c93599:DgoAdG6NUVMZAAAA:r3I9urfTNs3M0F/LjKVi3zAL+W3UZ75yLE9SiEnPGsQYZP0qzmo+WNCDXxIacFoPHw5nNHpjZ4dQST/YIFy7vKeVv/fYbrruLJXXYULp2eIxZjmMqmQWZBBqEulrGWvuKpBWymHxyVlJxw6lysVg5ef1amEXPJzaVwdaRiYsNipGTPdiokAbL9k1wunKnirpX3cg3QN9LFeejYP/ZYbiaIciKlxtmnZ+Dlqd5/lh7Uw4jobTLNBRMRN67qZZyooQhmQbW4E=" // Replace with your actual cookie
13
- };
14
- const payload = {
15
- "model": "nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",
16
- "preprompt": ""
17
- };
18
-
19
- try {
20
- const response = await fetch(url, {
21
- method: 'POST',
22
- headers: headers,
23
- body: JSON.stringify(payload)
24
- });
25
-
26
- if (response.ok) {
27
- const data = await response.json();
28
- document.getElementById("result").innerText = `ID: ${data.id}`; // Adjust based on actual response structure
29
- } else {
30
- document.getElementById("result").innerText = `Error: ${response.status}`;
31
- }
32
- } catch (error) {
33
- document.getElementById("result").innerText = `Request failed: ${error.message}`;
34
- }
35
- }
36
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  </head>
38
  <body>
39
- <h1>API Interaction</h1>
40
- <button onclick="callAPI()">Run API</button>
41
- <p id="result"></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  </body>
43
  </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>Modern AI Chat</title>
7
+ <style>
8
+ /* Import Fonts */
9
+ @import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600&family=Poppins:wght@400;600&display=swap');
10
+
11
+ /* Highlight Title Styling for AI Response */
12
+ .highlight-title {
13
+ font-size: 1rem; /* Adjust for mobile */
14
+ font-weight: 700; /* Extra bold */
15
+ color: #000; /* Black text */
16
+ display: inline-block;
17
+ margin: 5px 0; /* Add some spacing if needed */
18
+ }
19
+
20
+ /* Fullscreen Responsive Styling */
21
+ body {
22
+ margin: 0;
23
+ padding: 0;
24
+ font-family: 'Poppins', sans-serif;
25
+ background: linear-gradient(135deg, #6E45E2, #88D3CE);
26
+ height: 100vh; /* Full height */
27
+ display: flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ overflow: hidden;
31
+ }
32
+
33
+ /* Animation Background */
34
+ body::before {
35
+ content: '';
36
+ position: absolute;
37
+ top: -50%;
38
+ left: -50%;
39
+ width: 200%;
40
+ height: 200%;
41
+ background: radial-gradient(circle, rgba(98, 0, 234, 0.6), transparent);
42
+ animation: backgroundAnimation 6s infinite linear alternate;
43
+ z-index: 0;
44
+ }
45
+
46
+ @keyframes backgroundAnimation {
47
+ to {
48
+ transform: rotate(360deg);
49
+ }
50
+ }
51
+
52
+ .chat-container {
53
+ position: relative;
54
+ z-index: 1;
55
+ width: 100%; /* Full width for mobile */
56
+ height: 100%; /* Full height for mobile */
57
+ background: #ffffff;
58
+ border-radius: 15px 15px 0 0; /* Rounded top corners */
59
+ box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2); /* Subtle shadow */
60
+ display: flex;
61
+ flex-direction: column;
62
+ overflow: hidden;
63
+ }
64
+
65
+ @keyframes fadeIn {
66
+ from {
67
+ opacity: 0;
68
+ transform: translateY(30px);
69
+ }
70
+ to {
71
+ opacity: 1;
72
+ transform: translateY(0);
73
+ }
74
+ }
75
+
76
+ /* Header */
77
+ .chat-header {
78
+ background: linear-gradient(135deg, #6200ea, #3700b3);
79
+ color: #fff;
80
+ padding: 15px; /* Adjusted padding for mobile */
81
+ text-align: center;
82
+ font-size: 1.2rem; /* Adjusted for mobile */
83
+ font-weight: bold;
84
+ font-family: 'Cairo', sans-serif;
85
+ border-bottom: 1px solid #ddd;
86
+ }
87
+
88
+ /* Chat Box */
89
+ .chat-box {
90
+ flex: 1;
91
+ padding: 10px 15px; /* Smaller padding for mobile */
92
+ overflow-y: auto; /* Enable vertical scrolling */
93
+ max-height: calc(100vh - 140px); /* Dynamic height */
94
+ display: flex;
95
+ flex-direction: column;
96
+ background: #f8f9fa;
97
+ }
98
+
99
+ .chat-box .message {
100
+ margin-bottom: 10px; /* Reduced margin for compact spacing */
101
+ font-size: 0.9rem; /* Adjusted for mobile */
102
+ padding: 10px 15px;
103
+ border-radius: 20px;
104
+ max-width: 75%;
105
+ animation: slideIn 0.3s ease-in-out;
106
+ word-wrap: break-word;
107
+ font-family: 'Cairo', 'Poppins', sans-serif;
108
+ }
109
+
110
+ @keyframes slideIn {
111
+ from {
112
+ transform: translateY(10px);
113
+ opacity: 0;
114
+ }
115
+ to {
116
+ transform: translateY(0);
117
+ opacity: 1;
118
+ }
119
+ }
120
+
121
+ .chat-box .message.user {
122
+ margin-left: auto;
123
+ background: #e3f2fd;
124
+ color: #0D47A1;
125
+ text-align: right;
126
+ }
127
+
128
+ .chat-box .message.ai {
129
+ margin-right: auto;
130
+ background: #e8f5e9;
131
+ color: #1B5E20;
132
+ text-align: left;
133
+ }
134
+
135
+ /* Typing Animation */
136
+ .typing-animation {
137
+ display: flex;
138
+ margin: 10px 0;
139
+ justify-content: left;
140
+ align-items: center;
141
+ }
142
+
143
+ .typing-animation span {
144
+ display: inline-block;
145
+ width: 8px;
146
+ height: 8px;
147
+ margin: 0 3px;
148
+ background: #1B5E20;
149
+ border-radius: 50%;
150
+ animation: typing 1.3s infinite;
151
+ }
152
+
153
+ .typing-animation span:nth-child(2) {
154
+ animation-delay: 0.2s;
155
+ }
156
+
157
+ .typing-animation span:nth-child(3) {
158
+ animation-delay: 0.4s;
159
+ }
160
+
161
+ @keyframes typing {
162
+ 0%, 80% {
163
+ transform: scale(0);
164
+ }
165
+ 40% {
166
+ transform: scale(1);
167
+ }
168
+ }
169
+
170
+ /* Chat Input */
171
+ .chat-input {
172
+ display: flex;
173
+ align-items: center;
174
+ padding: 10px; /* Reduced padding for mobile */
175
+ background: #f9f9f9;
176
+ border-top: 1px solid #ddd;
177
+ }
178
+
179
+ .chat-input input {
180
+ flex: 1;
181
+ padding: 12px; /* Adjusted for smaller screens */
182
+ border: 1px solid #ddd;
183
+ border-radius: 30px;
184
+ margin-right: 10px;
185
+ font-size: 0.9rem; /* Smaller size for mobile */
186
+ font-family: 'Poppins', 'Cairo', sans-serif;
187
+ outline: none;
188
+ transition: all 0.3s ease;
189
+ }
190
+
191
+ .chat-input input:focus {
192
+ border-color: #6200ea;
193
+ box-shadow: 0 0 5px rgba(98, 0, 234, 0.5);
194
+ }
195
+
196
+ .chat-input button {
197
+ padding: 10px 15px; /* Adjusted for mobile */
198
+ background: linear-gradient(135deg, #6200ea, #3700b3);
199
+ border: none;
200
+ color: white;
201
+ border-radius: 20px;
202
+ cursor: pointer;
203
+ font-weight: bold;
204
+ font-size: 0.9rem; /* Adjusted for mobile */
205
+ font-family: 'Poppins', 'Cairo', sans-serif;
206
+ transition: all 0.3s ease;
207
+ }
208
+
209
+ .chat-input button:hover {
210
+ background: #5e35b1;
211
+ box-shadow: 0 5px 15px rgba(98, 0, 234, 0.4);
212
+ }
213
+ </style>
214
  </head>
215
  <body>
216
+ <div class="chat-container">
217
+ <div class="chat-header">
218
+ AI Chat with Omar's Smart Model
219
+ </div>
220
+ <div class="chat-box" id="chat-box">
221
+ <!-- Chat messages will populate here -->
222
+ </div>
223
+ <div class="chat-input">
224
+ <input type="text" id="user-input" placeholder="Type a message..." autocomplete="off">
225
+ <button id="send-btn">Send</button>
226
+ </div>
227
+ </div>
228
+ <script>
229
+ const apiUrl = "https://dooratre-test-flask-space.hf.space/chat";
230
+
231
+ const chatBox = document.getElementById("chat-box");
232
+ const userInput = document.getElementById("user-input");
233
+ const sendBtn = document.getElementById("send-btn");
234
+
235
+ // Initialize conversation history
236
+ let conversationHistory = [
237
+ { "role": "system", "content": "you are AI model created and developed By MR Omar Nuwara In CORVO AI Company you are model name ALEX-9 you can chat and help user you are best model for now\n\n you will chat Omar's Freind Hussein Shkikel He is Libyan So chat with Libyan arabic accent 😂😂😂 make it fun with smart libyan brain 😂 Hussein now in the work he is working in الاستخبارات😂😂" }
238
+ ];
239
+
240
+ // Function to format AI response
241
+ function formatResponse(content) {
242
+ content = content.replace(/\n/g, "<br>");
243
+ content = content.replace(/\*\*(.*?)\*\*/g, '<strong class="highlight-title">$1</strong>');
244
+ return content;
245
+ }
246
+
247
+ // Function to add a message to the chat box
248
+ function addMessage(role, content) {
249
+ const messageDiv = document.createElement("div");
250
+ messageDiv.classList.add("message", role);
251
+
252
+ if (role === "ai") {
253
+ content = formatResponse(content);
254
+ }
255
+
256
+ messageDiv.innerHTML = content;
257
+ chatBox.appendChild(messageDiv);
258
+
259
+ setTimeout(() => {
260
+ chatBox.scrollTop = chatBox.scrollHeight;
261
+ }, 100);
262
+ }
263
+
264
+ // Function to show typing animation
265
+ function showTyping() {
266
+ const typingDiv = document.createElement("div");
267
+ typingDiv.classList.add("typing-animation");
268
+ typingDiv.innerHTML = `
269
+ <span></span>
270
+ <span></span>
271
+ <span></span>
272
+ `;
273
+ chatBox.appendChild(typingDiv);
274
+
275
+ setTimeout(() => {
276
+ chatBox.scrollTop = chatBox.scrollHeight;
277
+ }, 100);
278
+
279
+ return typingDiv;
280
+ }
281
+
282
+ // Function to send a message
283
+ async function sendMessage() {
284
+ const userMessage = userInput.value.trim();
285
+ if (!userMessage) return;
286
+
287
+ addMessage("user", userMessage);
288
+
289
+ conversationHistory.push({ "role": "user", "content": userMessage });
290
+
291
+ const typingDiv = showTyping();
292
+
293
+ const data = { message: conversationHistory };
294
+
295
+ try {
296
+ const response = await fetch(apiUrl, {
297
+ method: "POST",
298
+ headers: {
299
+ "Content-Type": "application/json"
300
+ },
301
+ body: JSON.stringify(data)
302
+ });
303
+
304
+ if (response.ok) {
305
+ const aiResponse = await response.text();
306
+ chatBox.removeChild(typingDiv);
307
+ addMessage("ai", aiResponse);
308
+ conversationHistory.push({ "role": "assistant", "content": aiResponse });
309
+ } else {
310
+ throw new Error(`Error: ${response.status}`);
311
+ }
312
+ } catch (error) {
313
+ console.error("Error:", error);
314
+ chatBox.removeChild(typingDiv);
315
+ addMessage("ai", "AI: Sorry, something went wrong!");
316
+ }
317
+
318
+ userInput.value = "";
319
+ }
320
+
321
+ // Attach event listeners
322
+ sendBtn.addEventListener("click", sendMessage);
323
+ userInput.addEventListener("keypress", (e) => {
324
+ if (e.key === "Enter") sendMessage();
325
+ });
326
+ </script>
327
  </body>
328
  </html>