File size: 909 Bytes
1224729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
document.getElementById('send-button').addEventListener('click', function() {
    let userInput = document.getElementById('user-input').value;
    sendMessage(userInput);
});

function sendMessage(message) {
    fetch('https://huggingface.co/spaces/MosbergControl/CodeNinja-1.0-OpenChat-7B/your-endpoint', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ message: message })
    })
    .then(response => response.json())
    .then(data => {
        displayMessage(data);
    })
    .catch((error) => {
        console.error('Error:', error);
    });
}

function displayMessage(data) {
    let chatBox = document.getElementById('chat-box');
    let newMessage = document.createElement('div');
    newMessage.textContent = data.response; // Assuming the response has a 'response' field
    chatBox.appendChild(newMessage);
}