File size: 1,116 Bytes
176bc9a
 
 
 
 
b5553ae
176bc9a
 
b5553ae
176bc9a
 
b5553ae
176bc9a
 
 
b5553ae
 
 
176bc9a
b5553ae
 
 
 
 
 
 
176bc9a
b5553ae
 
 
 
176bc9a
 
661c05a
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RAG Chatbot</title>
</head>
<body>
    <h1>RAG Chatbot</h1>
    <div id="chat-container"></div>
    <input type="text" id="user-input" placeholder="Ask a question...">
    <button onclick="sendMessage()">Send</button>

    <script>
        async function sendMessage() {
            const input = document.getElementById('user-input');
            const message = input.value;
            input.value = '';

            const response = await fetch('/ask', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({ question: message }),
            });

            const data = await response.json();
            const chatContainer = document.getElementById('chat-container');
            chatContainer.innerHTML += `<p><strong>You:</strong> ${message}</p><p><strong>Bot:</strong> ${data.response}</p>`;
        }
    </script>
</body>
</html>