Crate ai chat interface
Browse files- README.md +8 -5
- components/chat-sidebar.js +51 -0
- components/navbar.js +32 -0
- index.html +69 -19
- script.js +60 -0
- style.css +28 -19
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: NeuralNest Chat - AI Conversations in the Cloud 🪺
|
| 3 |
+
colorFrom: gray
|
| 4 |
+
colorTo: red
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
components/chat-sidebar.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomChatSidebar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
.sidebar {
|
| 7 |
+
width: 260px;
|
| 8 |
+
height: 100%;
|
| 9 |
+
overflow-y: auto;
|
| 10 |
+
}
|
| 11 |
+
.conversation-item:hover {
|
| 12 |
+
background-color: rgba(79, 70, 229, 0.1);
|
| 13 |
+
}
|
| 14 |
+
.dark .conversation-item:hover {
|
| 15 |
+
background-color: rgba(99, 102, 241, 0.2);
|
| 16 |
+
}
|
| 17 |
+
</style>
|
| 18 |
+
<aside class="sidebar border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800">
|
| 19 |
+
<div class="p-4">
|
| 20 |
+
<button class="w-full flex items-center justify-center space-x-2 bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg transition-colors">
|
| 21 |
+
<i data-feather="plus" class="w-4 h-4"></i>
|
| 22 |
+
<span>New Chat</span>
|
| 23 |
+
</button>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div class="px-2">
|
| 27 |
+
<h3 class="px-2 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2">Recent Conversations</h3>
|
| 28 |
+
<div class="space-y-1">
|
| 29 |
+
<div class="conversation-item px-3 py-2 rounded-lg cursor-pointer flex items-center space-x-2">
|
| 30 |
+
<i data-feather="message-square" class="text-gray-500 dark:text-gray-400 w-4 h-4"></i>
|
| 31 |
+
<span class="text-sm text-gray-800 dark:text-gray-200 truncate">Website design ideas</span>
|
| 32 |
+
</div>
|
| 33 |
+
<div class="conversation-item px-3 py-2 rounded-lg cursor-pointer flex items-center space-x-2">
|
| 34 |
+
<i data-feather="message-square" class="text-gray-500 dark:text-gray-400 w-4 h-4"></i>
|
| 35 |
+
<span class="text-sm text-gray-800 dark:text-gray-200 truncate">Marketing strategy</span>
|
| 36 |
+
</div>
|
| 37 |
+
<div class="conversation-item px-3 py-2 rounded-lg cursor-pointer flex items-center space-x-2">
|
| 38 |
+
<i data-feather="message-square" class="text-gray-500 dark:text-gray-400 w-4 h-4"></i>
|
| 39 |
+
<span class="text-sm text-gray-800 dark:text-gray-200 truncate">Content calendar</span>
|
| 40 |
+
</div>
|
| 41 |
+
<div class="conversation-item px-3 py-2 rounded-lg cursor-pointer flex items-center space-x-2">
|
| 42 |
+
<i data-feather="message-square" class="text-gray-500 dark:text-gray-400 w-4 h-4"></i>
|
| 43 |
+
<span class="text-sm text-gray-800 dark:text-gray-200 truncate">Social media tips</span>
|
| 44 |
+
</div>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</aside>
|
| 48 |
+
`;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
customElements.define('custom-chat-sidebar', CustomChatSidebar);
|
components/navbar.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CustomNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
.navbar {
|
| 7 |
+
height: 60px;
|
| 8 |
+
backdrop-filter: blur(10px);
|
| 9 |
+
}
|
| 10 |
+
</style>
|
| 11 |
+
<nav class="navbar border-b border-gray-200 dark:border-gray-700 bg-white/80 dark:bg-gray-800/80">
|
| 12 |
+
<div class="max-w-7xl mx-auto px-4 h-full flex items-center justify-between">
|
| 13 |
+
<div class="flex items-center space-x-2">
|
| 14 |
+
<div class="w-8 h-8 rounded-full bg-indigo-600 flex items-center justify-center">
|
| 15 |
+
<i data-feather="cpu" class="text-white w-4 h-4"></i>
|
| 16 |
+
</div>
|
| 17 |
+
<span class="font-bold text-gray-800 dark:text-white">NeuralNest</span>
|
| 18 |
+
</div>
|
| 19 |
+
<div class="flex items-center space-x-4">
|
| 20 |
+
<button class="w-8 h-8 rounded-full flex items-center justify-center text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
| 21 |
+
<i data-feather="moon"></i>
|
| 22 |
+
</button>
|
| 23 |
+
<button class="w-8 h-8 rounded-full flex items-center justify-center text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors">
|
| 24 |
+
<i data-feather="settings"></i>
|
| 25 |
+
</button>
|
| 26 |
+
</div>
|
| 27 |
+
</div>
|
| 28 |
+
</nav>
|
| 29 |
+
`;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
customElements.define('custom-navbar', CustomNavbar);
|
index.html
CHANGED
|
@@ -1,19 +1,69 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en" class="h-full">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>NeuralNest Chat</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<script src="components/navbar.js"></script>
|
| 12 |
+
<script src="components/chat-sidebar.js"></script>
|
| 13 |
+
</head>
|
| 14 |
+
<body class="bg-gray-50 dark:bg-gray-900 h-full flex flex-col">
|
| 15 |
+
<custom-navbar></custom-navbar>
|
| 16 |
+
|
| 17 |
+
<div class="flex flex-1 overflow-hidden">
|
| 18 |
+
<custom-chat-sidebar></custom-chat-sidebar>
|
| 19 |
+
|
| 20 |
+
<main class="flex-1 flex flex-col bg-white dark:bg-gray-800 overflow-hidden">
|
| 21 |
+
<!-- Chat header -->
|
| 22 |
+
<div class="border-b border-gray-200 dark:border-gray-700 p-4 flex items-center">
|
| 23 |
+
<div class="flex items-center space-x-3">
|
| 24 |
+
<div class="w-10 h-10 rounded-full bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center">
|
| 25 |
+
<i data-feather="cpu" class="text-indigo-600 dark:text-indigo-300"></i>
|
| 26 |
+
</div>
|
| 27 |
+
<div>
|
| 28 |
+
<h2 class="font-semibold text-gray-800 dark:text-gray-100">AI Assistant</h2>
|
| 29 |
+
<p class="text-xs text-gray-500 dark:text-gray-400">Online</p>
|
| 30 |
+
</div>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<!-- Chat messages -->
|
| 35 |
+
<div id="chat-messages" class="flex-1 overflow-y-auto p-4 space-y-4">
|
| 36 |
+
<!-- Messages will be inserted here by JavaScript -->
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
<!-- Message input -->
|
| 40 |
+
<div class="border-t border-gray-200 dark:border-gray-700 p-4">
|
| 41 |
+
<form id="message-form" class="flex space-x-2">
|
| 42 |
+
<input
|
| 43 |
+
type="text"
|
| 44 |
+
id="message-input"
|
| 45 |
+
placeholder="Type your message..."
|
| 46 |
+
class="flex-1 px-4 py-2 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent text-gray-800 dark:text-gray-100"
|
| 47 |
+
autocomplete="off"
|
| 48 |
+
>
|
| 49 |
+
<button
|
| 50 |
+
type="submit"
|
| 51 |
+
class="w-10 h-10 rounded-full bg-indigo-600 hover:bg-indigo-700 text-white flex items-center justify-center transition-colors"
|
| 52 |
+
>
|
| 53 |
+
<i data-feather="send"></i>
|
| 54 |
+
</button>
|
| 55 |
+
</form>
|
| 56 |
+
<p class="text-xs text-gray-500 dark:text-gray-400 mt-2 text-center">
|
| 57 |
+
NeuralNest may produce inaccurate information about people, places, or facts.
|
| 58 |
+
</p>
|
| 59 |
+
</div>
|
| 60 |
+
</main>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
+
<script src="script.js"></script>
|
| 64 |
+
<script>
|
| 65 |
+
feather.replace();
|
| 66 |
+
</script>
|
| 67 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 68 |
+
</body>
|
| 69 |
+
</html>
|
script.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 2 |
+
const messageForm = document.getElementById('message-form');
|
| 3 |
+
const messageInput = document.getElementById('message-input');
|
| 4 |
+
const chatMessages = document.getElementById('chat-messages');
|
| 5 |
+
|
| 6 |
+
// Sample AI responses
|
| 7 |
+
const aiResponses = [
|
| 8 |
+
"I'm analyzing your request...",
|
| 9 |
+
"That's an interesting question!",
|
| 10 |
+
"Let me think about that for a moment.",
|
| 11 |
+
"Based on my knowledge, here's what I found...",
|
| 12 |
+
"I'd be happy to help with that!"
|
| 13 |
+
];
|
| 14 |
+
|
| 15 |
+
// Add a sample welcome message
|
| 16 |
+
addMessage('ai', "Hello! I'm your AI assistant. How can I help you today?");
|
| 17 |
+
|
| 18 |
+
messageForm.addEventListener('submit', (e) => {
|
| 19 |
+
e.preventDefault();
|
| 20 |
+
const message = messageInput.value.trim();
|
| 21 |
+
|
| 22 |
+
if (message) {
|
| 23 |
+
// Add user message
|
| 24 |
+
addMessage('user', message);
|
| 25 |
+
messageInput.value = '';
|
| 26 |
+
|
| 27 |
+
// Simulate AI thinking
|
| 28 |
+
setTimeout(() => {
|
| 29 |
+
const randomResponse = aiResponses[Math.floor(Math.random() * aiResponses.length)];
|
| 30 |
+
addMessage('ai', randomResponse);
|
| 31 |
+
}, 1000 + Math.random() * 2000);
|
| 32 |
+
}
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
function addMessage(sender, text) {
|
| 36 |
+
const messageElement = document.createElement('div');
|
| 37 |
+
messageElement.classList.add('message');
|
| 38 |
+
|
| 39 |
+
if (sender === 'user') {
|
| 40 |
+
messageElement.innerHTML = `
|
| 41 |
+
<div class="flex justify-end">
|
| 42 |
+
<div class="max-w-xs md:max-w-md lg:max-w-lg bg-indigo-600 text-white rounded-2xl px-4 py-2">
|
| 43 |
+
${text}
|
| 44 |
+
</div>
|
| 45 |
+
</div>
|
| 46 |
+
`;
|
| 47 |
+
} else {
|
| 48 |
+
messageElement.innerHTML = `
|
| 49 |
+
<div class="flex justify-start">
|
| 50 |
+
<div class="max-w-xs md:max-w-md lg:max-w-lg bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-100 rounded-2xl px-4 py-2">
|
| 51 |
+
${text}
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
`;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
chatMessages.appendChild(messageElement);
|
| 58 |
+
chatMessages.scrollTop = chatMessages.scrollHeight;
|
| 59 |
+
}
|
| 60 |
+
});
|
style.css
CHANGED
|
@@ -1,28 +1,37 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
margin-top: 0;
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
.
|
| 27 |
-
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Custom scrollbar */
|
| 2 |
+
::-webkit-scrollbar {
|
| 3 |
+
width: 6px;
|
| 4 |
}
|
| 5 |
|
| 6 |
+
::-webkit-scrollbar-track {
|
| 7 |
+
background: rgba(0, 0, 0, 0.05);
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
+
::-webkit-scrollbar-thumb {
|
| 11 |
+
background: rgba(0, 0, 0, 0.2);
|
| 12 |
+
border-radius: 3px;
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
|
| 15 |
+
.dark ::-webkit-scrollbar-track {
|
| 16 |
+
background: rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
|
| 19 |
+
.dark ::-webkit-scrollbar-thumb {
|
| 20 |
+
background: rgba(255, 255, 255, 0.2);
|
| 21 |
}
|
| 22 |
+
|
| 23 |
+
/* Animation for message appearance */
|
| 24 |
+
@keyframes messageAppear {
|
| 25 |
+
from {
|
| 26 |
+
opacity: 0;
|
| 27 |
+
transform: translateY(10px);
|
| 28 |
+
}
|
| 29 |
+
to {
|
| 30 |
+
opacity: 1;
|
| 31 |
+
transform: translateY(0);
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.message {
|
| 36 |
+
animation: messageAppear 0.3s ease-out forwards;
|
| 37 |
+
}
|