cripterhack commited on
Commit
fd5aae3
·
verified ·
1 Parent(s): 858bc1e

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +508 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Devai
3
- emoji: 🔥
4
  colorFrom: red
5
- colorTo: blue
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: devai
3
+ emoji: 🐳
4
  colorFrom: red
5
+ colorTo: purple
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,508 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>DevAI - AI-Powered Development Platform</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #6e8efb, #a777e3);
12
+ }
13
+ .sidebar-item:hover {
14
+ background-color: rgba(255, 255, 255, 0.1);
15
+ transform: translateX(5px);
16
+ }
17
+ .code-block {
18
+ font-family: 'Courier New', monospace;
19
+ background-color: #2d3748;
20
+ border-radius: 0.5rem;
21
+ }
22
+ .terminal {
23
+ background-color: #1a202c;
24
+ font-family: 'Courier New', monospace;
25
+ border-radius: 0.5rem;
26
+ }
27
+ .model-card:hover {
28
+ transform: translateY(-5px);
29
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
30
+ }
31
+ .animate-pulse {
32
+ animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
33
+ }
34
+ @keyframes pulse {
35
+ 0%, 100% {
36
+ opacity: 1;
37
+ }
38
+ 50% {
39
+ opacity: 0.5;
40
+ }
41
+ }
42
+ #terminal-output {
43
+ height: 300px;
44
+ overflow-y: auto;
45
+ }
46
+ </style>
47
+ </head>
48
+ <body class="bg-gray-100 font-sans">
49
+ <div class="flex h-screen overflow-hidden">
50
+ <!-- Sidebar -->
51
+ <div class="hidden md:flex md:flex-shrink-0">
52
+ <div class="flex flex-col w-64 gradient-bg text-white">
53
+ <div class="flex items-center h-16 px-4 border-b border-white/20">
54
+ <div class="flex items-center">
55
+ <i class="fas fa-robot text-2xl mr-2"></i>
56
+ <span class="text-xl font-bold">DevAI</span>
57
+ </div>
58
+ </div>
59
+ <div class="flex flex-col flex-grow overflow-y-auto">
60
+ <div class="px-4 py-4">
61
+ <div class="text-xs font-semibold uppercase tracking-wider text-white/60 mb-4">MAIN MENU</div>
62
+ <nav class="space-y-1">
63
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
64
+ <i class="fas fa-home mr-3"></i>
65
+ Dashboard
66
+ </a>
67
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
68
+ <i class="fas fa-project-diagram mr-3"></i>
69
+ Projects
70
+ </a>
71
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
72
+ <i class="fas fa-code mr-3"></i>
73
+ Code Generator
74
+ </a>
75
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
76
+ <i class="fas fa-vial mr-3"></i>
77
+ Testing
78
+ </a>
79
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
80
+ <i class="fas fa-rocket mr-3"></i>
81
+ Deployment
82
+ </a>
83
+ </nav>
84
+ </div>
85
+ <div class="px-4 py-4 border-t border-white/20">
86
+ <div class="text-xs font-semibold uppercase tracking-wider text-white/60 mb-4">AI MODELS</div>
87
+ <nav class="space-y-1">
88
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
89
+ <i class="fas fa-brain mr-3"></i>
90
+ Ollama Models
91
+ </a>
92
+ <a href="#" class="sidebar-item flex items-center px-4 py-3 rounded-lg text-white transition-all duration-200">
93
+ <i class="fas fa-sliders-h mr-3"></i>
94
+ Model Settings
95
+ </a>
96
+ </nav>
97
+ </div>
98
+ <div class="px-4 py-4 mt-auto border-t border-white/20">
99
+ <div class="flex items-center">
100
+ <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="">
101
+ <div class="ml-3">
102
+ <p class="text-sm font-medium text-white">DevAI User</p>
103
+ <p class="text-xs font-medium text-white/60">Developer</p>
104
+ </div>
105
+ </div>
106
+ </div>
107
+ </div>
108
+ </div>
109
+ </div>
110
+
111
+ <!-- Main content -->
112
+ <div class="flex flex-col flex-1 overflow-hidden">
113
+ <!-- Top navigation -->
114
+ <div class="flex items-center justify-between h-16 px-6 bg-white border-b border-gray-200">
115
+ <div class="flex items-center">
116
+ <button class="md:hidden text-gray-500 focus:outline-none">
117
+ <i class="fas fa-bars"></i>
118
+ </button>
119
+ <div class="relative ml-4">
120
+ <div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
121
+ <i class="fas fa-search text-gray-400"></i>
122
+ </div>
123
+ <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...">
124
+ </div>
125
+ </div>
126
+ <div class="flex items-center space-x-4">
127
+ <button id="ollama-status-btn" class="p-1 text-gray-400 rounded-full hover:text-gray-500 focus:outline-none">
128
+ <i class="fas fa-plug"></i>
129
+ </button>
130
+ <button class="p-1 text-gray-400 rounded-full hover:text-gray-500 focus:outline-none">
131
+ <i class="fas fa-cog"></i>
132
+ </button>
133
+ </div>
134
+ </div>
135
+
136
+ <!-- Main content area -->
137
+ <div class="flex-1 overflow-auto p-6">
138
+ <div class="mb-6">
139
+ <h1 class="text-2xl font-bold text-gray-800">Welcome to DevAI!</h1>
140
+ <p class="text-gray-600">AI-powered development environment with Ollama integration</p>
141
+ </div>
142
+
143
+ <!-- Quick actions -->
144
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
145
+ <div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
146
+ <div class="flex items-center mb-4">
147
+ <div class="p-3 rounded-full bg-blue-100 text-blue-600 mr-4">
148
+ <i class="fas fa-plus"></i>
149
+ </div>
150
+ <h3 class="text-lg font-semibold">New Project</h3>
151
+ </div>
152
+ <p class="text-gray-600 mb-4">Start a new project with AI-powered scaffolding</p>
153
+ <button class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors duration-200">
154
+ Create Project
155
+ </button>
156
+ </div>
157
+ <div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
158
+ <div class="flex items-center mb-4">
159
+ <div class="p-3 rounded-full bg-purple-100 text-purple-600 mr-4">
160
+ <i class="fas fa-code"></i>
161
+ </div>
162
+ <h3 class="text-lg font-semibold">Code Generator</h3>
163
+ </div>
164
+ <p class="text-gray-600 mb-4">Generate code with AI based on your requirements</p>
165
+ <button class="w-full py-2 px-4 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors duration-200">
166
+ Generate Code
167
+ </button>
168
+ </div>
169
+ <div class="bg-white rounded-xl shadow-sm p-6 hover:shadow-md transition-shadow duration-200">
170
+ <div class="flex items-center mb-4">
171
+ <div class="p-3 rounded-full bg-green-100 text-green-600 mr-4">
172
+ <i class="fas fa-rocket"></i>
173
+ </div>
174
+ <h3 class="text-lg font-semibold">Deploy</h3>
175
+ </div>
176
+ <p class="text-gray-600 mb-4">Deploy your project with one click</p>
177
+ <button class="w-full py-2 px-4 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors duration-200">
178
+ Deploy Now
179
+ </button>
180
+ </div>
181
+ </div>
182
+
183
+ <!-- AI Code Generation Section -->
184
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
185
+ <div class="bg-white rounded-xl shadow-sm p-6">
186
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">AI Code Generation</h2>
187
+ <div class="mb-4">
188
+ <label for="prompt" class="block text-sm font-medium text-gray-700 mb-1">Describe what you want to build</label>
189
+ <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>
190
+ </div>
191
+ <div class="mb-4">
192
+ <label for="tech-stack" class="block text-sm font-medium text-gray-700 mb-1">Tech Stack</label>
193
+ <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">
194
+ <option>React + TypeScript</option>
195
+ <option>Vue.js</option>
196
+ <option>Angular</option>
197
+ <option>Node.js + Express</option>
198
+ <option>Python + FastAPI</option>
199
+ <option>Django</option>
200
+ <option>Flask</option>
201
+ <option>Other</option>
202
+ </select>
203
+ </div>
204
+ <div class="mb-4">
205
+ <label for="model-select" class="block text-sm font-medium text-gray-700 mb-1">AI Model</label>
206
+ <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">
207
+ <option value="codellama">CodeLlama</option>
208
+ <option value="llama2">Llama 2</option>
209
+ <option value="mistral">Mistral</option>
210
+ </select>
211
+ </div>
212
+ <div class="flex justify-between">
213
+ <button class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300 transition-colors duration-200">
214
+ <i class="fas fa-sliders-h mr-2"></i> Advanced
215
+ </button>
216
+ <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">
217
+ <i class="fas fa-magic mr-2"></i> Generate Code
218
+ </button>
219
+ </div>
220
+ </div>
221
+
222
+ <div class="bg-white rounded-xl shadow-sm p-6">
223
+ <div class="flex justify-between items-center mb-4">
224
+ <h2 class="text-xl font-semibold text-gray-800">Generated Code</h2>
225
+ <div class="flex space-x-2">
226
+ <button id="copy-code-btn" class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
227
+ <i class="fas fa-copy"></i>
228
+ </button>
229
+ <button class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
230
+ <i class="fas fa-download"></i>
231
+ </button>
232
+ <button class="p-2 text-gray-500 hover:text-gray-700 rounded-full hover:bg-gray-100">
233
+ <i class="fas fa-code-branch"></i>
234
+ </button>
235
+ </div>
236
+ </div>
237
+ <div class="code-block p-4 mb-4 h-96 overflow-y-auto">
238
+ <pre id="generated-code" class="text-gray-300 text-sm"><code>// Your generated code will appear here</code></pre>
239
+ </div>
240
+ <div class="flex justify-between">
241
+ <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">
242
+ <i class="fas fa-redo mr-2"></i> Regenerate
243
+ </button>
244
+ <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">
245
+ <i class="fas fa-check mr-2"></i> Accept Code
246
+ </button>
247
+ </div>
248
+ </div>
249
+ </div>
250
+
251
+ <!-- Ollama Model Management -->
252
+ <div class="bg-white rounded-xl shadow-sm p-6 mt-8">
253
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Ollama Model Management</h2>
254
+ <div id="models-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
255
+ <!-- Models will be loaded here dynamically -->
256
+ </div>
257
+ <div class="mt-6">
258
+ <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">
259
+ <i class="fas fa-sync-alt mr-2"></i> Refresh Models
260
+ </button>
261
+ </div>
262
+ </div>
263
+
264
+ <!-- Terminal Output -->
265
+ <div class="bg-white rounded-xl shadow-sm p-6 mt-8">
266
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Terminal Output</h2>
267
+ <div id="terminal-output" class="terminal p-4 overflow-y-auto">
268
+ <div class="text-green-400">$ DevAI initialized</div>
269
+ <div class="text-gray-300">Connecting to Ollama...</div>
270
+ <div class="text-gray-300" id="ollama-status">Status: Checking Ollama connection...</div>
271
+ </div>
272
+ <div class="mt-4 flex">
273
+ <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...">
274
+ <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">
275
+ <i class="fas fa-arrow-right"></i>
276
+ </button>
277
+ </div>
278
+ </div>
279
+ </div>
280
+ </div>
281
+ </div>
282
+
283
+ <!-- Docker Setup Instructions Modal -->
284
+ <div id="docker-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
285
+ <div class="bg-white rounded-lg p-6 max-w-2xl w-full">
286
+ <div class="flex justify-between items-center mb-4">
287
+ <h3 class="text-xl font-semibold">Docker Setup Instructions</h3>
288
+ <button id="close-docker-modal" class="text-gray-500 hover:text-gray-700">
289
+ <i class="fas fa-times"></i>
290
+ </button>
291
+ </div>
292
+ <div class="mb-4">
293
+ <h4 class="font-medium mb-2">1. Install Docker</h4>
294
+ <p class="text-sm text-gray-600 mb-2">Make sure you have Docker installed on your system:</p>
295
+ <div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
296
+ <pre class="text-sm"># For Ubuntu/Debian
297
+ sudo apt-get update
298
+ sudo apt-get install docker.io docker-compose
299
+
300
+ # For Mac
301
+ brew install docker docker-compose
302
+
303
+ # For Windows
304
+ Download Docker Desktop from docker.com</pre>
305
+ </div>
306
+ </div>
307
+ <div class="mb-4">
308
+ <h4 class="font-medium mb-2">2. Install Ollama</h4>
309
+ <p class="text-sm text-gray-600 mb-2">Install Ollama for local LLM processing:</p>
310
+ <div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
311
+ <pre class="text-sm"># For Linux/Mac
312
+ curl -fsSL https://ollama.com/install.sh | sh
313
+
314
+ # For Windows
315
+ Download installer from ollama.com</pre>
316
+ </div>
317
+ </div>
318
+ <div class="mb-4">
319
+ <h4 class="font-medium mb-2">3. Pull a Model</h4>
320
+ <p class="text-sm text-gray-600 mb-2">Download a model to use with Ollama:</p>
321
+ <div class="bg-gray-800 text-white p-3 rounded-lg mb-4">
322
+ <pre class="text-sm">ollama pull llama2
323
+ ollama pull codellama
324
+ ollama pull mistral</pre>
325
+ </div>
326
+ </div>
327
+ <div class="mb-4">
328
+ <h4 class="font-medium mb-2">4. Run the DevAI Stack</h4>
329
+ <p class="text-sm text-gray-600 mb-2">Start the development environment:</p>
330
+ <div class="bg-gray-800 text-white p-3 rounded-lg">
331
+ <pre class="text-sm">docker-compose up -d</pre>
332
+ </div>
333
+ </div>
334
+ <div class="mt-6 flex justify-end">
335
+ <button id="confirm-docker-setup" class="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700">
336
+ I've completed these steps
337
+ </button>
338
+ </div>
339
+ </div>
340
+ </div>
341
+
342
+ <script>
343
+ document.addEventListener('DOMContentLoaded', function() {
344
+ // Check if Ollama is running
345
+ async function checkOllamaStatus() {
346
+ try {
347
+ const response = await fetch('http://localhost:11434/api/tags');
348
+ if (response.ok) {
349
+ const data = await response.json();
350
+ document.getElementById('ollama-status').innerHTML = `Status: Connected to Ollama (${data.models.length} models available)`;
351
+ document.getElementById('ollama-status-btn').innerHTML = '<i class="fas fa-plug text-green-500"></i>';
352
+ loadAvailableModels();
353
+ } else {
354
+ throw new Error('Ollama not running');
355
+ }
356
+ } catch (error) {
357
+ document.getElementById('ollama-status').innerHTML = 'Status: Ollama not running. Please start Ollama service.';
358
+ document.getElementById('ollama-status-btn').innerHTML = '<i class="fas fa-plug text-red-500"></i>';
359
+ // Show Docker setup instructions
360
+ document.getElementById('docker-modal').classList.remove('hidden');
361
+ }
362
+ }
363
+
364
+ // Load available models from Ollama
365
+ async function loadAvailableModels() {
366
+ try {
367
+ const response = await fetch('http://localhost:11434/api/tags');
368
+ const data = await response.json();
369
+ const modelsContainer = document.getElementById('models-container');
370
+ modelsContainer.innerHTML = '';
371
+
372
+ data.models.forEach(model => {
373
+ const modelCard = document.createElement('div');
374
+ modelCard.className = 'model-card bg-gray-50 rounded-lg p-4 border border-gray-200 transition-all duration-200';
375
+ modelCard.innerHTML = `
376
+ <div class="flex items-center mb-3">
377
+ <div class="p-2 rounded-full bg-blue-100 text-blue-600 mr-3">
378
+ <i class="fas fa-brain"></i>
379
+ </div>
380
+ <h3 class="font-medium">${model.name}</h3>
381
+ </div>
382
+ <p class="text-sm text-gray-600 mb-3">Model size: ${(model.size/1000000000).toFixed(1)}GB</p>
383
+ <div class="flex justify-between items-center">
384
+ <span class="text-xs px-2 py-1 bg-green-100 text-green-800 rounded-full">Available</span>
385
+ <button class="text-xs text-blue-600 hover:text-blue-800" onclick="setActiveModel('${model.name}')">Use</button>
386
+ </div>
387
+ `;
388
+ modelsContainer.appendChild(modelCard);
389
+ });
390
+ } catch (error) {
391
+ console.error('Error loading models:', error);
392
+ }
393
+ }
394
+
395
+ // Set active model
396
+ window.setActiveModel = function(modelName) {
397
+ document.getElementById('model-select').value = modelName.split(':')[0];
398
+ addTerminalOutput(`Model set to: ${modelName}`, 'gray-300');
399
+ }
400
+
401
+ // Generate code with Ollama
402
+ async function generateCode() {
403
+ const prompt = document.getElementById('prompt').value;
404
+ const techStack = document.getElementById('tech-stack').value;
405
+ const model = document.getElementById('model-select').value;
406
+
407
+ if (!prompt.trim()) {
408
+ alert('Please enter a description of what you want to build');
409
+ return;
410
+ }
411
+
412
+ const generateBtn = document.getElementById('generate-code-btn');
413
+ const originalText = generateBtn.innerHTML;
414
+ generateBtn.innerHTML = '<i class="fas fa-spinner animate-spin mr-2"></i> Generating...';
415
+ generateBtn.disabled = true;
416
+
417
+ addTerminalOutput(`Generating ${techStack} code with ${model}...`, 'gray-300');
418
+
419
+ try {
420
+ const response = await fetch('http://localhost:11434/api/generate', {
421
+ method: 'POST',
422
+ headers: {
423
+ 'Content-Type': 'application/json'
424
+ },
425
+ body: JSON.stringify({
426
+ model: model,
427
+ prompt: `Generate ${techStack} code for: ${prompt}. Provide only the code with no additional explanation or markdown formatting.`,
428
+ stream: false
429
+ })
430
+ });
431
+
432
+ if (response.ok) {
433
+ const data = await response.json();
434
+ document.getElementById('generated-code').innerHTML = `<code class="text-gray-300">${data.response.replace(/```/g, '').replace(/\n/g, '<br>')}</code>`;
435
+ addTerminalOutput('Code generation complete!', 'green-400');
436
+ } else {
437
+ throw new Error('Code generation failed');
438
+ }
439
+ } catch (error) {
440
+ console.error('Error generating code:', error);
441
+ addTerminalOutput('Error generating code. Make sure Ollama is running.', 'red-500');
442
+ } finally {
443
+ generateBtn.innerHTML = originalText;
444
+ generateBtn.disabled = false;
445
+ }
446
+ }
447
+
448
+ // Terminal functions
449
+ function addTerminalOutput(text, colorClass = 'gray-300') {
450
+ const terminal = document.getElementById('terminal-output');
451
+ const outputLine = document.createElement('div');
452
+ outputLine.className = `text-${colorClass}`;
453
+ outputLine.innerHTML = `$ ${text}`;
454
+ terminal.appendChild(outputLine);
455
+ terminal.scrollTop = terminal.scrollHeight;
456
+ }
457
+
458
+ // Event listeners
459
+ document.getElementById('generate-code-btn').addEventListener('click', generateCode);
460
+ document.getElementById('regenerate-btn').addEventListener('click', generateCode);
461
+
462
+ document.getElementById('copy-code-btn').addEventListener('click', function() {
463
+ const code = document.getElementById('generated-code').textContent;
464
+ navigator.clipboard.writeText(code);
465
+ addTerminalOutput('Code copied to clipboard', 'blue-400');
466
+ });
467
+
468
+ document.getElementById('refresh-models-btn').addEventListener('click', loadAvailableModels);
469
+
470
+ document.getElementById('terminal-send-btn').addEventListener('click', function() {
471
+ const input = document.getElementById('terminal-input').value;
472
+ if (input.trim()) {
473
+ addTerminalOutput(input, 'green-400');
474
+ document.getElementById('terminal-input').value = '';
475
+
476
+ // Simple command processing
477
+ if (input === 'clear') {
478
+ document.getElementById('terminal-output').innerHTML = '';
479
+ } else if (input.startsWith('ollama pull')) {
480
+ const model = input.split(' ')[2];
481
+ addTerminalOutput(`Pulling ${model}... This may take several minutes.`, 'yellow-400');
482
+ } else {
483
+ addTerminalOutput('Command not recognized', 'red-400');
484
+ }
485
+ }
486
+ });
487
+
488
+ document.getElementById('terminal-input').addEventListener('keypress', function(e) {
489
+ if (e.key === 'Enter') {
490
+ document.getElementById('terminal-send-btn').click();
491
+ }
492
+ });
493
+
494
+ document.getElementById('close-docker-modal').addEventListener('click', function() {
495
+ document.getElementById('docker-modal').classList.add('hidden');
496
+ });
497
+
498
+ document.getElementById('confirm-docker-setup').addEventListener('click', function() {
499
+ document.getElementById('docker-modal').classList.add('hidden');
500
+ checkOllamaStatus();
501
+ });
502
+
503
+ // Initialize
504
+ checkOllamaStatus();
505
+ });
506
+ </script>
507
+ <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>
508
+ </html>