-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
212 lines (177 loc) · 6.74 KB
/
index.html
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Louvre Museum Guide</title>
<style>
body {
font-family: "Arial", sans-serif;
margin: 0;
padding: 0;
background-color: #fafafa;
}
header {
background-image: url('\\images\\image.jpg'); /* Replace with actual Louvre Museum image URL */
background-repeat: no-repeat;
background-size: cover;
color: #fff;
text-align: center;
padding: 1rem 0;
position: relative;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.logo {
display: inline-block;
margin-right: 10px;
vertical-align: middle;
}
main {
padding: 20px;
text-align: center;
}
h1 {
font-size: 48px;
margin-bottom: 20px;
font-weight: bold;
text-transform: uppercase;
color: #00203f; /* Deep blue color for the title */
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}
input[type="text"] {
width: 100%;
padding: 12px;
font-size: 18px;
margin-bottom: 20px;
border: 1px solid #ccc;
border-radius: 5px;
outline: none;
}
input[type="text"]:focus {
border-color: #007bff; /* Bright blue color for the focus state */
}
button {
background-color: #007bff; /* Bright blue color for the button */
color: #fff;
font-size: 18px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #0056b3; /* Slightly darker blue color on hover */
}
.conversation {
height: 300px;
overflow-y: auto;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
background-color: #fff;
margin-bottom: 20px;
text-align: left;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
#output {
font-size: 18px;
font-weight: bold;
text-align: left;
}
.user-message {
color: #007bff; /* Bright blue color for user messages */
}
.guide-message {
color: #00203f; /* Deep blue color for guide messages */
margin-bottom: 10px;
}
.footer {
background-color: #00203f; /* Deep blue color for the footer */
padding: 10px 0;
color: #fff;
}
.footer p {
margin: 0;
font-size: 14px;
}
</style>
</head>
<body>
<header>
<h1>Louvre Museum Guide</h1>
</header>
<main>
<div class="conversation" id="output"></div>
<input type="text" id="userInput" placeholder="Enter your message">
<button onclick="showMessage()">Send Message</button>
<br><br>
<div class="footer">
<p>© 2023 Louvre Museum Guide | All rights reserved</p>
</div>
</main>
<script>
const endKeywords = ['no', 'thank you', 'thanks', 'thank you!', 'thanks!','no thank you','no thanks'];
const continueKeywords = ['yes', 'please','oh yes', 'yes please'];
let previousResponses = new Set();
let isFirstMessage = true;
function showGreeting() {
if (isFirstMessage) {
const outputDiv = document.getElementById("output");
outputDiv.innerHTML += "<p>Guide: Welcome to the Louvre Museum! I'm here to provide you with information and answer any questions you may have.</p>";
isFirstMessage = false;
}
}
async function showMessage() {
showGreeting();
while (true) {
const userInput = document.getElementById("userInput").value.trim();
if (userInput === '') {
return;
}
const outputDiv = document.getElementById("output");
outputDiv.innerHTML += "<p>User: " + userInput + "</p>";
if (endKeywords.includes(userInput.toLowerCase())) {
outputDiv.innerHTML += "<p>Guide: Enjoy your time exploring the incredible art at the Louvre Museum!</p>";
previousResponses.clear();
break;
} else {
let continueConversation = false;
if (continueKeywords.includes(userInput.toLowerCase())) {
continueConversation = true;
outputDiv.innerHTML += "<p>Guide: Sure, ask whatever you want!</p>";
} else {
try {
const response = await fetch('/generate_text', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ sequence: userInput }), // Ensure the key matches with the server-side variable name
});
const data = await response.json();
if (response.ok) {
const guideResponse = data.generated_text;
outputDiv.innerHTML += "<p>Guide: " + guideResponse + "</p>";
outputDiv.innerHTML += "<p>Guide: Do you need anything else?</p>";
} else {
outputDiv.innerHTML = "Error: Failed to generate text.";
return;
}
} catch (error) {
outputDiv.innerHTML = "Error: " + error.message;
return;
}
}
previousResponses.add(userInput.toLowerCase());
document.getElementById("userInput").value = '';
if (!continueConversation) {
break;
}
}
}
}
// Call showMessage() when the page loads
showMessage();
</script>
</body>
</html>