Sergidev commited on
Commit
9869e3d
1 Parent(s): 1c9ca94

Delete index.js

Browse files
Files changed (1) hide show
  1. index.js +0 -48
index.js DELETED
@@ -1,48 +0,0 @@
1
- $(document).ready(function() {
2
- var memoryMode = 'full';
3
-
4
- $('#memory-toggle').change(function() {
5
- memoryMode = $(this).is(':checked') ? 'smart' : 'full';
6
- });
7
-
8
- $('#chat-form').submit(function(event) {
9
- event.preventDefault();
10
- var userInput = $('#user-input').val();
11
- $('#chat-container').append('<div class="message user-message"><i class="fas fa-user icon"></i>' + userInput + '</div>');
12
- $('#user-input').val('');
13
- $('#send-button').prop('disabled', true);
14
- $('#loading-message').show();
15
- var $botMessage = $('<div class="message bot-message"><i class="fas fa-robot icon"></i></div>');
16
- $('#chat-container').append($botMessage);
17
- var botResponse = '';
18
- $.ajax({
19
- url: '/chat',
20
- method: 'POST',
21
- data: JSON.stringify({ user_input: userInput, mode: memoryMode }),
22
- contentType: 'application/json',
23
- dataType: 'text', // Add this line to handle the response as text
24
- xhrFields: {
25
- onprogress: function(e) {
26
- var chunk = e.currentTarget.response.slice(botResponse.length);
27
- botResponse += chunk;
28
- $botMessage.html('<i class="fas fa-robot icon"></i>' + botResponse.replace(/\n/g, '<br>'));
29
- $('#chat-container').scrollTop($('#chat-container')[0].scrollHeight);
30
- }
31
- },
32
- success: function() {
33
- $('#send-button').prop('disabled', false);
34
- $('#loading-message').hide();
35
- },
36
- error: function(xhr, status, error) {
37
- $('#send-button').prop('disabled', false);
38
- $('#loading-message').hide();
39
- var errorMessage = '<div class="message error-message"><i class="fas fa-exclamation-triangle icon"></i>Error: ' + error + '</div>';
40
- $('#chat-container').append(errorMessage);
41
- }
42
- });
43
- });
44
-
45
- setInterval(function() {
46
- $.post('/sleep');
47
- }, 20000); // set to 50 seconds, usually 2 minutes in milliseconds
48
- });