Ken Sang Tang commited on
Commit
9ff65e3
·
verified ·
1 Parent(s): 391511e

Create templates/chat.html

Browse files
Files changed (1) hide show
  1. templates/chat.html +33 -0
templates/chat.html ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>OpenManus Chat</title>
5
+ </head>
6
+ <body>
7
+ <h2>Chat with OpenManus</h2>
8
+ <form id="prompt-form">
9
+ <textarea id="prompt" rows="4" cols="50" placeholder="Type your prompt..."></textarea>
10
+ <br>
11
+ <button type="submit">Submit</button>
12
+ </form>
13
+ <div id="output"></div>
14
+
15
+ <script>
16
+ document.getElementById("prompt-form").addEventListener("submit", async function(e) {
17
+ e.preventDefault();
18
+ const prompt = document.getElementById("prompt").value;
19
+ const res = await fetch("/tasks", {
20
+ method: "POST",
21
+ headers: { "Content-Type": "application/json" },
22
+ body: JSON.stringify({ prompt })
23
+ });
24
+ const { task_id } = await res.json();
25
+ const events = new EventSource(`/tasks/${task_id}/events`);
26
+ events.onmessage = function(event) {
27
+ const data = JSON.parse(event.data);
28
+ document.getElementById("output").innerText += `\n${data.result || data.message || JSON.stringify(data)}`;
29
+ };
30
+ });
31
+ </script>
32
+ </body>
33
+ </html>