Update templates/index.html
Browse files3 unmodified lines456789101112131478910111213141518192021222316171819202122272324252627322829303536373831323334353637386 unmodified lines45464752535448495051523 unmodified lines <meta charset="UTF-8"> <title>ReAct Agent Console</title> <style> body { font-family: 'Courier New', Courier, monospace; background: #1e1e1e; color: #d4d4d4; padding: 20px; } #chatbox { border: 1px solid #444; height: 500px; overflow-y: auto; padding: 15px; background: #252526; } .message { margin-bottom: 15px; border-left: 3px solid #007acc; padding-left: 10px; white-space: pre-wrap; } .user-label { color: #569cd6; font-weight: bold; } .agent-label { color: #4ec9b0; font-weight: bold; } #input-area { display: flex; margin-top: 20px; } input { flex-grow: 1; background: #333; color: white; border: 1px solid #555; padding: 10px; } button { background: #007acc; color: white; border: none; padding: 10px 20px; cursor: pointer; } body { font-family: monospace; background: #121212; color: #e0e0e0; padding: 20px; } #console { border: 1px solid #333; height: 500px; overflow-y: auto; padding: 15px; margin-bottom: 20px; background: #000; } .trace { border-left: 2px solid #007acc; padding-left: 10px; margin: 10px 0; white-space: pre-wrap; } .user { color: #569cd6; font-weight: bold; } input { width: 80%; padding: 10px; background: #222; color: #fff; border: 1px solid #444; } button { padding: 10px 20px; background: #007acc; border: none; color: white; cursor: pointer; } </style></head><body> <h2>ReAct Agent Trace</h2> <div id="chatbox"></div> <div id="input-area"> <input type="text" id="user-input" placeholder="Ask for the time or a math problem (e.g., 25 * 4)..."> <button onclick="send()">Send</button> </div> <h2>ReAct Reasoning Trace</h2> <div id="console"></div> <input type="text" id="user-input" placeholder="Ask 'whats the time now'..."> <button onclick="send()">Execute</button>
<script> async function send() { const box = document.getElementById('chatbox'); const input = document.getElementById('user-input'); const consoleBox = document.getElementById('console'); const text = input.value; if (!text) return;
box.innerHTML += `<div><span class="user-label">User:</span> ${text}</div>`; consoleBox.innerHTML += `<div><span class="user">User:</span> ${text}</div>`; input.value = '';
const responseDiv = document.createElement('div'); responseDiv.className = 'message'; responseDiv.innerHTML = '<span class="agent-label">Agent Traces:</span><br>'; box.appendChild(responseDiv); const traceDiv = document.createElement('div'); traceDiv.className = 'trace'; consoleBox.appendChild(traceDiv);
// Fetching a streaming response [23, 24] const response = await fetch('/chat', { method: 'POST', headers: {'Content-Type': 'application/json'},6 unmodified lines while (true) { const { done, value } = await reader.read(); if (done) break; const chunk = decoder.decode(value, { stream: true }); responseDiv.innerHTML += chunk; box.scrollTop = box.scrollHeight; traceDiv.innerText += decoder.decode(value); consoleBox.scrollTop = consoleBox.scrollHeight; } } </script>templates/index.html+18-23