Spaces:
Runtime error
Runtime error
Update static/index.html
Browse files- static/index.html +166 -136
static/index.html
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
|
| 4 |
<head>
|
| 5 |
<meta charset="UTF-8">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
|
| 8 |
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
|
| 9 |
-
<title>Vion AI
|
| 10 |
<style>
|
| 11 |
-
|
| 12 |
|
| 13 |
* {
|
| 14 |
margin: 0;
|
|
@@ -79,22 +78,23 @@
|
|
| 79 |
to { background-position: 10000px 10000px; }
|
| 80 |
}
|
| 81 |
|
| 82 |
-
.
|
| 83 |
flex: 1;
|
| 84 |
display: flex;
|
| 85 |
flex-direction: column;
|
| 86 |
-
justify-content:
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
padding: 2rem;
|
| 90 |
}
|
| 91 |
|
| 92 |
-
.
|
|
|
|
| 93 |
text-align: center;
|
| 94 |
-
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
-
.
|
| 98 |
color: var(--text-color);
|
| 99 |
font-size: 3.5rem;
|
| 100 |
font-weight: 800;
|
|
@@ -102,7 +102,7 @@
|
|
| 102 |
text-shadow: 0 0 10px rgba(0, 163, 255, 0.5);
|
| 103 |
}
|
| 104 |
|
| 105 |
-
.
|
| 106 |
color: var(--text-secondary-color);
|
| 107 |
font-size: 1.5rem;
|
| 108 |
font-weight: 400;
|
|
@@ -111,197 +111,227 @@
|
|
| 111 |
text-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
| 112 |
}
|
| 113 |
|
| 114 |
-
.
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
margin
|
|
|
|
|
|
|
|
|
|
| 118 |
}
|
| 119 |
|
| 120 |
-
.
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
}
|
| 124 |
|
| 125 |
-
.
|
| 126 |
-
|
| 127 |
}
|
| 128 |
|
| 129 |
-
.
|
| 130 |
-
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
|
| 133 |
-
.
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
border-radius: 1rem;
|
| 137 |
-
background: var(--secondary-color);
|
| 138 |
-
color: var(--text-color);
|
| 139 |
}
|
| 140 |
|
| 141 |
-
.
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
}
|
| 145 |
|
| 146 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
display: flex;
|
| 148 |
align-items: center;
|
| 149 |
background: var(--secondary-color);
|
| 150 |
border: 1px solid var(--focus-color);
|
| 151 |
border-radius: 0.5rem;
|
| 152 |
padding: 0.2rem;
|
|
|
|
| 153 |
}
|
| 154 |
|
| 155 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
flex-grow: 1;
|
| 157 |
border: none;
|
| 158 |
-
|
|
|
|
| 159 |
color: var(--text-color);
|
| 160 |
-
padding: 0.5rem;
|
|
|
|
| 161 |
outline: none;
|
| 162 |
}
|
| 163 |
|
| 164 |
-
.
|
| 165 |
color: var(--placeholder-color);
|
| 166 |
}
|
| 167 |
|
| 168 |
-
.
|
| 169 |
-
background: none;
|
| 170 |
-
border: none;
|
| 171 |
-
color: var(--text-secondary-color);
|
| 172 |
-
font-size: 1.1rem;
|
| 173 |
-
cursor: pointer;
|
| 174 |
-
padding: 0.5rem;
|
| 175 |
-
transition: color 0.3s ease;
|
| 176 |
-
}
|
| 177 |
-
|
| 178 |
-
.chat-input button:hover {
|
| 179 |
-
color: var(--accent-color);
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
.file-upload {
|
| 183 |
display: flex;
|
| 184 |
align-items: center;
|
| 185 |
-
gap: 0.
|
|
|
|
| 186 |
}
|
| 187 |
|
| 188 |
-
.
|
| 189 |
-
|
|
|
|
| 190 |
color: var(--text-secondary-color);
|
|
|
|
|
|
|
|
|
|
| 191 |
transition: color 0.3s ease;
|
| 192 |
}
|
| 193 |
|
| 194 |
-
.
|
| 195 |
color: var(--accent-color);
|
| 196 |
}
|
| 197 |
|
| 198 |
-
.
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
}
|
| 201 |
</style>
|
| 202 |
</head>
|
| 203 |
-
|
| 204 |
<body>
|
| 205 |
<div class="stars"></div>
|
| 206 |
|
| 207 |
-
<div class="
|
| 208 |
-
<
|
| 209 |
-
<
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
<!-- Chat messages will appear here -->
|
| 215 |
-
</div>
|
| 216 |
|
| 217 |
-
<div class="
|
| 218 |
-
<div class="
|
| 219 |
-
<
|
| 220 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
</div>
|
| 222 |
-
<input type="text" id="chatInput" placeholder="Ask me anything...">
|
| 223 |
-
<button type="button" id="sendButton"><i class='bx bx-send'></i></button>
|
| 224 |
</div>
|
| 225 |
</div>
|
| 226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
<script>
|
| 228 |
-
|
| 229 |
-
const
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
messageContent.classList.add('message-content');
|
| 239 |
-
messageContent.innerText = text;
|
| 240 |
-
messageDiv.appendChild(messageContent);
|
| 241 |
-
chatMessages.appendChild(messageDiv);
|
| 242 |
-
chatMessages.scrollTop = chatMessages.scrollHeight; // Auto-scroll to the bottom
|
| 243 |
-
}
|
| 244 |
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
const
|
| 248 |
-
|
| 249 |
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
}
|
|
|
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
| 258 |
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
|
|
|
| 262 |
|
| 263 |
-
// Prepare the payload
|
| 264 |
const formData = new FormData();
|
| 265 |
-
|
| 266 |
-
if (userInput) formData.append('text', userInput);
|
| 267 |
-
|
| 268 |
-
// Determine the endpoint based on the input
|
| 269 |
-
let endpoint = '/summarize'; // Default to summarization
|
| 270 |
-
if (file && file.type.startsWith('image/')) {
|
| 271 |
-
endpoint = userInput ? '/vqa' : '/caption';
|
| 272 |
-
} else if (file && file.name.endsWith('.xlsx') || file.name.endsWith('.xls')) {
|
| 273 |
-
endpoint = '/visualize';
|
| 274 |
-
formData.append('request', userInput || "Generate a bar chart");
|
| 275 |
-
} else if (userInput && userInput.startsWith("/translate")) {
|
| 276 |
-
endpoint = '/translate';
|
| 277 |
-
formData.append('target_language', 'fr'); // Default to French
|
| 278 |
-
} else if (userInput && userInput.startsWith("/qa")) {
|
| 279 |
-
endpoint = '/answer';
|
| 280 |
-
formData.append('question', userInput.replace("/qa", "").trim());
|
| 281 |
-
}
|
| 282 |
|
| 283 |
-
// Send the input to the backend
|
| 284 |
try {
|
| 285 |
-
const response = await fetch(
|
| 286 |
method: 'POST',
|
| 287 |
-
body: formData
|
| 288 |
});
|
|
|
|
|
|
|
| 289 |
const data = await response.json();
|
| 290 |
-
|
| 291 |
} catch (error) {
|
| 292 |
console.error('Error:', error);
|
| 293 |
-
|
| 294 |
}
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
// Event listeners
|
| 298 |
-
sendButton.addEventListener('click', handleUserInput);
|
| 299 |
-
chatInput.addEventListener('keypress', (e) => {
|
| 300 |
-
if (e.key === 'Enter') handleUserInput();
|
| 301 |
});
|
| 302 |
</script>
|
| 303 |
</body>
|
| 304 |
-
|
| 305 |
-
</html>
|
| 306 |
-
|
| 307 |
-
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
|
| 7 |
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
|
| 8 |
+
<title>Vion AI</title>
|
| 9 |
<style>
|
| 10 |
+
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;800&display=swap');
|
| 11 |
|
| 12 |
* {
|
| 13 |
margin: 0;
|
|
|
|
| 78 |
to { background-position: 10000px 10000px; }
|
| 79 |
}
|
| 80 |
|
| 81 |
+
.main-content {
|
| 82 |
flex: 1;
|
| 83 |
display: flex;
|
| 84 |
flex-direction: column;
|
| 85 |
+
justify-content: center;
|
| 86 |
+
padding-bottom: 80px;
|
| 87 |
+
padding-top: 2rem;
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
+
.header {
|
| 91 |
+
max-width: 900px;
|
| 92 |
text-align: center;
|
| 93 |
+
padding: 0 2rem;
|
| 94 |
+
margin: 0 auto;
|
| 95 |
}
|
| 96 |
|
| 97 |
+
.header__title h1 {
|
| 98 |
color: var(--text-color);
|
| 99 |
font-size: 3.5rem;
|
| 100 |
font-weight: 800;
|
|
|
|
| 102 |
text-shadow: 0 0 10px rgba(0, 163, 255, 0.5);
|
| 103 |
}
|
| 104 |
|
| 105 |
+
.header__title h2 {
|
| 106 |
color: var(--text-secondary-color);
|
| 107 |
font-size: 1.5rem;
|
| 108 |
font-weight: 400;
|
|
|
|
| 111 |
text-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
| 112 |
}
|
| 113 |
|
| 114 |
+
.suggests {
|
| 115 |
+
display: grid;
|
| 116 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 117 |
+
margin: 2rem auto;
|
| 118 |
+
max-width: 900px;
|
| 119 |
+
gap: 1rem;
|
| 120 |
+
padding: 0 2rem;
|
| 121 |
}
|
| 122 |
|
| 123 |
+
.suggests__item {
|
| 124 |
+
background: rgba(26, 27, 30, 0.9);
|
| 125 |
+
color: var(--text-secondary-color);
|
| 126 |
+
padding: 1.5rem;
|
| 127 |
+
border-radius: 0.5rem;
|
| 128 |
+
cursor: pointer;
|
| 129 |
+
transition: all 0.3s ease;
|
| 130 |
+
border: 1px solid var(--focus-color);
|
| 131 |
}
|
| 132 |
|
| 133 |
+
.light_mode .suggests__item {
|
| 134 |
+
background: rgba(245, 246, 245, 0.9);
|
| 135 |
}
|
| 136 |
|
| 137 |
+
.suggests__item:hover {
|
| 138 |
+
background: var(--secondary-hover-color);
|
| 139 |
+
border-color: var(--accent-color);
|
| 140 |
+
color: var(--text-color);
|
| 141 |
}
|
| 142 |
|
| 143 |
+
.suggests__item-icon {
|
| 144 |
+
margin-top: 1rem;
|
| 145 |
+
color: var(--accent-color);
|
|
|
|
|
|
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
+
.prompt {
|
| 149 |
+
position: fixed;
|
| 150 |
+
background: rgba(10, 10, 11, 0.9);
|
| 151 |
+
z-index: 1000;
|
| 152 |
+
width: 100%;
|
| 153 |
+
left: 0;
|
| 154 |
+
bottom: 0;
|
| 155 |
+
padding: 1rem;
|
| 156 |
+
border-top: 1px solid var(--secondary-color);
|
| 157 |
}
|
| 158 |
|
| 159 |
+
.light_mode .prompt {
|
| 160 |
+
background: rgba(245, 246, 245, 0.9);
|
| 161 |
+
border-top: 1px solid var(--focus-color);
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.prompt__input-wrapper {
|
| 165 |
+
max-width: 900px;
|
| 166 |
+
margin: 0 auto;
|
| 167 |
+
position: relative;
|
| 168 |
display: flex;
|
| 169 |
align-items: center;
|
| 170 |
background: var(--secondary-color);
|
| 171 |
border: 1px solid var(--focus-color);
|
| 172 |
border-radius: 0.5rem;
|
| 173 |
padding: 0.2rem;
|
| 174 |
+
transition: all 0.3s ease;
|
| 175 |
}
|
| 176 |
|
| 177 |
+
.prompt__input-wrapper:focus-within {
|
| 178 |
+
border-color: var(--accent-color);
|
| 179 |
+
background: var(--focus-color);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.prompt__form-input {
|
| 183 |
flex-grow: 1;
|
| 184 |
border: none;
|
| 185 |
+
resize: none;
|
| 186 |
+
font-size: 1.1rem;
|
| 187 |
color: var(--text-color);
|
| 188 |
+
padding: 0.3rem 0.5rem;
|
| 189 |
+
background: transparent;
|
| 190 |
outline: none;
|
| 191 |
}
|
| 192 |
|
| 193 |
+
.prompt__form-input::placeholder {
|
| 194 |
color: var(--placeholder-color);
|
| 195 |
}
|
| 196 |
|
| 197 |
+
.prompt__action-buttons {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
display: flex;
|
| 199 |
align-items: center;
|
| 200 |
+
gap: 0.3rem;
|
| 201 |
+
padding-right: 0.3rem;
|
| 202 |
}
|
| 203 |
|
| 204 |
+
.prompt__form-button {
|
| 205 |
+
background: none;
|
| 206 |
+
border: none;
|
| 207 |
color: var(--text-secondary-color);
|
| 208 |
+
font-size: 1.1rem;
|
| 209 |
+
cursor: pointer;
|
| 210 |
+
padding: 0.2rem;
|
| 211 |
transition: color 0.3s ease;
|
| 212 |
}
|
| 213 |
|
| 214 |
+
.prompt__form-button:hover {
|
| 215 |
color: var(--accent-color);
|
| 216 |
}
|
| 217 |
|
| 218 |
+
.prompt__disclaim {
|
| 219 |
+
text-align: center;
|
| 220 |
+
color: var(--placeholder-color);
|
| 221 |
+
font-size: 0.8rem;
|
| 222 |
+
margin-top: 1rem;
|
| 223 |
+
max-width: 900px;
|
| 224 |
+
margin-left: auto;
|
| 225 |
+
margin-right: auto;
|
| 226 |
+
text-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
|
| 227 |
}
|
| 228 |
</style>
|
| 229 |
</head>
|
|
|
|
| 230 |
<body>
|
| 231 |
<div class="stars"></div>
|
| 232 |
|
| 233 |
+
<div class="main-content">
|
| 234 |
+
<header class="header">
|
| 235 |
+
<div class="header__title">
|
| 236 |
+
<h1>Vion AI</h1>
|
| 237 |
+
<h2>Ask me anything and I'll provide helpful and truthful answers from an outside perspective on humanity.</h2>
|
| 238 |
+
</div>
|
| 239 |
+
</header>
|
|
|
|
|
|
|
| 240 |
|
| 241 |
+
<div class="suggests">
|
| 242 |
+
<div class="suggests__item" onclick="sendPrompt('What is the meaning of life?', 'summarize')">
|
| 243 |
+
<p class="suggests__item-text">What is the meaning of life?</p>
|
| 244 |
+
<div class="suggests__item-icon"><i class='bx bx-bulb'></i></div>
|
| 245 |
+
</div>
|
| 246 |
+
<div class="suggests__item" onclick="sendPrompt('Explain quantum physics simply', 'summarize')">
|
| 247 |
+
<p class="suggests__item-text">Explain quantum physics simply</p>
|
| 248 |
+
<div class="suggests__item-icon"><i class='bx bx-atom'></i></div>
|
| 249 |
+
</div>
|
| 250 |
+
<div class="suggests__item" onclick="sendPrompt('How does the universe work?', 'summarize')">
|
| 251 |
+
<p class="suggests__item-text">How does the universe work?</p>
|
| 252 |
+
<div class="suggests__item-icon"><i class='bx bx-planet'></i></div>
|
| 253 |
</div>
|
|
|
|
|
|
|
| 254 |
</div>
|
| 255 |
</div>
|
| 256 |
|
| 257 |
+
<section class="prompt">
|
| 258 |
+
<form id="promptForm" class="prompt__form" novalidate>
|
| 259 |
+
<div class="prompt__input-wrapper">
|
| 260 |
+
<input type="text" id="promptInput" placeholder="Ask me anything..." class="prompt__form-input" required>
|
| 261 |
+
<div class="prompt__action-buttons">
|
| 262 |
+
<label for="fileInput" class="prompt__form-button"><i class='bx bx-upload'></i></label>
|
| 263 |
+
<input type="file" id="fileInput" style="display: none;" accept=".pdf,.docx,.txt">
|
| 264 |
+
<button type="button" class="prompt__form-button" id="deepSearchButton"><i class='bx bx-search'></i></button>
|
| 265 |
+
<button type="button" class="prompt__form-button" id="thinkButton"><i class='bx bx-brain'></i></button>
|
| 266 |
+
<button type="submit" class="prompt__form-button" id="sendButton"><i class='bx bx-send'></i></button>
|
| 267 |
+
<button type="button" class="prompt__form-button" id="themeToggler"><i class='bx bx-sun'></i></button>
|
| 268 |
+
</div>
|
| 269 |
+
</div>
|
| 270 |
+
</form>
|
| 271 |
+
<p class="prompt__disclaim">Vion AI provides answers based on its training and design. Vion can make mistakes.</p>
|
| 272 |
+
</section>
|
| 273 |
+
|
| 274 |
<script>
|
| 275 |
+
// Theme toggle
|
| 276 |
+
const themeToggler = document.getElementById('themeToggler');
|
| 277 |
+
themeToggler.addEventListener('click', () => {
|
| 278 |
+
document.body.classList.toggle('light_mode');
|
| 279 |
+
themeToggler.innerHTML = document.body.classList.contains('light_mode') ? "<i class='bx bx-moon'></i>" : "<i class='bx bx-sun'></i>";
|
| 280 |
+
});
|
| 281 |
+
|
| 282 |
+
// Send prompt to backend
|
| 283 |
+
const promptForm = document.getElementById('promptForm');
|
| 284 |
+
const promptInput = document.getElementById('promptInput');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
+
promptForm.addEventListener('submit', async (e) => {
|
| 287 |
+
e.preventDefault();
|
| 288 |
+
const prompt = promptInput.value.trim();
|
| 289 |
+
if (!prompt) return;
|
| 290 |
|
| 291 |
+
try {
|
| 292 |
+
const response = await fetch('/summarize', {
|
| 293 |
+
method: 'POST',
|
| 294 |
+
headers: { 'Content-Type': 'application/json' },
|
| 295 |
+
body: JSON.stringify({ text: prompt })
|
| 296 |
+
});
|
| 297 |
+
|
| 298 |
+
if (!response.ok) throw new Error('Failed to fetch response');
|
| 299 |
+
const data = await response.json();
|
| 300 |
+
alert(`Response: ${data.summary}`);
|
| 301 |
+
} catch (error) {
|
| 302 |
+
console.error('Error:', error);
|
| 303 |
+
alert('Failed to get a response. Please try again.');
|
| 304 |
}
|
| 305 |
+
});
|
| 306 |
|
| 307 |
+
// Send predefined prompt
|
| 308 |
+
function sendPrompt(prompt, endpoint) {
|
| 309 |
+
promptInput.value = prompt;
|
| 310 |
+
promptForm.dispatchEvent(new Event('submit'));
|
| 311 |
+
}
|
| 312 |
|
| 313 |
+
// File upload
|
| 314 |
+
document.getElementById('fileInput').addEventListener('change', async (e) => {
|
| 315 |
+
const file = e.target.files[0];
|
| 316 |
+
if (!file) return;
|
| 317 |
|
|
|
|
| 318 |
const formData = new FormData();
|
| 319 |
+
formData.append('file', file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
|
|
|
|
| 321 |
try {
|
| 322 |
+
const response = await fetch('/summarize', {
|
| 323 |
method: 'POST',
|
| 324 |
+
body: formData
|
| 325 |
});
|
| 326 |
+
|
| 327 |
+
if (!response.ok) throw new Error('Failed to upload file');
|
| 328 |
const data = await response.json();
|
| 329 |
+
alert(`Summary: ${data.summary}`);
|
| 330 |
} catch (error) {
|
| 331 |
console.error('Error:', error);
|
| 332 |
+
alert('Failed to process file. Please try again.');
|
| 333 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
});
|
| 335 |
</script>
|
| 336 |
</body>
|
| 337 |
+
</html>
|
|
|
|
|
|
|
|
|