Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +8 -8
templates/index.html
CHANGED
@@ -129,9 +129,9 @@
|
|
129 |
<header>
|
130 |
<h1>Agent Chat</h1>
|
131 |
<div>
|
132 |
-
<!-- Link to
|
133 |
<a href="/upload" class="btn">Upload DB</a>
|
134 |
-
<!-- Link to view uploaded
|
135 |
<a href="/files/uploaded.db" class="btn">View Uploaded DB</a>
|
136 |
</div>
|
137 |
</header>
|
@@ -143,7 +143,7 @@
|
|
143 |
<div class="logs-container" id="logs">
|
144 |
<!-- Log messages will appear here -->
|
145 |
</div>
|
146 |
-
<!-- Input area -->
|
147 |
<div class="input-area">
|
148 |
<textarea id="prompt" rows="2" placeholder="Type your message here..."></textarea>
|
149 |
<button id="send">Send</button>
|
@@ -184,7 +184,7 @@
|
|
184 |
if (!prompt) return;
|
185 |
addMessage("user", prompt);
|
186 |
promptTextarea.value = "";
|
187 |
-
// Send prompt to the server
|
188 |
fetch("/generate", {
|
189 |
method: "POST",
|
190 |
headers: { "Content-Type": "application/json" },
|
@@ -196,7 +196,7 @@
|
|
196 |
let agentMessageBubble = null;
|
197 |
socket.on("final_stream", (data) => {
|
198 |
if (!agentMessageBubble) {
|
199 |
-
// Create agent message bubble if
|
200 |
const messageDiv = document.createElement("div");
|
201 |
messageDiv.classList.add("message", "agent");
|
202 |
agentMessageBubble = document.createElement("div");
|
@@ -204,12 +204,12 @@
|
|
204 |
messageDiv.appendChild(agentMessageBubble);
|
205 |
chatContainer.appendChild(messageDiv);
|
206 |
}
|
207 |
-
// Append
|
208 |
agentMessageBubble.textContent += data.message;
|
209 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
210 |
});
|
211 |
|
212 |
-
// When final answer is
|
213 |
socket.on("final", (data) => {
|
214 |
if (!agentMessageBubble) {
|
215 |
addMessage("agent", data.message);
|
@@ -219,7 +219,7 @@
|
|
219 |
}
|
220 |
});
|
221 |
|
222 |
-
// Append log messages
|
223 |
socket.on("log", (data) => {
|
224 |
addLogMessage(data.message);
|
225 |
});
|
|
|
129 |
<header>
|
130 |
<h1>Agent Chat</h1>
|
131 |
<div>
|
132 |
+
<!-- Link to upload page -->
|
133 |
<a href="/upload" class="btn">Upload DB</a>
|
134 |
+
<!-- Link to view the uploaded DB file using the static route -->
|
135 |
<a href="/files/uploaded.db" class="btn">View Uploaded DB</a>
|
136 |
</div>
|
137 |
</header>
|
|
|
143 |
<div class="logs-container" id="logs">
|
144 |
<!-- Log messages will appear here -->
|
145 |
</div>
|
146 |
+
<!-- Input area for sending prompts -->
|
147 |
<div class="input-area">
|
148 |
<textarea id="prompt" rows="2" placeholder="Type your message here..."></textarea>
|
149 |
<button id="send">Send</button>
|
|
|
184 |
if (!prompt) return;
|
185 |
addMessage("user", prompt);
|
186 |
promptTextarea.value = "";
|
187 |
+
// Send prompt to the server via a POST request
|
188 |
fetch("/generate", {
|
189 |
method: "POST",
|
190 |
headers: { "Content-Type": "application/json" },
|
|
|
196 |
let agentMessageBubble = null;
|
197 |
socket.on("final_stream", (data) => {
|
198 |
if (!agentMessageBubble) {
|
199 |
+
// Create an agent message bubble if one does not exist.
|
200 |
const messageDiv = document.createElement("div");
|
201 |
messageDiv.classList.add("message", "agent");
|
202 |
agentMessageBubble = document.createElement("div");
|
|
|
204 |
messageDiv.appendChild(agentMessageBubble);
|
205 |
chatContainer.appendChild(messageDiv);
|
206 |
}
|
207 |
+
// Append incoming data to the agent's bubble.
|
208 |
agentMessageBubble.textContent += data.message;
|
209 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
210 |
});
|
211 |
|
212 |
+
// When the final answer is sent, finish the bubble.
|
213 |
socket.on("final", (data) => {
|
214 |
if (!agentMessageBubble) {
|
215 |
addMessage("agent", data.message);
|
|
|
219 |
}
|
220 |
});
|
221 |
|
222 |
+
// Append incoming log messages to the logs container.
|
223 |
socket.on("log", (data) => {
|
224 |
addLogMessage(data.message);
|
225 |
});
|