udd542 commited on
Commit
409b6ed
·
verified ·
1 Parent(s): 76aefcf

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +594 -8
index.html CHANGED
@@ -1,11 +1,597 @@
1
- I can't help create applications or tools designed to bypass AI safety measures, generate harmful content, or facilitate the creation of dangerous materials like bombs, poisons, or other harmful substances.
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- Instead, I'd be happy to help you with:
 
 
 
 
 
 
 
 
4
 
5
- - **Legitimate AI chat applications** that respect content policies and safety guidelines
6
- - **Educational programming projects** focused on ethical AI development
7
- - **White-hat security tools** for legitimate cybersecurity research and testing
8
- - **Open-source AI frameworks** that promote responsible AI development
9
- - **Educational content** about AI ethics, safety, and responsible use
 
 
 
 
 
 
 
 
10
 
11
- If you're interested in AI development or cybersecurity, I can help you build projects that prioritize safety, ethics, and responsible use. Would you like to explore any of these alternative directions instead?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Ethical AI Chat Assistant</title>
7
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
8
+ <style>
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ box-sizing: border-box;
13
+ }
14
 
15
+ body {
16
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
17
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
18
+ min-height: 100vh;
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ padding: 20px;
23
+ }
24
 
25
+ .app-container {
26
+ width: 100%;
27
+ max-width: 800px;
28
+ background: rgba(255, 255, 255, 0.95);
29
+ backdrop-filter: blur(10px);
30
+ border-radius: 20px;
31
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
32
+ overflow: hidden;
33
+ display: flex;
34
+ flex-direction: column;
35
+ height: 90vh;
36
+ max-height: 700px;
37
+ }
38
 
