msl 1 year ago
parent 332627eddd
commit bd2b81d8f9

@ -41,18 +41,17 @@
if (message) {
$$("#messageInput").val('');
$$("#hidep").append("{'role': 'user', 'content':'"+message+"'},")
$$("#hidep").append("{'role': 'user', 'content':'''"+message+"'''},")
allMessages=$$("#hidep").text()
$$(".chat-content").append(`<div class="text-right mb-2"><span class="badge badge-primary" ><p style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${message}<p></span></div>`);
$$(".chat-content").append(`<div class="text-right mb-2"><span class="badge badge-primary" ><p align="left" style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${message}<p></span></div>`);
$$("#sendButton").prop("disabled", true);
// Show loading spinner
$$(".chat-content").append('<div id="loadingSpinner" class="text-left mb-2"><span class="spinner-border spinner-border-sm"></span> Loading...</div>');
$$.post("/chat", { messages: allMessages }, function(response){
if(response) {
$$("#hidep").append("{'role': 'assistant', 'content':'"+response+"'},");
response=response.replace("\n","<br>")
$$(".chat-content").append(`<div class="text-left mb-2"><span class="badge badge-secondary"><p style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${response}</p></span></div>`);
$$("#hidep").append("{'role': 'assistant', 'content':'''"+response+"'''},");
$$(".chat-content").append(`<div class="text-left mb-2"><span class="badge badge-secondary"><p align="left" style="white-space: pre-wrap; width:220px; word-wrap: break-word; word-break:break-all;">$${response}</p></span></div>`);
$$("#sendButton").prop("disabled", false);
$$('#loadingSpinner').remove();

@ -39,7 +39,7 @@ class chat:
def POST(self):
i=web.input().messages
i=list(eval(i))
print(i)
x=chatgpt(i)
print(x)
return x

Loading…
Cancel
Save