ParthSadaria commited on
Commit
5bb3fcf
·
verified ·
1 Parent(s): e5220c2

Update playground.html

Browse files
Files changed (1) hide show
  1. playground.html +148 -100
playground.html CHANGED
@@ -463,6 +463,24 @@
463
  .message-appear {
464
  animation: messageAppear 0.3s ease-out forwards;
465
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  </style>
467
  </head>
468
 
@@ -481,123 +499,153 @@
481
  <div id="toast" class="toast">Message copied to clipboard!</div>
482
 
483
  <!-- Chat Container -->
484
- <div class="max-w-4xl mx-auto py-8 px-4 sm:px-6 opacity-0 transform translate-y-4" id="chatWrapper">
485
- <!-- Header with Logo -->
486
- <div class="flex justify-between items-center mb-6 p-4 bg-light-darker dark:bg-dark-lighter rounded-xl shadow-lg border border-light-darker dark:border-dark-input">
487
- <div class="flex items-center">
488
- <span class="text-xl font-mono font-bold bg-gradient-to-r from-primary to-primary-light bg-clip-text text-transparent">LOKI.AI</span>
489
- <span class="ml-2 text-sm bg-light-input dark:bg-dark-input px-2 py-0.5 rounded-full text-gray-600 dark:text-gray-300">Playground</span>
490
- </div>
491
- <div class="flex space-x-2">
492
- <!-- Model Selector -->
493
- <div class="relative" id="modelSelector">
494
- <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-md text-sm flex items-center space-x-1 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm" id="modelSelectButton" aria-label="Select AI model">
495
- <span id="modelSelectDisplay">Select Model</span>
496
- <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
497
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
498
- </svg>
499
- </button>
500
- <div class="absolute mt-1 w-56 rounded-md shadow-lg bg-light-card dark:bg-dark-card ring-1 ring-black ring-opacity-5 hidden max-h-64 overflow-y-auto z-20 dropdown-transition" id="modelOptions">
501
- <div class="py-2 px-3 text-sm text-gray-600 dark:text-gray-400" id="modelLoader">Loading models...</div>
502
- </div>
503
- </div>
504
-
505
- <!-- Clear Chat Button -->
506
- <button id="clearChatButton" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Clear chat history">
507
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
508
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
509
- </svg>
510
- </button>
511
-
512
- <!-- Export Chat Button -->
513
- <button id="exportChatButton" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Export conversation">
514
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
515
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
516
- </svg>
517
- </button>
518
-
519
- <!-- Theme Toggle Button -->
520
- <button id="themeToggle" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Toggle theme">
521
- <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
522
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
523
- </svg>
524
- </button>
525
- </div>
526
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527
 
528
- <!-- Initial Input -->
529
- <div class="flex flex-col items-center justify-center space-y-6 py-12" id="initialInput">
530
- <h2 class="text-2xl font-bold bg-gradient-to-r from-primary to-primary-light bg-clip-text text-transparent">Welcome to LOKI.AI</h2>
531
- <div class="w-full max-w-2xl relative">
532
- <input type="text" id="initialChatInput"
533
- class="w-full p-4 pr-12 rounded-xl border-2 border-light-darker dark:border-dark-input bg-light-input dark:bg-dark-lighter focus:outline-none focus:ring-2 focus:ring-primary-light dark:text-white text-gray-800 shadow-lg transition-all"
534
- placeholder="What can I help you with today?">
535
- <button id="initialSendIcon" class="absolute right-4 top-4 text-gray-400 hover:text-primary transition-colors" aria-label="Send message">
536
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
537
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
538
- </svg>
539
- </button>
540
- </div>
541
- <!-- Model suggestions -->
542
- <div class="flex flex-wrap justify-center gap-2 max-w-2xl">
543
- <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Explain quantum computing</button>
544
- <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Write a poem about AI</button>
545
- <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Help debug my code</button>
546
- <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Recommend a book</button>
547
- </div>
548
- </div>
549
 
550
- <!-- Chat Area -->
551
- <div class="hidden flex-col h-[70vh] bg-light-card dark:bg-dark-lighter rounded-xl shadow-lg overflow-hidden border border-light-darker dark:border-dark-input" id="chatContainer">
552
- <!-- Fullscreen Button -->
553
- <button id="fullscreenButton" class="absolute right-4 top-4 z-10 text-gray-400 hover:text-primary dark:hover:text-primary-light transition-colors" aria-label="Fullscreen">
554
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
555
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
556
- d="M4 4h6M4 4v6M4 4l6 6M20 20h-6M20 20v-6M20 20l-6-6" />
557
  </svg>
558
- </button>
559
 
560
- <!-- Messages Area -->
561
- <div class="flex-1 overflow-y-auto p-4 space-y-5" id="chatMessages"></div>
562
-
563
- <!-- Input Area -->
564
- <div class="border-t border-light-darker dark:border-dark-input p-4 bg-light-card dark:bg-dark-lighter">
565
  <div class="relative">
566
- <textarea id="chatInput"
567
- class="w-full p-3 pr-12 rounded-xl border border-light-darker dark:border-dark-input bg-light-input dark:bg-dark-input focus:outline-none focus:ring-2 focus:ring-primary dark:focus:ring-primary-light text-gray-800 dark:text-white transition-all shadow-inner resize-none min-h-[50px] max-h-[150px]"
568
- placeholder="Type your message..." rows="1"></textarea>
569
- <button id="sendButton" class="absolute right-3 bottom-3 text-gray-400 hover:text-primary dark:hover:text-primary-light transition-colors" aria-label="Send message">
570
- <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" id="sendIcon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
571
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
572
- </svg>
573
- <div id="sendLoader" class="hidden">
574
- <div class="w-5 h-5 border-2 border-primary-light border-t-transparent rounded-full animate-spin"></div>
575
- </div>
576
- </button>
577
  </div>
578
  <div class="flex justify-between items-center mt-2">
579
- <p class="text-gray-500 text-xs">Ctrl+Enter to send</p>
580
- <p class="text-gray-500 text-xs">Models may make mistakes. Check important information.</p>
581
  </div>
 
582
  </div>
583
- </div>
584
-
585
- <script>
586
- const chatContainer = document.getElementById('chatContainer');
 
587
  const fullscreenButton = document.getElementById('fullscreenButton');
 
 
588
 
 
589
  fullscreenButton.addEventListener('click', () => {
590
- if (!document.fullscreenElement) {
591
- chatContainer.requestFullscreen();
592
- } else {
593
- document.exitFullscreen();
594
- }
 
 
 
 
 
595
  });
596
- </script>
597
 
598
- </div>
599
- </div>
 
 
 
 
 
 
 
 
600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  <!-- Watermark -->
602
  <div class="fixed bottom-2 right-4 text-sm text-gray-500 font-mono font-bold">
603
  Built By <span class="text-primary-light">🔥</span> Parth Sadaria
 
463
  .message-appear {
464
  animation: messageAppear 0.3s ease-out forwards;
465
  }
466
+ @keyframes fullscreenIn {
467
+ from { transform: scale(0.95); opacity: 0; }
468
+ to { transform: scale(1); opacity: 1; }
469
+ }
470
+ .fullscreen-animate {
471
+ animation: fullscreenIn 0.3s ease-out;
472
+ }
473
+ /* Resize handle style */
474
+ #resizeHandle {
475
+ width: 1.5rem;
476
+ height: 1.5rem;
477
+ background-color: #9CA3AF; /* gray-400 */
478
+ cursor: se-resize;
479
+ position: absolute;
480
+ right: 0.5rem;
481
+ bottom: 0.5rem;
482
+ z-index: 50;
483
+ }
484
  </style>
