-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTML_UI.html
248 lines (235 loc) · 8.75 KB
/
HTML_UI.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>watsonx Model</title>
<link rel="icon" type="image/svg+xml" href="https://www.ibm.com/content/dam/adobe-cms/default-images/favicon.svg">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-image: url('https://www.horsesforsources.com/wp-content/uploads/2023/05/Watsonx.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 100vh;
overflow: hidden; /* Prevents scrolling on the body */
}
.header {
background-color: black;
color: white;
padding: 10px;
text-align: left;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000; /* Ensures the header is above other content */
display: flex;
align-items: center;
box-sizing: border-box;
}
.header img {
height: 40px; /* Adjust the size of the favicon */
margin-right: 10px; /* Space between the favicon and text */
}
.header .logo {
font-size: 2em; /* Larger font size for IBM */
font-family: 'IBM Plex Sans', sans-serif; /* IBM font */
margin: 0; /* Remove default margin */
}
.header .line {
width: 100%;
border-top: 2px solid white; /* Horizontal line */
margin: 5px 0 0 0; /* Space above the line */
}
.header .text {
font-size: 1em; /* Normal font size for the rest of the text */
font-family: 'IBM Plex Sans', sans-serif; /* IBM font */
margin: 0; /* Remove default margin */
}
.container {
display: flex;
flex-direction: column;
width: 80%;
max-width: 800px;
height: calc(100% - 80px); /* Adjust height to leave space for header */
margin: 80px auto 0; /* Add margin to push content below the header */
background-color: rgba(255, 255, 255, 0.9); /* Slightly transparent background */
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
overflow: hidden;
}
.chat {
flex: 1;
padding: 10px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 10px; /* Space between messages */
}
.message {
margin-bottom: 10px;
}
.message.user {
text-align: right;
}
.message.bot {
text-align: left;
}
.message p {
display: inline-block;
padding: 10px;
border-radius: 5px;
max-width: 60%;
}
.message.user p {
background-color: #e1ffc7; /* Light green */
}
.message.bot p {
background-color: #f1f1f1; /* Light gray */
}
.typing-indicator {
display: flex;
align-items: center;
font-size: 24px; /* Increase size for better visibility */
color: #333; /* Darker color for better contrast */
margin-top: 10px;
}
.typing-indicator span {
display: inline-block;
animation: jump 1s infinite;
font-weight: bold; /* Make dots bold */
}
.typing-indicator span:nth-child(2) {
animation-delay: 0.2s;
}
.typing-indicator span:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes jump {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
textarea {
width: calc(100% - 20px);
height: 60px;
padding: 10px;
margin: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 5px;
resize: none;
}
.footer {
position: fixed;
bottom: 10px;
right: 10px;
background-color: black;
color: white;
padding: 15px 25px; /* Increased padding for larger area */
border-radius: 5px;
font-family: 'IBM Plex Sans', sans-serif;
font-size: 1.5em; /* Increased font size */
z-index: 1000; /* Ensures the footer is above other content */
display: flex;
align-items: center;
}
.footer .highlight {
color: #0072CE; /* IBM Blue */
font-weight: bold;
}
</style>
</head>
<body>
<div class="header">
<img src="https://www.ibm.com/content/dam/adobe-cms/default-images/favicon.svg" alt="IBM Favicon">
<div>
<div class="logo">IBM</div>
<div class="line"></div>
<div class="text">IBM Sterling Order Management System Software</div>
</div>
</div>
<div class="container">
<div class="chat" id="chat">
<!-- Messages will be dynamically added here -->
</div>
<textarea id="question" placeholder="Type your question here..."></textarea>
</div>
<div class="footer">
dream<span class="highlight">AI</span>rs
</div>
<script>
document.getElementById('question').addEventListener('keydown', function(event) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault(); // Prevents the default action of inserting a new line
askQuestion();
}
});
async function askQuestion() {
const question = document.getElementById('question').value;
const chat = document.getElementById('chat');
if (!question.trim()) {
return; // Do nothing if the question is empty
}
// Add user message to chat
const userMessage = document.createElement('div');
userMessage.className = 'message user';
userMessage.innerHTML = `<p>${question}</p>`;
chat.appendChild(userMessage);
// Add typing indicator
const typingIndicator = document.createElement('div');
typingIndicator.className = 'typing-indicator';
typingIndicator.innerHTML = `
<span>.</span><span>.</span><span>.</span>
`;
chat.appendChild(typingIndicator);
// Clear the input
document.getElementById('question').value = '';
try {
const response = await fetch('http://127.0.0.1:5000/ask', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ question })
});
// Remove typing indicator
chat.removeChild(typingIndicator);
if (!response.ok) {
const error = await response.json();
const botMessage = document.createElement('div');
botMessage.className = 'message bot';
botMessage.innerHTML = `<p>Error: ${error.error}</p>`;
chat.appendChild(botMessage);
scrollToBottom();
return;
}
const data = await response.json();
const botMessage = document.createElement('div');
botMessage.className = 'message bot';
botMessage.innerHTML = `<p>${data.answer}</p>`;
chat.appendChild(botMessage);
} catch (error) {
const botMessage = document.createElement('div');
botMessage.className = 'message bot';
botMessage.innerHTML = `<p>Request failed: ${error.message}</p>`;
chat.appendChild(botMessage);
}
// Scroll to the bottom of the chat
scrollToBottom();
}
function scrollToBottom() {
const chat = document.getElementById('chat');
chat.scrollTop = chat.scrollHeight;
}
</script>
</body>
</html>