File size: 2,309 Bytes
c5303ee
16c5571
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e007a6b
d258d03
16c5571
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d258d03
 
 
 
 
 
 
 
 
 
 
 
16c5571
 
 
c5303ee
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AI ChatBot</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
        }
        #chat-container {
            width: 80%;
            margin: auto;
            margin-top: 50px;
            padding: 20px;
            border: 1px solid #ccc;
            background-color: #fff;
            position: relative;
            overflow: auto;
            height: 400px;
        }
        .user, .bot {
            padding: 10px;
            margin: 10px;
            border-radius: 5px;
        }
        .user {
            background-color: #e0e0e0;
            text-align: right;
        }
        .bot {
            background-color: #d1f5d3;
        }
        #input-container {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="chat-container"></div>
    <div id="input-container">
        <input type="text" id="user-input" style="width:80%">
        <button onclick="sendMessage()">Send</button>
    </div>
    <script>
     const endpoint = 'https://huggingface.co/spaces/dmar1313/uncensored/chat';

        function appendMessage(who, text) {
            const div = document.createElement('div');
            div.className = who;
            div.textContent = text;
            document.getElementById('chat-container').appendChild(div);
        }

        function sendMessage() {
            const input = document.getElementById('user-input');
            const text = input.value;
            input.value = '';

            // Append user message to chat
            appendMessage('user', text);

            // Make a request to your AI model to get a response
            fetch(endpoint, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({ prompt: text })
            })
            .then(response => response.json())
            .then(data => {
                // Append AI response to chat
                appendMessage('bot', data.response);
            })
            .catch(error => console.error('Error:', error));
        }
    </script>
</body>
</html>