wip
This commit is contained in:
@@ -4,10 +4,17 @@
|
||||
<script>
|
||||
function loadStream() {
|
||||
http("GET", "/api/v0/chatbot", (body, status) => {
|
||||
document.getElementById("stream-log").content = body
|
||||
var data = JSON.parse(body)
|
||||
document.getElementById("stream-log").innerHTML = data["Messages"]
|
||||
document.getElementById("stream-prompt").innerHTML = data["Prompt"]
|
||||
}, null)
|
||||
}
|
||||
|
||||
function appendStreamLog(message) {
|
||||
if (message)
|
||||
document.getElementById("stream-log").innerHTML += "\n" + message
|
||||
}
|
||||
|
||||
function startStream(newPrompt) {
|
||||
body = new URLSearchParams(new FormData(newPrompt)).toString()
|
||||
http("POST", "/api/v0/chatbot", (body, status) => {
|
||||
@@ -23,6 +30,7 @@
|
||||
for(var e of newMessage.elements)
|
||||
if(!e.attributes.readonly)
|
||||
e.disabled = true
|
||||
appendStreamLog(document.getElementsByName("Message")[0].value)
|
||||
http("PUT", "/api/v0/chatbot", (body, status) => {
|
||||
for(var e of newMessage.elements)
|
||||
e.disabled = false
|
||||
@@ -30,7 +38,8 @@
|
||||
log(body)
|
||||
return
|
||||
}
|
||||
log(body)
|
||||
appendStreamLog(body)
|
||||
document.getElementsByName("Message")[0].value = ""
|
||||
}, body)
|
||||
}
|
||||
|
||||
@@ -58,7 +67,7 @@
|
||||
<details>
|
||||
<summary>Set up a new session</summary>
|
||||
<form id="prompt" onsubmit="startStream(this); return false;">
|
||||
<textarea name="Prompt"></textarea>
|
||||
<textarea id="stream-prompt" name="Prompt"></textarea>
|
||||
<button type="submit">Start with prompt</button>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
Reference in New Issue
Block a user