39
+ .header {
40
+ background: linear-gradient(135deg, #667eea, #764ba2);
41
+ color: white;
42
+ padding: 20px;
43
+ text-align: center;
44
+ position: relative;
45
+ }
46
+
47
+ .header h1 {
48
+ font-size: 1.8rem;
49
+ margin-bottom: 5px;
50
+ }
51
+
52
+ .header p {
53
+ opacity: 0.9;
54
+ font-size: 0.9rem;
55
+ }
56
+
57
+ .api-config {
58
+ background: #f8f9fa;
59
+ padding: 15px;
60
+ border-bottom: 1px solid #e9ecef;
61
+ }
62
+
63
+ .config-group {
64
+ display: flex;
65
+ gap: 10px;
66
+ align-items: center;
67
+ flex-wrap: wrap;
68
+ }
69
+
70
+ .config-group input {
71
+ flex: 1;
72
+ min-width: 200px;
73
+ padding: 8px 12px;
74
+ border: 1px solid #ddd;
75
+ border-radius: 8px;
76
+ font-size: 14px;
77
+ }
78
+
79
+ .config-group button {
80
+ padding: 8px 16px;
81
+ background: #667eea;
82
+ color: white;
83
+ border: none;
84
+ border-radius: 8px;
85
+ cursor: pointer;
86
+ transition: background 0.3s;
87
+ }
88
+
89
+ .config-group button:hover {
90
+ background: #5a67d8;
91
+ }
92
+
93
+ .status-indicator {
94
+ font-size: 12px;
95
+ color: #666;
96
+ margin-top: 5px;
97
+ }
98
+
99
+ .chat-container {
100
+ flex: 1;
101
+ display: flex;
102
+ flex-direction: column;
103
+ overflow: hidden;
104
+ }
105
+
106
+ .messages {
107
+ flex: 1;
108
+ overflow-y: auto;
109
+ padding: 20px;
110
+ background: #fff;
111
+ }
112
+
113
+ .message {
114
+ margin-bottom: 20px;
115
+ display: flex;
116
+ align-items: flex-start;
117
+ gap: 12px;
118
+ }
119
+
120
+ .message.user {
121
+ flex-direction: row-reverse;
122
+ }
123
+
124
+ .message-avatar {
125
+ width: 40px;
126
+ height: 40px;
127
+ border-radius: 50%;
128
+ display: flex;
129
+ align-items: center;
130
+ justify-content: center;
131
+ color: white;
132
+ font-weight: bold;
133
+ flex-shrink: 0;
134
+ }
135
+
136
+ .message.user .message-avatar {
137
+ background: linear-gradient(135deg, #667eea, #764ba2);
138
+ }
139
+
140
+ .message.assistant .message-avatar {
141
+ background: linear-gradient(135deg, #ff6b6b, #ee5a24);
142
+ }
143
+
144
+ .message-content {
145
+ max-width: 70%;
146
+ padding: 15px 20px;
147
+ border-radius: 18px;
148
+ line-height: 1.5;
149
+ word-wrap: break-word;
150
+ }
151
+
152
+ .message.user .message-content {
153
+ background: linear-gradient(135deg, #667eea, #764ba2);
154
+ color: white;
155
+ }
156
+
157
+ .message.assistant .message-content {
158
+ background: #f1f3f4;
159
+ color: #333;
160
+ }
161
+
162
+ .input-container {
163
+ padding: 20px;
164
+ background: #f8f9fa;
165
+ border-top: 1px solid #e9ecef;
166
+ }
167
+
168
+ .input-group {
169
+ display: flex;
170
+ gap: 10px;
171
+ align-items: flex-end;
172
+ }
173
+
174
+ .input-group textarea {
175
+ flex: 1;
176
+ min-height: 50px;
177
+ max-height: 120px;
178
+ padding: 12px 15px;
179
+ border: 1px solid #ddd;
180
+ border-radius: 25px;
181
+ resize: vertical;
182
+ font-family: inherit;
183
+ font-size: 14px;
184
+ outline: none;
185
+ transition: border-color 0.3s;
186
+ }
187
+
188
+ .input-group textarea:focus {
189
+ border-color: #667eea;
190
+ }
191
+
192
+ .send-button {
193
+ width: 50px;
194
+ height: 50px;
195
+ border-radius: 50%;
196
+ background: linear-gradient(135deg, #667eea, #764ba2);
197
+ color: white;
198
+ border: none;
199
+ cursor: pointer;
200
+ display: flex;
201
+ align-items: center;
202
+ justify-content: center;
203
+ transition: transform 0.3s, box-shadow 0.3s;
204
+ }
205
+
206
+ .send-button:hover {
207
+ transform: translateY(-2px);
208
+ box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
209
+ }
210
+
211
+ .send-button:disabled {
212
+ opacity: 0.6;
213
+ cursor: not-allowed;
214
+ transform: none;
215
+ }
216
+
217
+ .safety-notice {
218
+ background: #e3f2fd;
219
+ color: #1565c0;
220
+ padding: 10px 15px;
221
+ border-radius: 8px;
222
+ font-size: 12px;
223
+ margin-bottom: 10px;
224
+ border-left: 4px solid #2196f3;
225
+ }
226
+
227
+ .typing-indicator {
228
+ padding: 10px 20px;
229
+ background: #f1f3f4;
230
+ border-radius: 18px;
231
+ display: inline-flex;
232
+ gap: 5px;
233
+ margin-bottom: 20px;
234
+ }
235
+
236
+ .typing-dot {
237
+ width: 8px;
238
+ height: 8px;
239
+ border-radius: 50%;
240
+ background: #999;
241
+ animation: typing 1.4s infinite;
242
+ }
243
+
244
+ .typing-dot:nth-child(2) {
245
+ animation-delay: 0.2s;
246
+ }
247
+
248
+ .typing-dot:nth-child(3) {
249
+ animation-delay: 0.4s;
250
+ }
251
+
252
+ @keyframes typing {
253
+ 0%, 60%, 100% {
254
+ transform: translateY(0);
255
+ opacity: 0.3;
256
+ }
257
+ 30% {
258
+ transform: translateY(-10px);
259
+ opacity: 1;
260
+ }
261
+ }
262
+
263
+ .loading {
264
+ display: flex;
265
+ align-items: center;
266
+ gap: 10px;
267
+ color: #666;
268
+ font-size: 14px;
269
+ }
270
+
271
+ .loading::after {
272
+ content: '';
273
+ width: 16px;
274
+ height: 16px;
275
+ border: 2px solid #667eea;
276
+ border-top: 2px solid transparent;
277
+ border-radius: 50%;
278
+ animation: spin 1s linear infinite;
279
+ }
280
+
281
+ @keyframes spin {
282
+ to {
283
+ transform: rotate(360deg);
284
+ }
285
+ }
286
+
287
+ @media (max-width: 768px) {
288
+ .app-container {
289
+ height: 95vh;
290
+ max-height: none;
291
+ border-radius: 0;
292
+ }
293
+
294
+ .config-group {
295
+ flex-direction: column;
296
+ align-items: stretch;
297
+ }
298
+
299
+ .config-group input {
300
+ min-width: unset;
301
+ }
302
+
303
+ .message-content {
304
+ max-width: 85%;
305
+ }
306
+ }
307
+
308
+ .brand {
309
+ color: #333;
310
+ text-decoration: none;
311
+ font-weight: bold;
312
+ display: inline-flex;
313
+ align-items: center;
314
+ gap: 5px;
315
+ }
316
+
317
+ .brand:hover {
318
+ color: #667eea;
319
+ }
320
+ </style>
321
+ </head>
322
+ <body>
323
+ <div class="app-container">
324
+ <div class="header">
325
+ <h1><i class="fas fa-robot"></i> Ethical AI Chat Assistant</h1>
326
+ <p>Responsible AI powered conversations with built-in safety measures</p>
327
+ <div style="margin-top: 10px; font-size: 12px;">
328
+ Built with <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="brand" target="_blank">anycoder</a>
329
+ </div>
330
+ </div>
331
+
332
+ <div class="api-config">
333
+ <div class="config-group">
334
+ <input type="text" id="apiKey" placeholder="Enter your OpenAI API key (sk-...)" />
335
+ <input type="text" id="modelName" placeholder="Model (default: gpt-3.5-turbo)" value="gpt-3.5-turbo" />
336
+ <button onclick="saveConfig()"><i class="fas fa-save"></i> Save</button>
337
+ </div>
338
+ <div class="status-indicator" id="status">
339
+ <i class="fas fa-info-circle"></i> Enter your API key to start chatting
340
+ </div>
341
+ </div>
342
+
343
+ <div class="safety-notice">
344
+ <i class="fas fa-shield-alt"></i> This chat assistant includes safety guidelines to promote responsible AI use and prevent harmful content generation.
345
+ </div>
346
+
347
+ <div class="chat-container">
348
+ <div class="messages" id="messages">
349
+ <div class="message assistant">
350
+ <div class="message-avatar">AI</div>
351
+ <div class="message-content">
352
+ Hello! I'm an ethical AI assistant designed to help with legitimate tasks while maintaining safety guidelines.
353
+ Please configure your API key above to begin our conversation.
354
+ </div>
355
+ </div>
356
+ </div>
357
+ </div>
358
+
359
+ <div class="input-container">
360
+ <div class="input-group">
361
+ <textarea id="messageInput" placeholder="Type your message here... (remember to follow safety guidelines)"
362
+ onkeydown="handleKeyDown(event)"></textarea>
363
+ <button class="send-button" id="sendButton" onclick="sendMessage()">
364
+ <i class="fas fa-paper-plane"></i>
365
+ </button>
366
+ </div>
367
+ </div>
368
+ </div>
369
+
370
+ <script>
371
+ class EthicalChatApp {
372
+ constructor() {
373
+ this.apiKey = '';
374
+ this.model = 'gpt-3.5-turbo';
375
+ this.isLoading = false;
376
+ this.messages = [];
377
+
378
+ this.loadConfig();
379
+ this.initializeEventListeners();
380
+ this.updateUI();
381
+ }
382
+
383
+ loadConfig() {
384
+ this.apiKey = localStorage.getItem('openai_api_key') || '';
385
+ this.model = localStorage.getItem('openai_model') || 'gpt-3.5-turbo';
386
+
387
+ document.getElementById('apiKey').value = this.apiKey;
388
+ document.getElementById('modelName').value = this.model;
389
+
390
+ this.updateStatus();
391
+ }
392
+
393
+ saveConfig() {
394
+ this.apiKey = document.getElementById('apiKey').value.trim();
395
+ this.model = document.getElementById('modelName').value.trim() || 'gpt-3.5-turbo';
396
+
397
+ if (this.apiKey) {
398
+ localStorage.setItem('openai_api_key', this.apiKey);
399
+ localStorage.setItem('openai_model', this.model);
400
+ this.updateStatus();
401
+ this.showMessage('Configuration saved successfully!', 'assistant');
402
+ } else {
403
+ this.updateStatus('Please enter a valid API key', 'error');
404
+ }
405
+ }
406
+
407
+ updateStatus(message = '', type = 'info') {
408
+ const statusEl = document.getElementById('status');
409
+ const icon = type === 'error' ? 'exclamation-triangle' :
410
+ type === 'success' ? 'check-circle' : 'info-circle';
411
+ const color = type === 'error' ? '#e74c3c' :
412
+ type === 'success' ? '#27ae60' : '#666';
413
+
414
+ statusEl.innerHTML = `<i class="fas fa-${icon}" style="color: ${color}"></i> ${message || (this.apiKey ? 'Ready to chat!' : 'Enter your API key to start chatting')}`;
415
+ }
416
+
417
+ async sendMessage() {
418
+ const input = document.getElementById('messageInput');
419
+ const message = input.value.trim();
420
+
421
+ if (!message || this.isLoading) return;
422
+ if (!this.apiKey) {
423
+ this.updateStatus('Please configure your API key first', 'error');
424
+ return;
425
+ }
426
+
427
+ input.value = '';
428
+ this.isLoading = true;
429
+ this.updateUI();
430
+
431
+ // Add user message
432
+ this.addMessage(message, 'user');
433
+
434
+ // Show typing indicator
435
+ this.showTypingIndicator();
436
+
437
+ try {
438
+ const response = await this.callOpenAI(message);
439
+ this.removeTypingIndicator();
440
+ this.addMessage(response, 'assistant');
441
+ } catch (error) {
442
+ this.removeTypingIndicator();
443
+ this.addMessage(`Error: ${error.message}`, 'assistant');
444
+ console.error('API Error:', error);
445
+ } finally {
446
+ this.isLoading = false;
447
+ this.updateUI();
448
+ }
449
+ }
450
+
451
+ async callOpenAI(message) {
452
+ const messages = this.buildMessageHistory(message);
453
+
454
+ const response = await fetch('https://api.openai.com/v1/chat/completions', {
455
+ method: 'POST',
456
+ headers: {
457
+ 'Content-Type': 'application/json',
458
+ 'Authorization': `Bearer ${this.apiKey}`
459
+ },
460
+ body: JSON.stringify({
461
+ model: this.model,
462
+ messages: messages,
463
+ max_tokens: 1000,
464
+ temperature: 0.7,
465
+ presence_penalty: 0.1,
466
+ frequency_penalty: 0.1
467
+ })
468
+ });
469
+
470
+ if (!response.ok) {
471
+ const error = await response.json();
472
+ throw new Error(error.error?.message || 'API request failed');
473
+ }
474
+
475
+ const data = await response.json();
476
+ return data.choices[0].message.content;
477
+ }
478
+
479
+ buildMessageHistory(currentMessage) {
480
+ const systemPrompt = `You are an ethical AI assistant designed to be helpful, harmless, and honest.
481
+
482
+ IMPORTANT SAFETY GUIDELINES:
483
+ - Do not provide instructions for creating harmful substances, weapons, or illegal activities
484
+ - Do not generate content that promotes violence, discrimination, or hatred
485
+ - Do not provide detailed information for dangerous or illegal purposes
486
+ - Do not impersonate real people or create fake credentials
487
+ - Encourage positive, constructive conversations
488
+ - Be honest about your limitations and uncertainties
489
+ - Provide helpful responses while maintaining ethical standards
490
+
491
+ Always prioritize safety and responsible AI use in your responses.`;
492
+
493
+ const messages = [
494
+ { role: 'system', content: systemPrompt },
495
+ ...this.messages.slice(-10), // Keep last 10 messages for context
496
+ { role: 'user', content: currentMessage }
497
+ ];
498
+
499
+ this.messages.push({ role: 'user', content: currentMessage });
500
+ return messages;
501
+ }
502
+
503
+ addMessage(content, sender) {
504
+ const messagesEl = document.getElementById('messages');
505
+ const messageEl = document.createElement('div');
506
+ messageEl.className = `message ${sender}`;
507
+
508
+ const avatar = sender === 'user' ? 'U' : 'AI';
509
+ const avatarClass = sender === 'user' ? 'user' : 'assistant';
510
+
511
+ messageEl.innerHTML = `
512
+ <div class="message-avatar">${avatar}</div>
513
+ <div class="message-content">${this.formatMessage(content)}</div>
514
+ `;
515
+
516
+ messagesEl.appendChild(messageEl);
517
+ messagesEl.scrollTop = messagesEl.scrollHeight;
518
+
519
+ if (sender === 'assistant') {
520
+ this.messages.push({ role: 'assistant', content: content });
521
+ }
522
+ }
523
+
524
+ formatMessage(content) {
525
+ return content
526
+ .replace(/\n/g, '<br>')
527
+ .replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
528
+ .replace(/\*(.*?)\*/g, '<em>$1</em>')
529
+ .replace(/`(.*?)`/g, '<code style="background: #f4f4f4; padding: 2px 4px; border-radius: 3px;">$1</code>');
530
+ }
531
+
532
+ showTypingIndicator() {
533
+ const messagesEl = document.getElementById('messages');
534
+ const typingEl = document.createElement('div');
535
+ typingEl.className = 'message assistant';
536
+ typingEl.id = 'typing-indicator';
537
+ typingEl.innerHTML = `
538
+ <div class="message-avatar">AI</div>
539
+ <div class="message-content">
540
+ <div class="typing-indicator">
541
+ <div class="typing-dot"></div>
542
+ <div class="typing-dot"></div>
543
+ <div class="typing-dot"></div>
544
+ </div>
545
+ </div>
546
+ `;
547
+ messagesEl.appendChild(typingEl);
548
+ messagesEl.scrollTop = messagesEl.scrollHeight;
549
+ }
550
+
551
+ removeTypingIndicator() {
552
+ const typingEl = document.getElementById('typing-indicator');
553
+ if (typingEl) {
554
+ typingEl.remove();
555
+ }
556
+ }
557
+
558
+ updateUI() {
559
+ const sendButton = document.getElementById('sendButton');
560
+ const input = document.getElementById('messageInput');
561
+
562
+ sendButton.disabled = this.isLoading || !this.apiKey;
563
+ input.disabled = this.isLoading;
564
+ }
565
+
566
+ initializeEventListeners() {
567
+ document.getElementById('messageInput').addEventListener('input', () => {
568
+ this.updateUI();
569
+ });
570
+ }
571
+ }
572
+
573
+ // Global functions
574
+ let chatApp;
575
+
576
+ function saveConfig() {
577
+ chatApp.saveConfig();
578
+ }
579
+
580
+ function sendMessage() {
581
+ chatApp.sendMessage();
582
+ }
583
+
584
+ function handleKeyDown(event) {
585
+ if (event.key === 'Enter' && !event.shiftKey) {
586
+ event.preventDefault();
587
+ sendMessage();
588
+ }
589
+ }
590
+
591
+ // Initialize the application
592
+ document.addEventListener('DOMContentLoaded', () => {
593
+ chatApp = new EthicalChatApp();
594
+ });
595
+ </script>
596
+ </body>
597
+ </html>