manus4 / templates /chat.html
Ken Sang Tang
Update templates/chat.html
70e870a verified
<!DOCTYPE html>
<html>
<head>
<title>Manus4 Chat</title>
</head>
<body>
<h2>Chat with Manus4</h2>
<form id="prompt-form">
<textarea id="prompt" rows="4" cols="50" placeholder="Type your prompt..."></textarea>
<br>
<button type="submit">Submit</button>
</form>
<div id="output"></div>
<script>
document.getElementById("prompt-form").addEventListener("submit", async function(e) {
e.preventDefault();
const prompt = document.getElementById("prompt").value;
const res = await fetch("/tasks", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ prompt })
});
const { task_id } = await res.json();
const events = new EventSource(`/tasks/${task_id}/events`);
events.onmessage = function(event) {
const data = JSON.parse(event.data);
document.getElementById("output").innerText += `\n${data.result || data.message || JSON.stringify(data)}`;
};
});
</script>
</body>
</html>