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