Spaces:
Running
Running
File size: 21,988 Bytes
c544ac4 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Agent Builder - CodeCollab Pro</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://unpkg.com/uuid@8.3.2/dist/uuid.min.js"></script>
</head>
<body class="bg-gray-50">
<custom-navbar></custom-navbar>
<main class="pt-20 min-h-screen">
<!-- Header -->
<section class="bg-gradient-to-r from-indigo-600 to-purple-600 text-white py-8">
<div class="container mx-auto px-6">
<h1 class="text-3xl font-bold mb-2">AI Agent Builder</h1>
<p class="text-indigo-100">Create intelligent coding agents with custom tools and capabilities</p>
</div>
</section>
<div class="container mx-auto px-6 py-8">
<div class="grid lg:grid-cols-3 gap-8">
<!-- Agent Configuration Panel -->
<div class="lg:col-span-1">
<div class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-xl font-bold text-gray-800 mb-4">Agent Configuration</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Agent Name</label>
<input type="text" id="agentName" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="My Coding Agent">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Model</label>
<select id="agentModel" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="gpt-4">GPT-4</option>
<option value="gpt-3.5-turbo">GPT-3.5 Turbo</option>
<option value="claude-3">Claude 3</option>
<option value="llama-2">Llama 2</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">System Prompt</label>
<textarea id="systemPrompt" rows="4" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="You are an expert coding assistant..."></textarea>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Temperature</label>
<input type="range" id="temperature" min="0" max="1" step="0.1" value="0.7" class="w-full">
<div class="flex justify-between text-xs text-gray-500">
<span>Precise</span>
<span id="tempValue">0.7</span>
<span>Creative</span>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Max Tokens</label>
<input type="number" id="maxTokens" value="2048" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<button id="createAgent" class="w-full bg-indigo-600 hover:bg-indigo-700 text-white font-semibold py-2 px-4 rounded-lg transition">
Create Agent
</button>
</div>
</div>
<!-- Tools Panel -->
<div class="bg-white rounded-xl shadow-lg p-6 mt-6">
<h2 class="text-xl font-bold text-gray-800 mb-4">Available Tools</h2>
<div class="space-y-2">
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="code-executor" checked class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">Code Executor</span>
</label>
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="file-system" checked class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">File System</span>
</label>
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="web-search" class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">Web Search</span>
</label>
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="api-caller" class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">API Caller</span>
</label>
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="database" class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">Database Access</span>
</label>
<label class="flex items-center space-x-3 cursor-pointer">
<input type="checkbox" class="tool-checkbox" value="git" class="w-4 h-4 text-indigo-600 rounded">
<span class="text-sm">Git Operations</span>
</label>
</div>
</div>
</div>
<!-- Main Workspace -->
<div class="lg:col-span-2">
<!-- Agent Chat Interface -->
<div class="bg-white rounded-xl shadow-lg p-6 mb-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800">Agent Workspace</h2>
<div class="flex items-center space-x-2">
<div class="w-3 h-3 bg-green-500 rounded-full animate-pulse"></div>
<span class="text-sm text-gray-600">Agent Ready</span>
</div>
</div>
<div id="chatMessages" class="bg-gray-50 rounded-lg p-4 h-96 overflow-y-auto mb-4">
<div class="text-center text-gray-500 py-8">
<i data-feather="cpu" class="w-12 h-12 mx-auto mb-3 text-gray-400"></i>
<p>Create an agent to start interacting</p>
</div>
</div>
<div class="flex space-x-2">
<input type="text" id="chatInput" placeholder="Type your message..." class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" disabled>
<button id="sendMessage" class="bg-indigo-600 hover:bg-indigo-700 text-white px-6 py-2 rounded-lg transition flex items-center space-x-2" disabled>
<i data-feather="send" class="w-4 h-4"></i>
<span>Send</span>
</button>
</div>
</div>
<!-- Tool Execution Log -->
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-bold text-gray-800">Tool Execution Log</h2>
<button id="clearLog" class="text-gray-500 hover:text-gray-700">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</div>
<div id="toolLog" class="bg-gray-900 text-gray-100 rounded-lg p-4 h-64 overflow-y-auto font-mono text-sm">
<div class="text-gray-500">Tool execution events will appear here...</div>
</div>
</div>
</div>
</div>
<!-- Saved Agents -->
<div class="mt-8">
<h2 class="text-2xl font-bold text-gray-800 mb-4">Your Agents</h2>
<div id="savedAgents" class="grid md:grid-cols-3 gap-4">
<div class="bg-white rounded-lg shadow p-4 text-center text-gray-500">
<i data-feather="package" class="w-8 h-8 mx-auto mb-2"></i>
<p>No saved agents yet</p>
</div>
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/navbar.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script>
let currentAgent = null;
let agents = [];
// Temperature slider update
document.getElementById('temperature').addEventListener('input', (e) => {
document.getElementById('tempValue').textContent = e.target.value;
});
// Create Agent
document.getElementById('createAgent').addEventListener('click', () => {
const name = document.getElementById('agentName').value || 'Unnamed Agent';
const model = document.getElementById('agentModel').value;
const systemPrompt = document.getElementById('systemPrompt').value || 'You are a helpful coding assistant.';
const temperature = parseFloat(document.getElementById('temperature').value);
const maxTokens = parseInt(document.getElementById('maxTokens').value);
const selectedTools = Array.from(document.querySelectorAll('.tool-checkbox:checked'))
.map(cb => cb.value);
const agent = {
id: uuid.v4(),
name,
model,
systemPrompt,
temperature,
maxTokens,
tools: selectedTools,
createdAt: new Date().toISOString()
};
currentAgent = agent;
agents.push(agent);
// Enable chat interface
document.getElementById('chatInput').disabled = false;
document.getElementById('sendMessage').disabled = false;
// Update UI
updateSavedAgents();
initializeChat();
addToolLog(`Agent "${name}" created with tools: ${selectedTools.join(', ')}`, 'success');
});
// Initialize Chat
function initializeChat() {
const chatMessages = document.getElementById('chatMessages');
chatMessages.innerHTML = `
<div class="mb-4">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 bg-indigo-500 rounded-full flex items-center justify-center">
<i data-feather="cpu" class="w-4 h-4 text-white"></i>
</div>
<div class="flex-1">
<div class="bg-gray-100 rounded-lg p-3">
<p class="text-sm text-gray-800">Hello! I'm ${currentAgent.name}. I have access to the following tools: ${currentAgent.tools.join(', ')}. How can I help you today?</p>
</div>
</div>
</div>
</div>
`;
feather.replace();
}
// Send Message
document.getElementById('sendMessage').addEventListener('click', sendMessage);
document.getElementById('chatInput').addEventListener('keypress', (e) => {
if (e.key === 'Enter') sendMessage();
});
function sendMessage() {
const input = document.getElementById('chatInput');
const message = input.value.trim();
if (!message || !currentAgent) return;
const chatMessages = document.getElementById('chatMessages');
// Add user message
chatMessages.innerHTML += `
<div class="mb-4">
<div class="flex items-start space-x-3 justify-end">
<div class="flex-1 text-right">
<div class="bg-indigo-600 text-white rounded-lg p-3 inline-block">
<p class="text-sm">${message}</p>
</div>
</div>
<div class="w-8 h-8 bg-gray-500 rounded-full flex items-center justify-center">
<i data-feather="user" class="w-4 h-4 text-white"></i>
</div>
</div>
</div>
`;
input.value = '';
// Simulate agent thinking and tool usage
setTimeout(() => {
addToolLog('π€ Processing request...', 'info');
simulateAgentResponse(message);
}, 1000);
}
function simulateAgentResponse(userMessage) {
const chatMessages = document.getElementById('chatMessages');
const tools = currentAgent.tools;
let response = '';
let toolUsed = '';
// Simple response simulation based on message and available tools
if (userMessage.toLowerCase().includes('run') || userMessage.toLowerCase().includes('execute')) {
if (tools.includes('code-executor')) {
toolUsed = 'code-executor';
response = 'I\'ll execute that code for you using the code executor tool.';
setTimeout(() => {
addToolLog('π§ Using code-executor tool...', 'tool');
addToolLog('β
Code executed successfully', 'success');
}, 2000);
} else {
response = 'I don\'t have access to the code executor tool. Please enable it in the agent configuration.';
}
} else if (userMessage.toLowerCase().includes('file') || userMessage.toLowerCase().includes('save')) {
if (tools.includes('file-system')) {
toolUsed = 'file-system';
response = 'I\'ll help you manage files using the file system tool.';
setTimeout(() => {
addToolLog('π Using file-system tool...', 'tool');
addToolLog('β
File operation completed', 'success');
}, 2000);
} else {
response = 'I don\'t have access to file system operations.';
}
} else if (userMessage.toLowerCase().includes('search') || userMessage.toLowerCase().includes('find')) {
if (tools.includes('web-search')) {
toolUsed = 'web-search';
response = 'Let me search for that information using the web search tool.';
setTimeout(() => {
addToolLog('π Using web-search tool...', 'tool');
addToolLog('π Found 5 relevant results', 'success');
}, 2000);
} else {
response = 'I don\'t have access to web search functionality.';
}
} else {
response = 'I understand your request. Let me help you with that task using my available capabilities.';
}
// Add agent response
setTimeout(() => {
chatMessages.innerHTML += `
<div class="mb-4">
<div class="flex items-start space-x-3">
<div class="w-8 h-8 bg-indigo-500 rounded-full flex items-center justify-center">
<i data-feather="cpu" class="w-4 h-4 text-white"></i>
</div>
<div class="flex-1">
<div class="bg-gray-100 rounded-lg p-3">
<p class="text-sm text-gray-800">${response}</p>
${toolUsed ? `<p class="text-xs text-gray-500 mt-1">Used tool: ${toolUsed}</p>` : ''}
</div>
</div>
</div>
</div>
`;
chatMessages.scrollTop = chatMessages.scrollHeight;
feather.replace();
}, 1500);
}
function addToolLog(message, type = 'info') {
const toolLog = document.getElementById('toolLog');
const timestamp = new Date().toLocaleTimeString();
const colorClass = {
'info': 'text-gray-300',
'success': 'text-green-400',
'tool': 'text-blue-400',
'error': 'text-red-400'
}[type] || 'text-gray-300';
toolLog.innerHTML += `<div class="${colorClass}">[${timestamp}] ${message}</div>`;
toolLog.scrollTop = toolLog.scrollHeight;
}
function updateSavedAgents() {
const container = document.getElementById('savedAgents');
if (agents.length === 0) {
container.innerHTML = `
<div class="bg-white rounded-lg shadow p-4 text-center text-gray-500">
<i data-feather="package" class="w-8 h-8 mx-auto mb-2"></i>
<p>No saved agents yet</p>
</div>
`;
} else {
container.innerHTML = agents.map(agent => `
<div class="bg-white rounded-lg shadow p-4 hover:shadow-lg transition cursor-pointer" onclick="loadAgent('${agent.id}')">
<div class="flex items-center justify-between mb-2">
<h3 class="font-semibold text-gray-800">${agent.name}</h3>
<span class="text-xs bg-indigo-100 text-indigo-700 px-2 py-1 rounded">${agent.model}</span>
</div>
<p class="text-sm text-gray-600 mb-2">${agent.tools.length} tools</p>
<div class="flex flex-wrap gap-1">
${agent.tools.slice(0, 3).map(tool =>
`<span class="text-xs bg-gray-100 text-gray-600 px-2 py-1 rounded">${tool}</span>`
).join('')}
${agent.tools.length > 3 ? `<span class="text-xs text-gray-500">+${agent.tools.length - 3} more</span>` : ''}
</div>
</div>
`).join('');
}
feather.replace();
}
function loadAgent(agentId) {
currentAgent = agents.find(a => a.id === agentId);
if (currentAgent) {
document.getElementById('agentName').value = currentAgent.name;
document.getElementById('agentModel').value = currentAgent.model;
document.getElementById('systemPrompt').value = currentAgent.systemPrompt;
document.getElementById('temperature').value = currentAgent.temperature;
document.getElementById('maxTokens').value = currentAgent.maxTokens;
// Update checkboxes
document.querySelectorAll('.tool-checkbox').forEach(cb => {
cb.checked = currentAgent.tools.includes(cb.value);
});
// Enable chat
document.getElementById('chatInput').disabled = false;
document.getElementById('sendMessage').disabled = false;
initializeChat();
addToolLog(`Loaded agent: ${currentAgent.name}`, 'success');
}
}
// Clear log
document.getElementById('clearLog').addEventListener('click', () => {
document.getElementById('toolLog').innerHTML = '<div class="text-gray-500">Log cleared...</div>';
});
feather.replace();
</script>
</body>
</html> |