ok submitting a prompt
This commit is contained in:
@@ -1,8 +1,66 @@
|
||||
<html>
|
||||
<header>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/dark.css">
|
||||
<script>
|
||||
function loadStream() {
|
||||
http("GET", "/api/v0/chatbot", (body, status) => {
|
||||
document.getElementById("stream-log").content = body
|
||||
}, null)
|
||||
}
|
||||
|
||||
function startStream(newPrompt) {
|
||||
body = new URLSearchParams(new FormData(newPrompt)).toString()
|
||||
console.log(body)
|
||||
http("POST", "/api/v0/chatbot", (body, status) => {
|
||||
if (status != 200) {
|
||||
log(body)
|
||||
return
|
||||
}
|
||||
}, body)
|
||||
}
|
||||
|
||||
function log() {
|
||||
console.log(arguments)
|
||||
document.getElementById("debug-log").innerHTML += "\n" + new String(arguments)
|
||||
}
|
||||
|
||||
function http(method, remote, callback, body) {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) {
|
||||
callback(xmlhttp.responseText, xmlhttp.status)
|
||||
}
|
||||
};
|
||||
xmlhttp.open(method, remote, true);
|
||||
if (typeof body == "undefined") {
|
||||
body = null
|
||||
}
|
||||
xmlhttp.send(body);
|
||||
}
|
||||
function callback(responseBody, responseStatus) {
|
||||
}
|
||||
</script>
|
||||
</header>
|
||||
<body>
|
||||
<body onload="loadStream()">
|
||||
<details>
|
||||
<summary>Set up a new session</summary>
|
||||
<form id="prompt" onsubmit="startStream(this); return false;">
|
||||
<textarea name="Prompt"></textarea>
|
||||
<button type="submit">Start with prompt</button>
|
||||
</form>
|
||||
</details>
|
||||
<details open=true>
|
||||
<summary>Use your session</summary>
|
||||
<form id="stream" onsubmit="return false;">
|
||||
<textarea id="stream-log" readonly=true></textarea>
|
||||
<div style="display: flex; flex-direction: row;">
|
||||
<input style="flex-grow: 1;" type="text" name="Message"/>
|
||||
<button type="submit">Send</button>
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
<pre id="debug-log">
|
||||
</pre>
|
||||
</body>
|
||||
<footer>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user