485
  </head>
486
 
 
499
  <div id="toast" class="toast">Message copied to clipboard!</div>
500
 
501
  <!-- Chat Container -->
502
+ <div class="max-w-4xl mx-auto py-8 px-4 sm:px-6 opacity-0 transform translate-y-4 relative" id="chatWrapper">
503
+ <!-- Header with Logo -->
504
+ <div class="flex justify-between items-center mb-6 p-4 bg-light-darker dark:bg-dark-lighter rounded-xl shadow-lg border border-light-darker dark:border-dark-input">
505
+ <div class="flex items-center">
506
+ <span class="text-xl font-mono font-bold bg-gradient-to-r from-primary to-primary-light bg-clip-text text-transparent">LOKI.AI</span>
507
+ <span class="ml-2 text-sm bg-light-input dark:bg-dark-input px-2 py-0.5 rounded-full text-gray-600 dark:text-gray-300">Playground</span>
508
+ </div>
509
+ <div class="flex space-x-2">
510
+ <!-- Model Selector -->
511
+ <div class="relative" id="modelSelector">
512
+ <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-md text-sm flex items-center space-x-1 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm" id="modelSelectButton" aria-label="Select AI model">
513
+ <span id="modelSelectDisplay">Select Model</span>
514
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
515
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
516
+ </svg>
517
+ </button>
518
+ <div class="absolute mt-1 w-56 rounded-md shadow-lg bg-light-card dark:bg-dark-card ring-1 ring-black ring-opacity-5 hidden max-h-64 overflow-y-auto z-20 dropdown-transition" id="modelOptions">
519
+ <div class="py-2 px-3 text-sm text-gray-600 dark:text-gray-400" id="modelLoader">Loading models...</div>
520
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  </div>
522
+
523
+ <!-- Clear Chat Button -->
524
+ <button id="clearChatButton" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Clear chat history">
525
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
526
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
527
+ </svg>
528
+ </button>
529
+
530
+ <!-- Export Chat Button -->
531
+ <button id="exportChatButton" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Export conversation">
532
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
533
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
534
+ </svg>
535
+ </button>
536
+
537
+ <!-- Theme Toggle Button -->
538
+ <button id="themeToggle" class="p-2 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors bg-light-input dark:bg-dark-input shadow-sm group" aria-label="Toggle theme">
539
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 text-gray-500 group-hover:text-primary dark:text-gray-400 dark:group-hover:text-primary-light transition-colors" fill="none" viewBox="0 0 24 24" stroke="currentColor">
540
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
541
+ </svg>
542
+ </button>
543
+ </div>
544
+ </div>
545
 
