diff --git a/vicuna-tools.d/template.d/chatbot.html b/vicuna-tools.d/template.d/chatbot.html index a76bee1..237a38c 100644 --- a/vicuna-tools.d/template.d/chatbot.html +++ b/vicuna-tools.d/template.d/chatbot.html @@ -9,19 +9,33 @@ } 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) + body = new URLSearchParams(new FormData(newPrompt)).toString() + http("POST", "/api/v0/chatbot", (body, status) => { + if (status != 200) { + log(body) + return + } + }, body) + } + + function pushStream(newMessage) { + body = new URLSearchParams(new FormData(newMessage)).toString() + newMessage.getElementsByTagName("button").disabled = true + newMessage.getElementsByTagName("input").disabled = true + http("PUT", "/api/v0/chatbot", (body, status) => { + newMessage.getElementsByTagName("button").disabled = false + newMessage.getElementsByTagName("input").disabled = false + if (status != 200) { + log(body) + return + } + log(body) + }, body) } function log() { - console.log(arguments) - document.getElementById("debug-log").innerHTML += "\n" + new String(arguments) + console.log(arguments) + document.getElementById("debug-log").innerHTML += "\n" + new String(arguments) } function http(method, remote, callback, body) { @@ -37,8 +51,6 @@ } xmlhttp.send(body); } - function callback(responseBody, responseStatus) { - } @@ -51,7 +63,7 @@
Use your session -
+