Download index.html from MarcRyan/multi-agent-llm-system-template: direct link, hf CLI and curl.
- Browser
- Download file 37.1 kB
-
https://huggingface.co/spaces/MarcRyan/multi-agent-llm-system-template/resolve/main/index.html
- Command line
-
hf download hf://spaces/MarcRyan/multi-agent-llm-system-template/index.html
-
curl -L -o index.html https://huggingface.co/spaces/MarcRyan/multi-agent-llm-system-template/resolve/main/index.html
37.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Multi-Agent LLM System</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> | |
| .message-animation { | |
| animation: fadeIn 0.3s ease-in-out; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .agent-selected { | |
| box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5); | |
| } | |
| .task-pending { | |
| border-left: 4px solid #f59e0b; | |
| } | |
| .task-processing { | |
| border-left: 4px solid #3b82f6; | |
| } | |
| .task-completed { | |
| border-left: 4px solid #10b981; | |
| } | |
| .task-failed { | |
| border-left: 4px solid #ef4444; | |
| } | |
| .typing-indicator { | |
| display: inline-block; | |
| } | |
| .typing-indicator span { | |
| height: 8px; | |
| width: 8px; | |
| background: #6b7280; | |
| border-radius: 50%; | |
| display: inline-block; | |
| margin-right: 4px; | |
| animation: typing 1.5s infinite ease-in-out; | |
| } | |
| .typing-indicator span:nth-child(2) { | |
| animation-delay: 0.2s; | |
| } | |
| .typing-indicator span:nth-child(3) { | |
| animation-delay: 0.4s; | |
| } | |
| @keyframes typing { | |
| 0%, 100% { transform: translateY(0); } | |
| 50% { transform: translateY(-5px); } | |
| } | |
| .model-status-idle { | |
| background-color: #e5e7eb; | |
| } | |
| .model-status-loading { | |
| background-color: #93c5fd; | |
| animation: pulse 2s infinite; | |
| } | |
| .model-status-ready { | |
| background-color: #6ee7b7; | |
| } | |
| .model-status-error { | |
| background-color: #fca5a5; | |
| } | |
| @keyframes pulse { | |
| 0%, 100% { opacity: 1; } | |
| 50% { opacity: 0.5; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-100 font-sans"> | |
| <div class="container mx-auto px-4 py-8 max-w-7xl"> | |
| <header class="mb-8"> | |
| <h1 class="text-3xl font-bold text-gray-800">Multi-Agent LLM System</h1> | |
| <p class="text-gray-600 mt-2">Manage conversations with Gemma3, Nous-Hermes2, and Llama3 models</p> | |
| </header> | |
| <div class="grid grid-cols-1 lg:grid-cols-3 gap-6"> | |
| <!-- Model Status Panel --> | |
| <div class="bg-white rounded-lg shadow p-6"> | |
| <h2 class="text-xl font-semibold mb-4 text-gray-800">Model Status</h2> | |
| <div class="space-y-4"> | |
| <div class="p-4 rounded-lg model-status-idle" id="gemma-status"> | |
| <div class="flex items-center justify-between"> | |
| <div> | |
| <h3 class="font-medium">Gemma3:1b</h3> | |
| <p class="text-sm text-gray-600">Google's lightweight model</p> | |
| </div> | |
| <span class="px-3 py-1 rounded-full text-xs font-medium" id="gemma-status-text">Idle</span> | |
| </div> | |
| <div class="mt-3 flex space-x-2"> | |
| <button onclick="loadModel('gemma')" class="px-3 py-1 bg-blue-100 text-blue-800 rounded text-sm hover:bg-blue-200 transition">Load</button> | |
| <button onclick="unloadModel('gemma')" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition">Unload</button> | |
| </div> | |
| </div> | |
| <div class="p-4 rounded-lg model-status-idle" id="hermes-status"> | |
| <div class="flex items-center justify-between"> | |
| <div> | |
| <h3 class="font-medium">Nous-Hermes2</h3> | |
| <p class="text-sm text-gray-600">Fine-tuned for instruction following</p> | |
| </div> | |
| <span class="px-3 py-1 rounded-full text-xs font-medium" id="hermes-status-text">Idle</span> | |
| </div> | |
| <div class="mt-3 flex space-x-2"> | |
| <button onclick="loadModel('hermes')" class="px-3 py-1 bg-blue-100 text-blue-800 rounded text-sm hover:bg-blue-200 transition">Load</button> | |
| <button onclick="unloadModel('hermes')" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition">Unload</button> | |
| </div> | |
| </div> | |
| <div class="p-4 rounded-lg model-status-idle" id="llama-status"> | |
| <div class="flex items-center justify-between"> | |
| <div> | |
| <h3 class="font-medium">Llama3.2:1b</h3> | |
| <p class="text-sm text-gray-600">Meta's efficient language model</p> | |
| </div> | |
| <span class="px-3 py-1 rounded-full text-xs font-medium" id="llama-status-text">Idle</span> | |
| </div> | |
| <div class="mt-3 flex space-x-2"> | |
| <button onclick="loadModel('llama')" class="px-3 py-1 bg-blue-100 text-blue-800 rounded text-sm hover:bg-blue-200 transition">Load</button> | |
| <button onclick="unloadModel('llama')" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition">Unload</button> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mt-6 pt-4 border-t border-gray-200"> | |
| <h3 class="font-medium mb-2">System Resources</h3> | |
| <div class="space-y-2"> | |
| <div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>CPU Usage</span> | |
| <span id="cpu-usage">0%</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2"> | |
| <div id="cpu-bar" class="bg-blue-600 h-2 rounded-full" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| <div> | |
| <div class="flex justify-between text-sm mb-1"> | |
| <span>Memory Usage</span> | |
| <span id="memory-usage">0MB/0MB</span> | |
| </div> | |
| <div class="w-full bg-gray-200 rounded-full h-2"> | |
| <div id="memory-bar" class="bg-purple-600 h-2 rounded-full" style="width: 0%"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Conversation Panel --> | |
| <div class="bg-white rounded-lg shadow lg:col-span-2"> | |
| <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | |
| <h2 class="text-xl font-semibold text-gray-800">Conversation</h2> | |
| <div class="flex space-x-2"> | |
| <button onclick="newConversation()" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition flex items-center"> | |
| <i class="fas fa-plus mr-1"></i> New | |
| </button> | |
| <button onclick="exportConversation()" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition flex items-center"> | |
| <i class="fas fa-download mr-1"></i> Export | |
| </button> | |
| </div> | |
| </div> | |
| <div class="h-96 overflow-y-auto p-4" id="conversation-container"> | |
| <div class="text-center text-gray-500 py-10"> | |
| <i class="fas fa-comments text-4xl mb-3"></i> | |
| <p>Start a new conversation by selecting an agent and typing a message</p> | |
| </div> | |
| </div> | |
| <div class="p-4 border-t border-gray-200"> | |
| <div class="flex mb-3 space-x-2 overflow-x-auto pb-2"> | |
| <button onclick="selectAgent('gemma')" class="agent-btn px-3 py-1 bg-gray-100 text-gray-800 rounded-full text-sm hover:bg-gray-200 transition flex items-center"> | |
| <span class="w-2 h-2 rounded-full bg-gray-400 mr-2" id="gemma-indicator"></span> | |
| Gemma3 | |
| </button> | |
| <button onclick="selectAgent('hermes')" class="agent-btn px-3 py-1 bg-gray-100 text-gray-800 rounded-full text-sm hover:bg-gray-200 transition flex items-center"> | |
| <span class="w-2 h-2 rounded-full bg-gray-400 mr-2" id="hermes-indicator"></span> | |
| Hermes2 | |
| </button> | |
| <button onclick="selectAgent('llama')" class="agent-btn px-3 py-1 bg-gray-100 text-gray-800 rounded-full text-sm hover:bg-gray-200 transition flex items-center"> | |
| <span class="w-2 h-2 rounded-full bg-gray-400 mr-2" id="llama-indicator"></span> | |
| Llama3 | |
| </button> | |
| <button onclick="selectAgent('all')" class="agent-btn px-3 py-1 bg-gray-100 text-gray-800 rounded-full text-sm hover:bg-gray-200 transition flex items-center"> | |
| <i class="fas fa-users mr-1"></i> All Agents | |
| </button> | |
| </div> | |
| <div class="flex"> | |
| <input type="text" id="user-input" placeholder="Type your message..." class="flex-1 px-4 py-2 border border-gray-300 rounded-l-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"> | |
| <button onclick="sendMessage()" class="px-4 py-2 bg-blue-600 text-white rounded-r-lg hover:bg-blue-700 transition flex items-center"> | |
| <i class="fas fa-paper-plane mr-2"></i> Send | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Task Queue Panel --> | |
| <div class="mt-6 bg-white rounded-lg shadow"> | |
| <div class="p-4 border-b border-gray-200 flex justify-between items-center"> | |
| <h2 class="text-xl font-semibold text-gray-800">Task Queue</h2> | |
| <div class="flex space-x-2"> | |
| <button onclick="processQueue()" class="px-3 py-1 bg-blue-100 text-blue-800 rounded text-sm hover:bg-blue-200 transition flex items-center"> | |
| <i class="fas fa-play mr-1"></i> Process | |
| </button> | |
| <button onclick="clearQueue()" class="px-3 py-1 bg-gray-100 text-gray-800 rounded text-sm hover:bg-gray-200 transition flex items-center"> | |
| <i class="fas fa-trash mr-1"></i> Clear | |
| </button> | |
| </div> | |
| </div> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Task</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Model</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Created</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th> | |
| </tr> | |
| </thead> | |
| <tbody class="bg-white divide-y divide-gray-200" id="task-queue-body"> | |
| <!-- Tasks will be added here dynamically --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Global state | |
| const state = { | |
| conversations: [], | |
| currentConversation: null, | |
| selectedAgent: null, | |
| models: { | |
| gemma: { status: 'idle', loaded: false }, | |
| hermes: { status: 'idle', loaded: false }, | |
| llama: { status: 'idle', loaded: false } | |
| }, | |
| taskQueue: [], | |
| isProcessing: false | |
| }; | |
| // DOM elements | |
| const conversationContainer = document.getElementById('conversation-container'); | |
| const userInput = document.getElementById('user-input'); | |
| const taskQueueBody = document.getElementById('task-queue-body'); | |
| // Initialize | |
| document.addEventListener('DOMContentLoaded', () => { | |
| updateModelStatusDisplays(); | |
| simulateSystemResources(); | |
| newConversation(); | |
| }); | |
| // Model management | |
| function loadModel(model) { | |
| if (state.models[model].loaded) return; | |
| state.models[model].status = 'loading'; | |
| state.models[model].loaded = false; | |
| updateModelStatusDisplays(); | |
| // Simulate model loading | |
| setTimeout(() => { | |
| state.models[model].status = 'ready'; | |
| state.models[model].loaded = true; | |
| updateModelStatusDisplays(); | |
| // Add system message to current conversation | |
| if (state.currentConversation !== null) { | |
| const modelName = getModelDisplayName(model); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: `${modelName} model loaded and ready`, | |
| timestamp: new Date() | |
| }); | |
| } | |
| }, 2000); | |
| } | |
| function unloadModel(model) { | |
| if (!state.models[model].loaded) return; | |
| state.models[model].status = 'idle'; | |
| state.models[model].loaded = false; | |
| updateModelStatusDisplays(); | |
| // Add system message to current conversation | |
| if (state.currentConversation !== null) { | |
| const modelName = getModelDisplayName(model); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: `${modelName} model unloaded`, | |
| timestamp: new Date() | |
| }); | |
| } | |
| } | |
| function updateModelStatusDisplays() { | |
| // Update status panels | |
| for (const model in state.models) { | |
| const status = state.models[model].status; | |
| const statusElement = document.getElementById(`${model}-status`); | |
| const statusTextElement = document.getElementById(`${model}-status-text`); | |
| const indicatorElement = document.getElementById(`${model}-indicator`); | |
| // Remove all classes first | |
| statusElement.className = statusElement.className.replace(/model-status-\w+/g, ''); | |
| statusElement.classList.add(`model-status-${status}`); | |
| // Update text and indicator | |
| statusTextElement.textContent = status.charAt(0).toUpperCase() + status.slice(1); | |
| // Update indicator color | |
| if (indicatorElement) { | |
| indicatorElement.className = indicatorElement.className.replace(/bg-\w+/g, ''); | |
| if (status === 'ready') { | |
| indicatorElement.classList.add('bg-green-500'); | |
| } else if (status === 'loading') { | |
| indicatorElement.classList.add('bg-blue-500'); | |
| } else { | |
| indicatorElement.classList.add('bg-gray-400'); | |
| } | |
| } | |
| } | |
| } | |
| function getModelDisplayName(model) { | |
| const names = { | |
| gemma: 'Gemma3:1b', | |
| hermes: 'Nous-Hermes2', | |
| llama: 'Llama3.2:1b' | |
| }; | |
| return names[model] || model; | |
| } | |
| // Conversation management | |
| function newConversation() { | |
| const conversation = { | |
| id: Date.now(), | |
| title: 'New Conversation', | |
| messages: [], | |
| createdAt: new Date() | |
| }; | |
| state.conversations.push(conversation); | |
| state.currentConversation = conversation; | |
| // Add welcome message | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: 'Welcome to the multi-agent conversation system. Select an agent and start chatting!', | |
| timestamp: new Date() | |
| }); | |
| renderConversation(); | |
| } | |
| function addMessageToConversation(message) { | |
| if (state.currentConversation === null) return; | |
| state.currentConversation.messages.push(message); | |
| renderConversation(); | |
| // Auto-scroll to bottom | |
| conversationContainer.scrollTop = conversationContainer.scrollHeight; | |
| } | |
| function renderConversation() { | |
| if (state.currentConversation === null || state.currentConversation.messages.length === 0) { | |
| conversationContainer.innerHTML = ` | |
| <div class="text-center text-gray-500 py-10"> | |
| <i class="fas fa-comments text-4xl mb-3"></i> | |
| <p>Start a new conversation by selecting an agent and typing a message</p> | |
| </div> | |
| `; | |
| return; | |
| } | |
| let messagesHTML = ''; | |
| state.currentConversation.messages.forEach((msg, index) => { | |
| const isUser = msg.sender === 'user'; | |
| const isSystem = msg.sender === 'system'; | |
| const isAgent = !isUser && !isSystem; | |
| const time = msg.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| messagesHTML += ` | |
| <div class="message-animation mb-4 ${isUser ? 'text-right' : 'text-left'}"> | |
| <div class="inline-block max-w-xs md:max-w-md lg:max-w-lg xl:max-w-xl 2xl:max-w-2xl rounded-lg px-4 py-2 ${isUser ? 'bg-blue-100 text-blue-900' : isSystem ? 'bg-gray-200 text-gray-800' : 'bg-purple-100 text-purple-900'}"> | |
| <div class="flex items-center ${isUser ? 'justify-end' : 'justify-start'} mb-1"> | |
| ${isAgent ? `<span class="font-medium mr-2">${msg.sender}</span>` : ''} | |
| ${isSystem ? `<span class="font-medium mr-2"><i class="fas fa-cog"></i> System</span>` : ''} | |
| <span class="text-xs text-gray-500">${time}</span> | |
| </div> | |
| <div class="whitespace-pre-wrap">${msg.content}</div> | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| conversationContainer.innerHTML = messagesHTML; | |
| } | |
| function exportConversation() { | |
| if (state.currentConversation === null || state.currentConversation.messages.length === 0) return; | |
| let exportText = `Conversation #${state.currentConversation.id}\n\n`; | |
| state.currentConversation.messages.forEach(msg => { | |
| const time = msg.timestamp.toLocaleTimeString(); | |
| exportText += `[${time}] ${msg.sender}: ${msg.content}\n\n`; | |
| }); | |
| const blob = new Blob([exportText], { type: 'text/plain' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `conversation-${state.currentConversation.id}.txt`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| // Agent selection | |
| function selectAgent(agent) { | |
| state.selectedAgent = agent; | |
| // Update UI | |
| document.querySelectorAll('.agent-btn').forEach(btn => { | |
| btn.classList.remove('agent-selected', 'bg-blue-100', 'text-blue-800'); | |
| }); | |
| if (agent === 'all') { | |
| document.querySelector(`.agent-btn:nth-last-child(1)`).classList.add('agent-selected', 'bg-blue-100', 'text-blue-800'); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: 'All agents selected. Your message will be sent to all available models.', | |
| timestamp: new Date() | |
| }); | |
| } else { | |
| const btn = document.querySelector(`.agent-btn:nth-child(${['gemma', 'hermes', 'llama'].indexOf(agent) + 1})`); | |
| if (btn) { | |
| btn.classList.add('agent-selected', 'bg-blue-100', 'text-blue-800'); | |
| const modelName = getModelDisplayName(agent); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: `${modelName} selected as the active agent`, | |
| timestamp: new Date() | |
| }); | |
| } | |
| } | |
| } | |
| // Message sending | |
| function sendMessage() { | |
| const message = userInput.value.trim(); | |
| if (!message) return; | |
| if (state.selectedAgent === null) { | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: 'Please select an agent before sending a message', | |
| timestamp: new Date() | |
| }); | |
| return; | |
| } | |
| // Add user message to conversation | |
| addMessageToConversation({ | |
| sender: 'user', | |
| content: message, | |
| timestamp: new Date() | |
| }); | |
| // Clear input | |
| userInput.value = ''; | |
| // Add typing indicator | |
| const typingId = 'typing-' + Date.now(); | |
| conversationContainer.innerHTML += ` | |
| <div id="${typingId}" class="mb-4 text-left"> | |
| <div class="inline-block max-w-xs md:max-w-md lg:max-w-lg rounded-lg px-4 py-2 bg-gray-200 text-gray-800"> | |
| <div class="flex items-center mb-1"> | |
| <span class="font-medium mr-2">${state.selectedAgent === 'all' ? 'Agents' : getModelDisplayName(state.selectedAgent)}</span> | |
| <span class="text-xs text-gray-500">typing</span> | |
| </div> | |
| <div class="typing-indicator"> | |
| <span></span> | |
| <span></span> | |
| <span></span> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| // Scroll to bottom | |
| conversationContainer.scrollTop = conversationContainer.scrollHeight; | |
| // Create task(s) | |
| if (state.selectedAgent === 'all') { | |
| // Send to all loaded models | |
| const loadedModels = Object.keys(state.models).filter(model => state.models[model].loaded); | |
| if (loadedModels.length === 0) { | |
| removeTypingIndicator(typingId); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: 'No models are loaded. Please load at least one model before sending messages.', | |
| timestamp: new Date() | |
| }); | |
| return; | |
| } | |
| loadedModels.forEach(model => { | |
| addToTaskQueue({ | |
| type: 'generate', | |
| model: model, | |
| prompt: message, | |
| conversationId: state.currentConversation.id, | |
| typingId: typingId | |
| }); | |
| }); | |
| } else { | |
| // Send to selected model | |
| if (!state.models[state.selectedAgent].loaded) { | |
| removeTypingIndicator(typingId); | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: `${getModelDisplayName(state.selectedAgent)} is not loaded. Please load the model first.`, | |
| timestamp: new Date() | |
| }); | |
| return; | |
| } | |
| addToTaskQueue({ | |
| type: 'generate', | |
| model: state.selectedAgent, | |
| prompt: message, | |
| conversationId: state.currentConversation.id, | |
| typingId: typingId | |
| }); | |
| } | |
| // Process queue if not already processing | |
| if (!state.isProcessing) { | |
| processQueue(); | |
| } | |
| } | |
| function removeTypingIndicator(id) { | |
| const element = document.getElementById(id); | |
| if (element) { | |
| element.remove(); | |
| } | |
| } | |
| // Task queue management | |
| function addToTaskQueue(task) { | |
| const taskId = Date.now(); | |
| const fullTask = { | |
| id: taskId, | |
| ...task, | |
| status: 'pending', | |
| createdAt: new Date(), | |
| startedAt: null, | |
| completedAt: null | |
| }; | |
| state.taskQueue.push(fullTask); | |
| renderTaskQueue(); | |
| return taskId; | |
| } | |
| function renderTaskQueue() { | |
| if (state.taskQueue.length === 0) { | |
| taskQueueBody.innerHTML = ` | |
| <tr> | |
| <td colspan="6" class="px-6 py-4 text-center text-gray-500">No tasks in queue</td> | |
| </tr> | |
| `; | |
| return; | |
| } | |
| let tasksHTML = ''; | |
| state.taskQueue.forEach(task => { | |
| const createdTime = task.createdAt.toLocaleTimeString(); | |
| const startedTime = task.startedAt ? task.startedAt.toLocaleTimeString() : '-'; | |
| const completedTime = task.completedAt ? task.completedAt.toLocaleTimeString() : '-'; | |
| const statusClass = { | |
| pending: 'text-yellow-600', | |
| processing: 'text-blue-600', | |
| completed: 'text-green-600', | |
| failed: 'text-red-600' | |
| }[task.status]; | |
| tasksHTML += ` | |
| <tr class="task-${task.status} hover:bg-gray-50"> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${task.id}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${task.type === 'generate' ? 'Generate Response' : 'Unknown Task'}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${getModelDisplayName(task.model)}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm ${statusClass}"> | |
| <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-${task.status === 'pending' ? 'yellow' : task.status === 'processing' ? 'blue' : task.status === 'completed' ? 'green' : 'red'}-100 text-${task.status === 'pending' ? 'yellow' : task.status === 'processing' ? 'blue' : task.status === 'completed' ? 'green' : 'red'}-800"> | |
| ${task.status} | |
| </span> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${createdTime}</td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> | |
| ${task.status === 'pending' ? ` | |
| <button onclick="cancelTask(${task.id})" class="text-red-600 hover:text-red-900 mr-2"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| ` : ''} | |
| </td> | |
| </tr> | |
| `; | |
| }); | |
| taskQueueBody.innerHTML = tasksHTML; | |
| } | |
| function cancelTask(taskId) { | |
| state.taskQueue = state.taskQueue.filter(task => { | |
| if (task.id === taskId && task.status === 'pending') { | |
| return false; | |
| } | |
| return true; | |
| }); | |
| renderTaskQueue(); | |
| } | |
| function clearQueue() { | |
| // Only clear completed/failed tasks | |
| state.taskQueue = state.taskQueue.filter(task => | |
| task.status === 'pending' || task.status === 'processing' | |
| ); | |
| renderTaskQueue(); | |
| } | |
| async function processQueue() { | |
| if (state.isProcessing || state.taskQueue.length === 0) return; | |
| state.isProcessing = true; | |
| // Find the next pending task | |
| const nextTask = state.taskQueue.find(task => task.status === 'pending'); | |
| if (!nextTask) { | |
| state.isProcessing = false; | |
| return; | |
| } | |
| // Update task status | |
| nextTask.status = 'processing'; | |
| nextTask.startedAt = new Date(); | |
| renderTaskQueue(); | |
| // Simulate processing (in a real app, this would call your Ollama API) | |
| try { | |
| const response = await simulateLLMResponse(nextTask.prompt, nextTask.model); | |
| // Update task status | |
| nextTask.status = 'completed'; | |
| nextTask.completedAt = new Date(); | |
| nextTask.result = response; | |
| // Remove typing indicator | |
| if (nextTask.typingId) { | |
| removeTypingIndicator(nextTask.typingId); | |
| } | |
| // Add response to conversation | |
| if (state.currentConversation && state.currentConversation.id === nextTask.conversationId) { | |
| addMessageToConversation({ | |
| sender: getModelDisplayName(nextTask.model), | |
| content: response, | |
| timestamp: new Date() | |
| }); | |
| } | |
| // Continue processing next task | |
| renderTaskQueue(); | |
| state.isProcessing = false; | |
| processQueue(); | |
| } catch (error) { | |
| console.error('Task failed:', error); | |
| nextTask.status = 'failed'; | |
| nextTask.completedAt = new Date(); | |
| nextTask.error = error.message; | |
| if (nextTask.typingId) { | |
| removeTypingIndicator(nextTask.typingId); | |
| } | |
| if (state.currentConversation && state.currentConversation.id === nextTask.conversationId) { | |
| addMessageToConversation({ | |
| sender: 'system', | |
| content: `${getModelDisplayName(nextTask.model)} failed to generate response: ${error.message}`, | |
| timestamp: new Date() | |
| }); | |
| } | |
| renderTaskQueue(); | |
| state.isProcessing = false; | |
| processQueue(); | |
| } | |
| } | |
| // Simulation functions | |
| function simulateLLMResponse(prompt, model) { | |
| return new Promise((resolve, reject) => { | |
| // Random delay between 1-4 seconds | |
| const delay = 1000 + Math.random() * 3000; | |
| setTimeout(() => { | |
| // Small chance of failure | |
| if (Math.random() < 0.05) { | |
| reject(new Error('Model encountered an error during generation')); | |
| return; | |
| } | |
| // Generate different responses based on model | |
| let response; | |
| if (model === 'gemma') { | |
| response = `Gemma3:1b response to "${prompt}"\n\nAs a lightweight model, I can provide concise information. ${prompt} is an interesting topic that involves several considerations. The key points are...`; | |
| } else if (model === 'hermes') { | |
| response = `Nous-Hermes2 analysis of "${prompt}"\n\nThank you for your question. I'll provide a detailed response:\n\n1. First aspect: ...\n2. Second consideration: ...\n3. Additional factors: ...\n\nIn conclusion, ${prompt.toLowerCase()} involves multiple dimensions that should be carefully evaluated.`; | |
| } else if (model === 'llama') { | |
| response = `Llama3.2:1b on "${prompt}"\n\nI've analyzed your query about "${prompt}". Here's my perspective:\n\n- Point A: ...\n- Point B: ...\n- Point C: ...\n\nThis overview should help understand the core concepts. Would you like me to elaborate on any specific aspect?`; | |
| } else { | |
| response = `Response to: ${prompt}\n\nThis is a simulated response from the language model. In a real implementation, this would be the actual output from the ${getModelDisplayName(model)} model.`; | |
| } | |
| resolve(response); | |
| }, delay); | |
| }); | |
| } | |
| function simulateSystemResources() { | |
| // Simulate changing system resources | |
| setInterval(() => { | |
| const totalMemory = 8192; // 8GB | |
| const memoryUsed = Math.floor(1000 + Math.random() * 6000); | |
| const memoryPercent = Math.floor((memoryUsed / totalMemory) * 100); | |
| const cpuPercent = Math.floor(10 + Math.random() * 60); | |
| document.getElementById('cpu-usage').textContent = `${cpuPercent}%`; | |
| document.getElementById('cpu-bar').style.width = `${cpuPercent}%`; | |
| document.getElementById('memory-usage').textContent = `${memoryUsed}MB/${totalMemory}MB`; | |
| document.getElementById('memory-bar').style.width = `${memoryPercent}%`; | |
| }, 2000); | |
| } | |
| // Keyboard shortcut for sending message | |
| userInput.addEventListener('keypress', (e) => { | |
| if (e.key === 'Enter') { | |
| sendMessage(); | |
| } | |
| }); | |
| </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=MarcRyan/multi-agent-llm-system-template" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |