Spaces:
Running
Running
File size: 28,906 Bytes
fd5aae3 |
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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DevAI - AI-Powered Development Platform</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.gradient-bg {
background: linear-gradient(135deg, #6e8efb, #a777e3);
}
.sidebar-item:hover {
background-color: rgba(255, 255, 255, 0.1);
transform: translateX(5px);
}
.code-block {
font-family: 'Courier New', monospace;
background-color: #2d3748;
border-radius: 0.5rem;
}
.terminal {
background-color: #1a202c;
font-family: 'Courier New', monospace;
border-radius: 0.5rem;
}
.model-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
#terminal-output {
height: 300px;
overflow-y: auto;
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<div class="hidden md:flex md:flex-shrink-0">
<div class="flex flex-col w-64 gradient-bg text-white">
<div class="flex items-center h-16 px-4 border-b border-white/20">
<div class="flex items-center">
<i class="fas fa-robot text-2xl mr-2"></i>
<span class="text-xl font-bold">DevAI</span>
</div>
</div>
<div class="flex flex-col flex-grow overflow-y-auto">
<div class="px-4 py-4">
<div class="text-xs font-semibold uppercase tracking-wider text-white/60 mb-4">MAIN MENU</div>
<nav class="space-y-1">
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-home mr-3"></i>
Dashboard
</a>
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-project-diagram mr-3"></i>
Projects
</a>
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-code mr-3"></i>
Code Generator
</a>
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-vial mr-3"></i>
Testing
</a>
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-rocket mr-3"></i>
Deployment
</a>
</nav>
</div>
<div class="px-4 py-4 border-t border-white/20">
<div class="text-xs font-semibold uppercase tracking-wider text-white/60 mb-4">AI MODELS</div>
<nav class="space-y-1">
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-brain mr-3"></i>
Ollama Models
</a>
<a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
<i class="fas fa-sliders-h mr-3"></i>
Model Settings
</a>
</nav>
</div>
<div class="px-4 py-4 mt-auto border-t border-white/20">
<div class="flex items-center">
<img class="h-10 w-10 rounded-full" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="">
<div class="ml-3">
<p class="text-sm font-medium text-white">DevAI User</p>
<p class="text-xs font-medium text-white/60">Developer</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Main content -->
<div class="flex flex-col flex-1 overflow-hidden">
<!-- Top navigation -->
<div class="flex items-center justify-between h-16 px-6 bg-white border-b border-gray-200">
<div class="flex items-center">
<button class="md:hidden text-gray-500 focus:outline-none">
<i class="fas fa-bars"></i>
</button>
<div class="relative ml-4">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
<i class="fas fa-search text-gray-400"></i>
</div>
<input type="text" class="block w-full py-2 pl-10 pr-3 text-sm bg-gray-100 border border-transparent rounded-lg focus:bg-white focus:border-gray-300 focus:ring-0" placeholder="Search projects, files...">
</div>
</div>
<div class="flex items-center space-x-4">
<button id="ollama-status-btn" class="p-1 text-gray-400 rounded-full hover:text-gray-500 focus:outline-none">
<i class="fas fa-plug"></i>
</button>
<button class="p-1 text-gray-400 rounded-full hover:text-gray-500 focus:outline-none">
<i class="fas fa-cog"></i>
</button>
</div>
</div>
<!-- Main content area -->
<div class="flex-1 overflow-auto p-6">
<div class="mb-6">
<h1 class="text-2xl font-bold text-gray-800">Welcome to DevAI!</h1>
<p class="text-gray-600">AI-powered development environment with Ollama integration</p>
</div>
<!-- Quick actions -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
<div class="flex items-center mb-4">
<div class="p-3 rounded-full bg-blue-100 text-blue-600 mr-4">
<i class="fas fa-plus"></i>
</div>
<h3 class="text-lg font-semibold">New Project</h3>
</div>
<p class="text-gray-600 mb-4">Start a new project with AI-powered scaffolding</p>
<button class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors duration-200">
Create Project
</button>
</div>
<div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
<div class="flex items-center mb-4">
<div class="p-3 rounded-full bg-purple-100 text-purple-600 mr-4">
<i class="fas fa-code"></i>
</div>
<h3 class="text-lg font-semibold">Code Generator</h3>
</div>
<p class="text-gray-600 mb-4">Generate code with AI based on your requirements</p>
<button class="w-full py-2 px-4 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors duration-200">
Generate Code
</button>
</div>
<div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
<div class="flex items-center mb-4">
<div class="p-3 rounded-full bg-green-100 text-green-600 mr-4">
<i class="fas fa-rocket"></i>
</div>
<h3 class="text-lg font-semibold">Deploy</h3>
</div>
<p class="text-gray-600 mb-4">Deploy your project with one click</p>
<button class="w-full py-2 px-4 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors duration-200">
Deploy Now
</button>
</div>
</div>
<!-- AI Code Generation Section -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white rounded-xl shadow-sm p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">AI Code Generation</h2>
<div class="mb-4">
<label for="prompt" class="block text-sm font-medium text-gray-700 mb-1">Describe what you want to build</label>
<textarea id="prompt" rows="4" class="w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:ring-1 focus:ring-blue-500" placeholder="e.g. Create a React component for a login form with email and password fields, validation, and a submit button..."></textarea>
</div>
<div class="mb-4">
<label for="tech-stack" class="block text-sm font-medium text-gray-700 mb-1">Tech Stack</label>
<select id="tech-stack" class="w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:ring-1 focus:ring-blue-500">
<option>React + TypeScript</option>
<option>Vue.js</option>
<option>Angular</option>
<option>Node.js + Express</option>
<option>Python + FastAPI</option>
<option>Django</option>
<option>Flask</option>
<option>Other</option>
</select>
</div>
<div class="mb-4">
<label for="model-select" class="block text-sm font-medium text-gray-700 mb-1">AI Model</label>
<select id="model-select" class="w-full px-3 py-2 text-gray-700 border rounded-lg focus:outline-none focus:ring-1 focus:ring-blue-500">
<option value="codellama">CodeLlama</option>
<option value="llama2">Llama 2</option>
<option value="mistral">Mistral</option>
</select>
</div>
<div class="flex justify-between">
<button class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors duration-200">
<i class="fas fa-sliders-h mr-2"></i> Advanced
</button>
<button id="generate-code-btn" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200">
<i class="fas fa-magic mr-2"></i> Generate Code
</button>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Generated Code</h2>
<div class="flex space-x-2">
<button id="copy-code-btn" class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
<i class="fas fa-copy"></i>
</button>
<button class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
<i class="fas fa-download"></i>
</button>
<button class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
<i class="fas fa-code-branch"></i>
</button>
</div>
</div>
<div class="code-block p-4 mb-4 h-96 overflow-y-auto">
<pre id="generated-code" class="text-gray-300 text-sm"><code>// Your generated code will appear here</code></pre>
</div>
<div class="flex justify-between">
<button id="regenerate-btn" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors duration-200">
<i class="fas fa-redo mr-2"></i> Regenerate
</button>
<button id="accept-code-btn" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors duration-200">
<i class="fas fa-check mr-2"></i> Accept Code
</button>
</div>
</div>
</div>
<!-- Ollama Model Management -->
<div class="bg-white rounded-xl shadow-sm p-6 mt-8">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Ollama Model Management</h2>
<div id="models-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<!-- Models will be loaded here dynamically -->
</div>
<div class="mt-6">
<button id="refresh-models-btn" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200">
<i class="fas fa-sync-alt mr-2"></i> Refresh Models
</button>
</div>
</div>
<!-- Terminal Output -->
<div class="bg-white rounded-xl shadow-sm p-6 mt-8">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Terminal Output</h2>
<div id="terminal-output" class="terminal p-4 overflow-y-auto">
<div class="text-green-400">$ DevAI initialized</div>
<div class="text-gray-300">Connecting to Ollama...</div>
<div class="text-gray-300" id="ollama-status">Status: Checking Ollama connection...</div>
</div>
<div class="mt-4 flex">
<input id="terminal-input" type="text" class="flex-grow px-3 py-2 text-gray-700 border rounded-l-lg focus:outline-none focus:ring-1 focus:ring-blue-500" placeholder="Enter command...">
<button id="terminal-send-btn" class="px-4 py-2 bg-blue-600 text-white rounded-r-lg hover:bg-blue-700 transition-colors duration-200">
<i class="fas fa-arrow-right"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Docker Setup Instructions Modal -->
<div id="docker-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
<div class="bg-white rounded-lg p-6 max-w-2xl w-full">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold">Docker Setup Instructions</h3>
<button id="close-docker-modal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<h4 class="font-medium mb-2">1. Install Docker</h4>
<p class="text-sm text-gray-600 mb-2">Make sure you have Docker installed on your system:</p>
<div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
<pre class="text-sm"># For Ubuntu/Debian
sudo apt-get update
sudo apt-get install docker.io docker-compose
# For Mac
brew install docker docker-compose
# For Windows
Download Docker Desktop from docker.com</pre>
</div>
</div>
<div class="mb-4">
<h4 class="font-medium mb-2">2. Install Ollama</h4>
<p class="text-sm text-gray-600 mb-2">Install Ollama for local LLM processing:</p>
<div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
<pre class="text-sm"># For Linux/Mac
curl -fsSL https://ollama.com/install.sh | sh
# For Windows
Download installer from ollama.com</pre>
</div>
</div>
<div class="mb-4">
<h4 class="font-medium mb-2">3. Pull a Model</h4>
<p class="text-sm text-gray-600 mb-2">Download a model to use with Ollama:</p>
<div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
<pre class="text-sm">ollama pull llama2
ollama pull codellama
ollama pull mistral</pre>
</div>
</div>
<div class="mb-4">
<h4 class="font-medium mb-2">4. Run the DevAI Stack</h4>
<p class="text-sm text-gray-600 mb-2">Start the development environment:</p>
<div class="bg-gray-800 text-white p-3 rounded-lg">
<pre class="text-sm">docker-compose up -d</pre>
</div>
</div>
<div class="mt-6 flex justify-end">
<button id="confirm-docker-setup" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
I've completed these steps
</button>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Check if Ollama is running
async function checkOllamaStatus() {
try {
const response = await fetch('http://localhost:11434/api/tags');
if (response.ok) {
const data = await response.json();
document.getElementById('ollama-status').innerHTML = `Status: Connected to Ollama (${data.models.length} models available)`;
document.getElementById('ollama-status-btn').innerHTML = '<i class="fas fa-plug text-green-500"></i>';
loadAvailableModels();
} else {
throw new Error('Ollama not running');
}
} catch (error) {
document.getElementById('ollama-status').innerHTML = 'Status: Ollama not running. Please start Ollama service.';
document.getElementById('ollama-status-btn').innerHTML = '<i class="fas fa-plug text-red-500"></i>';
// Show Docker setup instructions
document.getElementById('docker-modal').classList.remove('hidden');
}
}
// Load available models from Ollama
async function loadAvailableModels() {
try {
const response = await fetch('http://localhost:11434/api/tags');
const data = await response.json();
const modelsContainer = document.getElementById('models-container');
modelsContainer.innerHTML = '';
data.models.forEach(model => {
const modelCard = document.createElement('div');
modelCard.className = 'model-card bg-gray-50 rounded-lg p-4 border border-gray-200 transition-all duration-200';
modelCard.innerHTML = `
<div class="flex items-center mb-3">
<div class="p-2 rounded-full bg-blue-100 text-blue-600 mr-3">
<i class="fas fa-brain"></i>
</div>
<h3 class="font-medium">${model.name}</h3>
</div>
<p class="text-sm text-gray-600 mb-3">Model size: ${(model.size/1000000000).toFixed(1)}GB</p>
<div class="flex justify-between items-center">
<span class="text-xs px-2 py-1 bg-green-100 text-green-800 rounded-full">Available</span>
<button class="text-xs text-blue-600 hover:text-blue-800" onclick="setActiveModel('${model.name}')">Use</button>
</div>
`;
modelsContainer.appendChild(modelCard);
});
} catch (error) {
console.error('Error loading models:', error);
}
}
// Set active model
window.setActiveModel = function(modelName) {
document.getElementById('model-select').value = modelName.split(':')[0];
addTerminalOutput(`Model set to: ${modelName}`, 'gray-300');
}
// Generate code with Ollama
async function generateCode() {
const prompt = document.getElementById('prompt').value;
const techStack = document.getElementById('tech-stack').value;
const model = document.getElementById('model-select').value;
if (!prompt.trim()) {
alert('Please enter a description of what you want to build');
return;
}
const generateBtn = document.getElementById('generate-code-btn');
const originalText = generateBtn.innerHTML;
generateBtn.innerHTML = '<i class="fas fa-spinner animate-spin mr-2"></i> Generating...';
generateBtn.disabled = true;
addTerminalOutput(`Generating ${techStack} code with ${model}...`, 'gray-300');
try {
const response = await fetch('http://localhost:11434/api/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: model,
prompt: `Generate ${techStack} code for: ${prompt}. Provide only the code with no additional explanation or markdown formatting.`,
stream: false
})
});
if (response.ok) {
const data = await response.json();
document.getElementById('generated-code').innerHTML = `<code class="text-gray-300">${data.response.replace(/```/g, '').replace(/\n/g, '<br>')}</code>`;
addTerminalOutput('Code generation complete!', 'green-400');
} else {
throw new Error('Code generation failed');
}
} catch (error) {
console.error('Error generating code:', error);
addTerminalOutput('Error generating code. Make sure Ollama is running.', 'red-500');
} finally {
generateBtn.innerHTML = originalText;
generateBtn.disabled = false;
}
}
// Terminal functions
function addTerminalOutput(text, colorClass = 'gray-300') {
const terminal = document.getElementById('terminal-output');
const outputLine = document.createElement('div');
outputLine.className = `text-${colorClass}`;
outputLine.innerHTML = `$ ${text}`;
terminal.appendChild(outputLine);
terminal.scrollTop = terminal.scrollHeight;
}
// Event listeners
document.getElementById('generate-code-btn').addEventListener('click', generateCode);
document.getElementById('regenerate-btn').addEventListener('click', generateCode);
document.getElementById('copy-code-btn').addEventListener('click', function() {
const code = document.getElementById('generated-code').textContent;
navigator.clipboard.writeText(code);
addTerminalOutput('Code copied to clipboard', 'blue-400');
});
document.getElementById('refresh-models-btn').addEventListener('click', loadAvailableModels);
document.getElementById('terminal-send-btn').addEventListener('click', function() {
const input = document.getElementById('terminal-input').value;
if (input.trim()) {
addTerminalOutput(input, 'green-400');
document.getElementById('terminal-input').value = '';
// Simple command processing
if (input === 'clear') {
document.getElementById('terminal-output').innerHTML = '';
} else if (input.startsWith('ollama pull')) {
const model = input.split(' ')[2];
addTerminalOutput(`Pulling ${model}... This may take several minutes.`, 'yellow-400');
} else {
addTerminalOutput('Command not recognized', 'red-400');
}
}
});
document.getElementById('terminal-input').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
document.getElementById('terminal-send-btn').click();
}
});
document.getElementById('close-docker-modal').addEventListener('click', function() {
document.getElementById('docker-modal').classList.add('hidden');
});
document.getElementById('confirm-docker-setup').addEventListener('click', function() {
document.getElementById('docker-modal').classList.add('hidden');
checkOllamaStatus();
});
// Initialize
checkOllamaStatus();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=cripterhack/devai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |