Spaces:
Runtime error
Runtime error
Update templates/index.html
Browse files- templates/index.html +9 -48
templates/index.html
CHANGED
@@ -1,56 +1,17 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
-
<html
|
3 |
<head>
|
4 |
-
<
|
5 |
-
<
|
6 |
-
<title>Hotel Booking AI</title>
|
7 |
-
<link rel="stylesheet" href="/static/style.css">
|
8 |
</head>
|
9 |
<body>
|
10 |
-
|
11 |
-
<
|
12 |
-
|
13 |
-
<div id="chatbot-container">
|
14 |
-
<h2>Chat with our AI</h2>
|
15 |
-
<div id="chat-history"></div>
|
16 |
-
<input type="text" id="user-input" placeholder="Type your message...">
|
17 |
-
<button onclick="sendMessage()">Send</button>
|
18 |
-
</div>
|
19 |
-
|
20 |
-
<div id="voice-container">
|
21 |
-
<h2>Voice Interaction</h2>
|
22 |
-
<div id="voice-response"></div>
|
23 |
-
<input type="file" accept="audio/*" id="voice-input" onchange="sendVoice()">
|
24 |
-
<button onclick="sendVoice()">Send Voice</button>
|
25 |
-
</div>
|
26 |
-
|
27 |
<script>
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
fetch('/chatbot', {
|
32 |
-
method: 'POST',
|
33 |
-
headers: { 'Content-Type': 'application/json' },
|
34 |
-
body: JSON.stringify({ message: input })
|
35 |
-
})
|
36 |
-
.then(response => response.text())
|
37 |
-
.then(data => document.getElementById('chat-history').innerHTML += `<p>User: ${input}</p><p>AI: ${data}</p>`);
|
38 |
-
}
|
39 |
-
|
40 |
-
// JavaScript for voice functionality
|
41 |
-
function sendVoice() {
|
42 |
-
var audioInput = document.getElementById('voice-input').files[0];
|
43 |
-
var formData = new FormData();
|
44 |
-
formData.append('audio', audioInput);
|
45 |
-
|
46 |
-
fetch('/voice', {
|
47 |
-
method: 'POST',
|
48 |
-
body: formData
|
49 |
-
})
|
50 |
-
.then(response => response.text())
|
51 |
-
.then(data => document.getElementById('voice-response').innerHTML = `<p>${data}</p>`);
|
52 |
-
}
|
53 |
</script>
|
54 |
-
|
55 |
</body>
|
56 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
<head>
|
4 |
+
<title>Chatbot - Hotel Booking</title>
|
5 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
|
|
|
|
6 |
</head>
|
7 |
<body>
|
8 |
+
<h1>Hotel Booking Chatbot</h1>
|
9 |
+
<div id="chatbot"></div>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/gradio"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
<script>
|
12 |
+
gr.Interface({
|
13 |
+
src: "/chatbot"
|
14 |
+
}).render("#chatbot");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
</script>
|
|
|
16 |
</body>
|
17 |
</html>
|