546
+ <!-- Initial Input -->
547
+ <div class="flex flex-col items-center justify-center space-y-6 py-12" id="initialInput">
548
+ <h2 class="text-2xl font-bold bg-gradient-to-r from-primary to-primary-light bg-clip-text text-transparent">Welcome to LOKI.AI</h2>
549
+ <div class="w-full max-w-2xl relative">
550
+ <input type="text" id="initialChatInput" class="w-full p-4 pr-12 rounded-xl border-2 border-light-darker dark:border-dark-input bg-light-input dark:bg-dark-lighter focus:outline-none focus:ring-2 focus:ring-primary-light dark:text-white text-gray-800 shadow-lg transition-all"
551
+ placeholder="What can I help you with today?">
552
+ <button id="initialSendIcon" class="absolute right-4 top-4 text-gray-400 hover:text-primary transition-colors" aria-label="Send message">
553
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
554
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
555
+ </svg>
556
+ </button>
557
+ </div>
558
+ <!-- Model suggestions -->
559
+ <div class="flex flex-wrap justify-center gap-2 max-w-2xl">
560
+ <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Explain quantum computing</button>
561
+ <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Write a poem about AI</button>
562
+ <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Help debug my code</button>
563
+ <button class="px-3 py-2 bg-light-input dark:bg-dark-input rounded-full text-sm hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors shadow-sm text-gray-600 dark:text-gray-300 quick-prompt">Recommend a book</button>
564
+ </div>
565
+ </div>
 
566
 
567
+ <!-- Chat Area -->
568
+ <div class="hidden flex-col h-[70vh] bg-light-card dark:bg-dark-lighter rounded-xl shadow-lg overflow-hidden border border-light-darker dark:border-dark-input" id="chatContainer">
569
+ <!-- Fullscreen Button -->
570
+ <button id="fullscreenButton" class="absolute right-4 top-4 z-10 text-gray-400 hover:text-primary dark:hover:text-primary-light transition-colors" aria-label="Fullscreen">
571
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
572
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
573
+ d="M4 4h6M4 4v6M4 4l6 6M20 20h-6M20 20v-6M20 20l-6-6" />
574
  </svg>
