Spaces:
Running

moazelgen commited on
Commit
b57e0a8
·
verified ·
1 Parent(s): f9746fe

عايز طرفيه محادثه فعليه زكيه

Browse files
Files changed (3) hide show
  1. ai-lab.html +1 -0
  2. index.html +1 -0
  3. smart-chat.html +208 -0
ai-lab.html CHANGED
@@ -58,6 +58,7 @@
58
  <a href="tech-stack.html" class="text-white hover:text-primary-400 transition">Tech Stack</a>
59
  <a href="tasks.html" class="text-white hover:text-primary-400 transition">Tasks</a>
60
  <a href="external-chat.html" class="text-white hover:text-primary-400 transition">External Chat</a>
 
61
  </div>
62
  <button class="md:hidden text-white">
63
  <i data-feather="menu"></i>
 
58
  <a href="tech-stack.html" class="text-white hover:text-primary-400 transition">Tech Stack</a>
59
  <a href="tasks.html" class="text-white hover:text-primary-400 transition">Tasks</a>
60
  <a href="external-chat.html" class="text-white hover:text-primary-400 transition">External Chat</a>
61
+ <a href="smart-chat.html" class="text-white hover:text-primary-400 transition">Smart Chat</a>
62
  </div>
63
  <button class="md:hidden text-white">
64
  <i data-feather="menu"></i>
index.html CHANGED
@@ -83,6 +83,7 @@
83
  <a href="tech-stack.html" class="text-white hover:text-primary-400 transition">Tech Stack</a>
84
  <a href="tasks.html" class="text-white hover:text-primary-400 transition">Tasks</a>
85
  <a href="external-chat.html" class="text-white hover:text-primary-400 transition">External Chat</a>
 
86
  </div>
87
  <button class="md:hidden text-white">
88
  <i data-feather="menu"></i>
 
83
  <a href="tech-stack.html" class="text-white hover:text-primary-400 transition">Tech Stack</a>
84
  <a href="tasks.html" class="text-white hover:text-primary-400 transition">Tasks</a>
85
  <a href="external-chat.html" class="text-white hover:text-primary-400 transition">External Chat</a>
86
+ <a href="smart-chat.html" class="text-white hover:text-primary-400 transition">Smart Chat</a>
87
  </div>
88
  <button class="md:hidden text-white">
89
  <i data-feather="menu"></i>
