devai / index.html
cripterhack's picture
Add 2 files
fd5aae3 verified
<!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>