575
+ </button>
576
 
577
+ <!-- Messages Area -->
578
+ <div class="flex-1 overflow-y-auto p-4 space-y-5" id="chatMessages"></div>
579
+
580
+ <!-- Input Area -->
581
+ <div class="border-t border-light-darker dark:border-dark-input p-4 bg-light-card dark:bg-dark-lighter">
582
  <div class="relative">
583
+ <textarea id="chatInput" class="w-full p-3 pr-12 rounded-xl border border-light-darker dark:border-dark-input bg-light-input dark:bg-dark-input focus:outline-none focus:ring-2 focus:ring-primary dark:focus:ring-primary-light text-gray-800 dark:text-white transition-all shadow-inner resize-none min-h-[50px] max-h-[150px]" placeholder="Type your message..." rows="1"></textarea>
584
+ <button id="sendButton" class="absolute right-3 bottom-3 text-gray-400 hover:text-primary dark:hover:text-primary-light transition-colors" aria-label="Send message">
585
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" id="sendIcon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
586
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8" />
587
+ </svg>
588
+ <div id="sendLoader" class="hidden">
589
+ <div class="w-5 h-5 border-2 border-primary-light border-t-transparent rounded-full animate-spin"></div>
590
+ </div>
591
+ </button>
 
 
592
  </div>
593
  <div class="flex justify-between items-center mt-2">
594
+ <p class="text-gray-500 text-xs">Ctrl+Enter to send</p>
595
+ <p class="text-gray-500 text-xs">Models may make mistakes. Check important information.</p>
596
  </div>
597
+ </div>
598
  </div>
599
+ <!-- Resize Handle -->
600
+ <div id="resizeHandle"></div>
601
+ </div>
602
+ <script>
603
+ const chatContainer = document.getElementById('chatContainer');
604
  const fullscreenButton = document.getElementById('fullscreenButton');
605
+ const chatWrapper = document.getElementById('chatWrapper');
606
+ const resizeHandle = document.getElementById('resizeHandle');
607
 
608
+ // Fullscreen animation
609
  fullscreenButton.addEventListener('click', () => {
610
+ if (!document.fullscreenElement) {
611
+ chatContainer.requestFullscreen().then(() => {
612
+ chatContainer.classList.add('fullscreen-animate');
613
+ setTimeout(() => {
614
+ chatContainer.classList.remove('fullscreen-animate');
615
+ }, 300);
616
+ });
617
+ } else {
618
+ document.exitFullscreen();
619
+ }
620
  });
 
621
 
622
+ // Resize functionality
623
+ let isResizing = false;
624
+ let lastDownX, lastDownY;
625
+
626
+ resizeHandle.addEventListener('mousedown', (e) => {
627
+ isResizing = true;
628
+ lastDownX = e.clientX;
629
+ lastDownY = e.clientY;
630
+ e.preventDefault();
631
+ });
632
 
633
+ document.addEventListener('mousemove', (e) => {
634
+ if (!isResizing) return;
635
+ const dx = e.clientX - lastDownX;
636
+ const dy = e.clientY - lastDownY;
637
+ const newWidth = chatWrapper.offsetWidth + dx;
638
+ const newHeight = chatWrapper.offsetHeight + dy;
639
+ chatWrapper.style.width = newWidth + 'px';
640
+ chatWrapper.style.height = newHeight + 'px';
641
+ lastDownX = e.clientX;
642
+ lastDownY = e.clientY;
643
+ });
644
+
645
+ document.addEventListener('mouseup', () => {
646
+ isResizing = false;
647
+ });
648
+ </script>
649
  <!-- Watermark -->
650
  <div class="fixed bottom-2 right-4 text-sm text-gray-500 font-mono font-bold">
651
  Built By <span class="text-primary-light">🔥</span> Parth Sadaria