smart-chat.html ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="scroll-smooth">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Smart Chat | Cosmic Canvas</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/feather-icons"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
10
+ <style>
11
+ @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
12
+ body {
13
+ font-family: 'Space Grotesk', sans-serif;
14
+ }
15
+ #vanta-bg {
16
+ position: absolute;
17
+ top: 0;
18
+ left: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ z-index: -1;
22
+ }
23
+ .gradient-text {
24
+ background: linear-gradient(90deg, #0ea5e9 0%, #8b5cf6 100%);
25
+ -webkit-background-clip: text;
26
+ background-clip: text;
27
+ color: transparent;
28
+ }
29
+ .chat-container {
30
+ height: 70vh;
31
+ scrollbar-width: thin;
32
+ scrollbar-color: #3b82f6 #1e293b;
33
+ }
34
+ .message-bubble {
35
+ max-width: 80%;
36
+ }
37
+ </style>
38
+ </head>
39
+ <body class="bg-gray-900 text-white min-h-screen">
40
+ <div id="vanta-bg"></div>
41
+
42
+ <nav class="fixed w-full z-50 bg-gray-900/80 backdrop-blur-md">
43
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
44
+ <div class="flex justify-between h-16 items-center">
45
+ <div class="flex items-center">
46
+ <span class="text-2xl font-bold gradient-text">Cosmic Canvas</span>
47
+ </div>
48
+ <div class="hidden md:flex space-x-8">
49
+ <a href="index.html" class="text-white hover:text-primary-400 transition">Home</a>
50
+ <a href="ai-lab.html" class="text-white hover:text-primary-400 transition">AI Lab</a>
51
+ <a href="smart-chat.html" class="text-white hover:text-primary-400 transition font-bold">Smart Chat</a>
52
+ <a href="about.html" class="text-white hover:text-primary-400 transition">About</a>
53
+ </div>
54
+ <button class="md:hidden text-white">
55
+ <i data-feather="menu"></i>
56
+ </button>
57
+ </div>
58
+ </div>
59
+ </nav>
60
+
61
+ <main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8">
62
+ <section class="max-w-4xl mx-auto">
63
+ <h1 class="text-4xl md:text-6xl font-bold mb-8 text-center">
64
+ <span class="gradient-text">Smart</span> Chat
65
+ </h1>
66
+
67
+ <div class="bg-gray-800/50 backdrop-blur-md rounded-xl border border-gray-700 p-6">
68
+ <div id="chat-window" class="chat-container overflow-y-auto mb-6 space-y-4">
69
+ <div class="flex justify-start">
70
+ <div class="message-bubble bg-gray-700 p-4 rounded-lg">
71
+ <p>Hello! I'm your smart AI assistant. How can I help you today?</p>
72
+ </div>
73
+ </div>
74
+ </div>
75
+
76
+ <div class="flex items-center space-x-4">
77
+ <div class="flex-1 relative">
78
+ <textarea id="chat-input" class="w-full bg-gray-700 text-white px-4 py-3 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 pr-12" placeholder="Type your message..." rows="1"></textarea>
79
+ <button id="voice-btn" class="absolute right-3 top-3 text-gray-400 hover:text-primary-400">
80
+ <i data-feather="mic"></i>
81
+ </button>
82
+ </div>
83
+ <button id="send-btn" class="bg-primary-600 hover:bg-primary-700 text-white px-6 py-3 rounded-lg">
84
+ Send
85
+ </button>
86
+ </div>
87
+ </div>
88
+ </section>
89
+ </main>
90
+
91
+ <script>
92
+ feather.replace();
93
+
94
+ // Initialize Vanta.js background
95
+ VANTA.GLOBE({
96
+ el: "#vanta-bg",
97
+ mouseControls: true,
98
+ touchControls: true,
99
+ gyroControls: false,
100
+ minHeight: 200.00,
101
+ minWidth: 200.00,
102
+ scale: 1.00,
103
+ scaleMobile: 1.00,
104
+ color: 0x3b82f6,
105
+ backgroundColor: 0x111827
106
+ });
107
+
108
+ // Chat functionality
109
+ const chatWindow = document.getElementById('chat-window');
110
+ const chatInput = document.getElementById('chat-input');
111
+ const sendBtn = document.getElementById('send-btn');
112
+ const voiceBtn = document.getElementById('voice-btn');
113
+
114
+ // Auto-resize textarea
115
+ chatInput.addEventListener('input', function() {
116
+ this.style.height = 'auto';
117
+ this.style.height = (this.scrollHeight) + 'px';
118
+ });
119
+
120
+ // Send message function
121
+ function sendMessage() {
122
+ const message = chatInput.value.trim();
123
+ if (!message) return;
124
+
125
+ // Add user message
126
+ addMessage(message, 'user');
127
+
128
+ // Clear input
129
+ chatInput.value = '';
130
+ chatInput.style.height = 'auto';
131
+
132
+ // Simulate AI response
133
+ setTimeout(() => {
134
+ const responses = [
135
+ "That's an interesting point! Could you elaborate more?",
136
+ "I understand what you're saying. Here's what I think about that...",
137
+ "Thanks for sharing! Based on my knowledge...",
138
+ "That's a great question! The answer is...",
139
+ "I've processed your input. Here's my analysis..."
140
+ ];
141
+ const randomResponse = responses[Math.floor(Math.random() * responses.length)];
142
+ addMessage(randomResponse, 'ai');
143
+ }, 1000);
144
+ }
145
+
146
+ // Add message to chat
147
+ function addMessage(text, sender) {
148
+ const messageDiv = document.createElement('div');
149
+ messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'}`;
150
+
151
+ const bubbleDiv = document.createElement('div');
152
+ bubbleDiv.className = `message-bubble ${sender === 'user' ? 'bg-primary-600' : 'bg-gray-700'} p-4 rounded-lg`;
153
+ bubbleDiv.innerHTML = `<p>${text}</p>`;
154
+
155
+ messageDiv.appendChild(bubbleDiv);
156
+ chatWindow.appendChild(messageDiv);
157
+
158
+ // Scroll to bottom
159
+ chatWindow.scrollTop = chatWindow.scrollHeight;
160
+ }
161
+
162
+ // Event listeners
163
+ sendBtn.addEventListener('click', sendMessage);
164
+ chatInput.addEventListener('keypress', function(e) {
165
+ if (e.key === 'Enter' && !e.shiftKey) {
166
+ e.preventDefault();
167
+ sendMessage();
168
+ }
169
+ });
170
+
171
+ // Voice recognition
172
+ const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
173
+ if (SpeechRecognition) {
174
+ const recognition = new SpeechRecognition();
175
+ recognition.lang = 'en-US';
176
+ recognition.interimResults = false;
177
+ recognition.maxAlternatives = 1;
178
+
179
+ voiceBtn.addEventListener('click', function() {
180
+ recognition.start();
181
+ voiceBtn.innerHTML = '<i data-feather="mic-off"></i>';
182
+ feather.replace();
183
+ });
184
+
185
+ recognition.onresult = function(event) {
186
+ const speechResult = event.results[0][0].transcript;
187
+ chatInput.value = speechResult;
188
+ chatInput.dispatchEvent(new Event('input'));
189
+ voiceBtn.innerHTML = '<i data-feather="mic"></i>';
190
+ feather.replace();
191
+ };
192
+
193
+ recognition.onerror = function(event) {
194
+ console.error('Speech recognition error', event.error);
195
+ voiceBtn.innerHTML = '<i data-feather="mic"></i>';
196
+ feather.replace();
197
+ };
198
+
199
+ recognition.onend = function() {
200
+ voiceBtn.innerHTML = '<i data-feather="mic"></i>';
201
+ feather.replace();
202
+ };
203
+ } else {
204
+ voiceBtn.style.display = 'none';
205
+ }
206
+ </script>
207
+ </body>
208
+ </html>