File size: 12,474 Bytes
af6ae45 5d04d24 af6ae45 5d04d24 af6ae45 5d04d24 af6ae45 5d04d24 af6ae45 ec1a1ed 5d04d24 ec1a1ed af6ae45 ec1a1ed e153705 f9746fe b57e0a8 e153705 af6ae45 5d04d24 af6ae45 5d04d24 af6ae45 5d04d24 af6ae45 207a58d 5d04d24 f58b1d7 5d04d24 af6ae45 5d04d24 f58b1d7 af6ae45 f58b1d7 af6ae45 297bb2c f58b1d7 297bb2c f58b1d7 297bb2c 5d04d24 297bb2c 5d04d24 297bb2c 5d04d24 297bb2c 207a58d 297bb2c 5d04d24 af6ae45 297bb2c af6ae45 297bb2c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | <!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Lab | Cosmic Canvas</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script type="module">
import { GoogleGenAI } from "https://aistudiocdn.com/@google/genai@^1.23.0";
const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY" }); // Replace with actual API key
window.ai = ai;
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Space Grotesk', sans-serif;
}
#vanta-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.gradient-text {
background: linear-gradient(90deg, #0ea5e9 0%, #8b5cf6 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.terminal {
background-color: #010409;
border: 1px solid #30363d;
color: #c9d1d9;
font-family: monospace;
}
</style>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<div id="vanta-bg"></div>
<nav class="fixed w-full z-50 bg-gray-900/80 backdrop-blur-md">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16 items-center">
<div class="flex items-center">
<span class="text-2xl font-bold gradient-text">Cosmic Canvas</span>
</div>
<div class="hidden md:flex space-x-8">
<a href="index.html" class="text-white hover:text-primary-400 transition">Home</a>
<a href="gallery.html" class="text-white hover:text-primary-400 transition">Gallery</a>
<a href="ai-lab.html" class="text-white hover:text-primary-400 transition font-bold">AI Lab</a>
<a href="about.html" class="text-white hover:text-primary-400 transition">About</a>
<a href="chat.html" class="text-white hover:text-primary-400 transition">Chat</a>
<a href="tech-stack.html" class="text-white hover:text-primary-400 transition">Tech Stack</a>
<a href="tasks.html" class="text-white hover:text-primary-400 transition">Tasks</a>
<a href="external-chat.html" class="text-white hover:text-primary-400 transition">External Chat</a>
<a href="smart-chat.html" class="text-white hover:text-primary-400 transition">Smart Chat</a>
</div>
<button class="md:hidden text-white">
<i data-feather="menu"></i>
</button>
</div>
</div>
</nav>
<main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8">
<section class="max-w-7xl mx-auto">
<h1 class="text-5xl md:text-7xl font-bold mb-6 text-center">
<span class="gradient-text">AI</span> Laboratory
</h1>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mt-12">
<div class="bg-gray-800/50 backdrop-blur-md p-6 rounded-xl border border-gray-700">
<h2 class="text-2xl font-bold mb-4">Terminal Interface</h2>
<div class="terminal p-4 h-64 overflow-y-auto mb-4" id="terminal-output">
<p>Legendary Terminal initialized...</p>
<p>Type 'help' for available commands</p>
</div>
<div class="flex">
<input type="text" id="terminal-input" class="flex-1 bg-gray-700 text-white px-4 py-2 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-primary-500" placeholder="Enter command...">
<button onclick="executeCommand()" class="bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-r-lg">
Execute
</button>
</div>
</div>
<div class="bg-gray-800/50 backdrop-blur-md p-6 rounded-xl border border-gray-700">
<h2 class="text-2xl font-bold mb-4">AI Playground</h2>
<div class="mb-4">
<label class="block text-gray-300 mb-2">Model</label>
<select id="ai-model" class="w-full bg-gray-700 text-white px-4 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500">
<option value="gemini-pro">Gemini Pro</option>
<option value="gpt-4">GPT-4</option>
</select>
</div>
<div class="mb-4">
<label class="block text-gray-300 mb-2">Language</label>
<select id="ai-language" class="w-full bg-gray-700 text-white px-4 py-2 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500">
<option value="en">English</option>
<option value="ar">العربية</option>
</select>
</div>
<div class="mb-4">
<label class="block text-gray-300 mb-2">Prompt</label>
<textarea id="ai-prompt" class="w-full bg-gray-700 text-white px-4 py-2 rounded-lg h-24 focus:outline-none focus:ring-2 focus:ring-primary-500" placeholder="اكتب رسالتك هنا / Type your message here..."></textarea>
</div>
<div id="ai-response" class="bg-gray-700 text-white p-4 rounded-lg mb-4 min-h-24 hidden">
<p class="text-gray-300">AI response will appear here...</p>
</div>
<div class="flex space-x-4">
<button id="ai-listen" class="flex-1 bg-secondary-600 hover:bg-secondary-700 text-white px-4 py-3 rounded-lg flex items-center justify-center">
<i data-feather="mic" class="mr-2"></i> Speak
</button>
<button id="ai-generate" class="flex-1 bg-primary-600 hover:bg-primary-700 text-white px-4 py-3 rounded-lg">
Generate Response
</button>
</div>
</div>
</div>
</section>
</main>
<script>
feather.replace();
// Initialize LegendaryTerminal integration
const terminalSocket = new WebSocket('ws://localhost:3000/terminal');
terminalSocket.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'terminal-output') {
const output = document.getElementById('terminal-output');
output.innerHTML += `<p>${data.content}</p>`;
output.scrollTop = output.scrollHeight;
}
};
// Speech recognition setup
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 1;
document.getElementById('ai-language').addEventListener('change', function() {
recognition.lang = this.value === 'ar' ? 'ar-SA' : 'en-US';
});
document.getElementById('ai-listen').addEventListener('click', function() {
recognition.start();
this.innerHTML = '<i data-feather="mic-off" class="mr-2"></i> Listening...';
feather.replace();
});
recognition.onresult = function(event) {
const speechResult = event.results[0][0].transcript;
document.getElementById('ai-prompt').value = speechResult;
document.getElementById('ai-listen').innerHTML = '<i data-feather="mic" class="mr-2"></i> Speak';
feather.replace();
};
recognition.onerror = function(event) {
console.error('Speech recognition error', event.error);
document.getElementById('ai-listen').innerHTML = '<i data-feather="mic" class="mr-2"></i> Speak';
feather.replace();
};
recognition.onend = function() {
document.getElementById('ai-listen').innerHTML = '<i data-feather="mic" class="mr-2"></i> Speak';
feather.replace();
};
// AI Response handling
document.getElementById('ai-generate').addEventListener('click', async function() {
const prompt = document.getElementById('ai-prompt').value;
const language = document.getElementById('ai-language').value;
const responseElement = document.getElementById('ai-response');
if (!prompt.trim()) return;
responseElement.classList.remove('hidden');
responseElement.innerHTML = '<p class="text-gray-300">جار المعالجة... / Processing...</p>';
try {
// In a real implementation, you would call your AI API here
const response = await simulateAIResponse(prompt, language);
// Display response with appropriate RTL/LTR direction
const dir = language === 'ar' ? 'rtl' : 'ltr';
responseElement.innerHTML = `<p dir="${dir}" class="${language === 'ar' ? 'text-right' : ''}">${response}</p>`;
// Speak the response
speakResponse(response, language);
} catch (error) {
responseElement.innerHTML = `<p class="text-red-400">Error: ${error.message}</p>`;
}
});
function simulateAIResponse(prompt, language) {
return new Promise((resolve) => {
setTimeout(() => {
if (language === 'ar') {
resolve(`هذا رد من الذكاء الاصطناعي على رسالتك: "${prompt}". يمكنني فهم العربية والإنجليزية.`);
} else {
resolve(`This is an AI response to your message: "${prompt}". I can understand both English and Arabic.`);
}
}, 1500);
});
}
function speakResponse(text, language) {
const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = language === 'ar' ? 'ar-SA' : 'en-US';
speechSynthesis.speak(utterance);
}
// Terminal functionality - integrated with LegendaryTerminal
function executeCommand() {
const input = document.getElementById('terminal-input').value;
const output = document.getElementById('terminal-output');
output.innerHTML += `<p><span class="text-green-400">$ ${input}</span></p>`;
document.getElementById('terminal-input').value = '';
output.scrollTop = output.scrollHeight;
// Send command to LegendaryTerminal backend
terminalSocket.send(JSON.stringify({
type: 'terminal-command',
command: input
}));
}
// WebSocket cleanup on page unload
window.addEventListener('beforeunload', () => {
terminalSocket.close();
});
// Initialize Vanta.js background
VANTA.GLOBE({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x3b82f6,
backgroundColor: 0x111827
});
</script>
<style>
#terminal-output {
font-family: 'Space Grotesk', monospace;
white-space: pre-wrap;
line-height: 1.5;
}
#terminal-input {
font-family: 'Space Grotesk', monospace;
}
</style>
</body>
</html>
|