Spaces:
Runtime error
Runtime error
Update static/index.html
Browse files- static/index.html +272 -266
static/index.html
CHANGED
|
@@ -7,317 +7,323 @@
|
|
| 7 |
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
|
| 8 |
<title>Vion AI</title>
|
| 9 |
<style>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
margin: 0;
|
| 14 |
-
padding: 0;
|
| 15 |
-
outline: none;
|
| 16 |
-
box-sizing: border-box;
|
| 17 |
-
font-family: "Open Sans", sans-serif;
|
| 18 |
}
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
--primary-color: #0A0A0B;
|
| 22 |
-
--secondary-color: #1A1B1E;
|
| 23 |
-
--secondary-hover-color: #2A2B2E;
|
| 24 |
-
--focus-color: #242528;
|
| 25 |
-
--focus-hover-color: #343538;
|
| 26 |
-
--button-hover-color: #252627;
|
| 27 |
-
--text-color: #FFFFFF;
|
| 28 |
-
--text-secondary-color: #A0A1A3;
|
| 29 |
-
--heading-secondary-color: #606162;
|
| 30 |
-
--placeholder-color: #78797A;
|
| 31 |
-
--accent-color: #00A3FF;
|
| 32 |
-
--star-color: #FFFFFF;
|
| 33 |
-
--background-color: #000;
|
| 34 |
}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
--primary-color: #FFFFFF;
|
| 38 |
-
--secondary-color: #F5F6F5;
|
| 39 |
-
--secondary-hover-color: #E5E6E5;
|
| 40 |
-
--focus-color: #ECEDEC;
|
| 41 |
-
--focus-hover-color: #E0E1E0;
|
| 42 |
-
--button-hover-color: #ECEDED;
|
| 43 |
-
--text-color: #0A0A0B;
|
| 44 |
-
--text-secondary-color: #4A4B4C;
|
| 45 |
-
--heading-secondary-color: #BABBBB;
|
| 46 |
-
--placeholder-color: #868788;
|
| 47 |
-
--accent-color: #007ACC;
|
| 48 |
-
--star-color: #666;
|
| 49 |
-
--background-color: #E0E7FF;
|
| 50 |
}
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
min-height: 100vh;
|
| 54 |
-
display: flex;
|
| 55 |
-
flex-direction: column;
|
| 56 |
-
justify-content: space-between;
|
| 57 |
-
background: var(--background-color);
|
| 58 |
-
position: relative;
|
| 59 |
-
overflow-y: auto;
|
| 60 |
}
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
| 64 |
width: 100%;
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
animation: starsAnim 100s linear infinite;
|
| 68 |
-
z-index: -1;
|
| 69 |
}
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
| 74 |
}
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
to { background-position: 10000px 10000px; }
|
| 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 |
-
transition: all 0.3s ease;
|
| 130 |
-
border: 1px solid var(--focus-color);
|
| 131 |
-
}
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
color: var(--text-color);
|
| 141 |
-
}
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
width: 100%;
|
| 153 |
-
left: 0;
|
| 154 |
-
bottom: 0;
|
| 155 |
-
padding: 1rem;
|
| 156 |
-
border-top: 1px solid var(--secondary-color);
|
| 157 |
-
}
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 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 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
padding: 0.3rem 0.5rem;
|
| 189 |
-
background: transparent;
|
| 190 |
-
outline: none;
|
| 191 |
-
}
|
| 192 |
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
| 196 |
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
padding-right: 0.3rem;
|
| 202 |
-
}
|
| 203 |
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 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 |
-
|
| 234 |
-
|
| 235 |
-
|
| 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 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
</div>
|
| 254 |
-
</div>
|
| 255 |
-
</div>
|
| 256 |
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 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 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
});
|
| 281 |
|
| 282 |
-
//
|
| 283 |
-
|
| 284 |
-
const promptInput = document.getElementById('promptInput');
|
| 285 |
-
const fileInput = document.getElementById('fileInput');
|
| 286 |
-
promptForm.addEventListener('submit', async (e) => {
|
| 287 |
e.preventDefault();
|
| 288 |
-
const
|
| 289 |
-
const file =
|
| 290 |
-
|
| 291 |
-
|
|
|
|
|
|
|
| 292 |
return;
|
| 293 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
try {
|
| 295 |
-
const
|
| 296 |
-
if (file) formData.append('file', file);
|
| 297 |
-
if (prompt) formData.append('text', prompt);
|
| 298 |
-
console.log("Sending request with:", { prompt, file }); // Debugging
|
| 299 |
-
const response = await fetch('/summarize', {
|
| 300 |
method: 'POST',
|
| 301 |
body: formData
|
| 302 |
});
|
| 303 |
-
if (!response.ok) {
|
| 304 |
-
console.error("Response error:", response.status, response.statusText); // Debugging
|
| 305 |
-
throw new Error('Failed to fetch response');
|
| 306 |
-
}
|
| 307 |
const data = await response.json();
|
| 308 |
-
|
| 309 |
-
alert(`Response: ${data.summary}`);
|
| 310 |
} catch (error) {
|
| 311 |
console.error('Error:', error);
|
| 312 |
-
|
| 313 |
}
|
| 314 |
});
|
| 315 |
-
|
| 316 |
-
// Send predefined prompt
|
| 317 |
-
function sendPrompt(prompt, endpoint) {
|
| 318 |
-
promptInput.value = prompt;
|
| 319 |
-
promptForm.dispatchEvent(new Event('submit'));
|
| 320 |
-
}
|
| 321 |
</script>
|
| 322 |
</body>
|
| 323 |
</html>
|
|
|
|
| 7 |
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
|
| 8 |
<title>Vion AI</title>
|
| 9 |
<style>
|
| 10 |
+
body {
|
| 11 |
+
font-family: Arial, sans-serif;
|
| 12 |
+
margin: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
+
.section {
|
| 15 |
+
margin-bottom: 30px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
+
.section h2 {
|
| 18 |
+
margin-bottom: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
+
.form-group {
|
| 21 |
+
margin-bottom: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
+
.form-group label {
|
| 24 |
+
display: block;
|
| 25 |
+
margin-bottom: 5px;
|
| 26 |
+
}
|
| 27 |
+
.form-group input, .form-group textarea, .form-group select {
|
| 28 |
width: 100%;
|
| 29 |
+
padding: 8px;
|
| 30 |
+
box-sizing: border-box;
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
+
.result {
|
| 33 |
+
margin-top: 10px;
|
| 34 |
+
padding: 10px;
|
| 35 |
+
background-color: #f4f4f4;
|
| 36 |
+
border-radius: 5px;
|
| 37 |
}
|
| 38 |
+
.result pre {
|
| 39 |
+
white-space: pre-wrap;
|
| 40 |
+
word-wrap: break-word;
|
|
|
|
| 41 |
}
|
| 42 |
+
</style>
|
| 43 |
+
</head>
|
| 44 |
+
<body>
|
| 45 |
+
<h1>Vion AI - All Functionalities</h1>
|
| 46 |
+
|
| 47 |
+
<!-- Summarization Section -->
|
| 48 |
+
<div class="section">
|
| 49 |
+
<h2>Summarization</h2>
|
| 50 |
+
<form id="summarizeForm">
|
| 51 |
+
<div class="form-group">
|
| 52 |
+
<label for="summarizeText">Enter Text:</label>
|
| 53 |
+
<textarea id="summarizeText" rows="5" placeholder="Paste your text here..."></textarea>
|
| 54 |
+
</div>
|
| 55 |
+
<div class="form-group">
|
| 56 |
+
<label for="summarizeFile">Or Upload a File (PDF, DOCX, TXT):</label>
|
| 57 |
+
<input type="file" id="summarizeFile" accept=".pdf,.docx,.txt">
|
| 58 |
+
</div>
|
| 59 |
+
<button type="submit">Summarize</button>
|
| 60 |
+
</form>
|
| 61 |
+
<div class="result" id="summarizeResult"></div>
|
| 62 |
+
</div>
|
| 63 |
|
| 64 |
+
<!-- Image Captioning Section -->
|
| 65 |
+
<div class="section">
|
| 66 |
+
<h2>Image Captioning</h2>
|
| 67 |
+
<form id="captionForm">
|
| 68 |
+
<div class="form-group">
|
| 69 |
+
<label for="imageInput">Upload an Image (JPEG, PNG):</label>
|
| 70 |
+
<input type="file" id="imageInput" accept="image/jpeg, image/png" required>
|
| 71 |
+
</div>
|
| 72 |
+
<button type="submit">Generate Caption</button>
|
| 73 |
+
</form>
|
| 74 |
+
<div class="result" id="captionResult"></div>
|
| 75 |
+
</div>
|
| 76 |
|
| 77 |
+
<!-- Question Answering Section -->
|
| 78 |
+
<div class="section">
|
| 79 |
+
<h2>Question Answering</h2>
|
| 80 |
+
<form id="qaForm">
|
| 81 |
+
<div class="form-group">
|
| 82 |
+
<label for="qaText">Enter Context:</label>
|
| 83 |
+
<textarea id="qaText" rows="5" placeholder="Paste your text here..."></textarea>
|
| 84 |
+
</div>
|
| 85 |
+
<div class="form-group">
|
| 86 |
+
<label for="qaFile">Or Upload a File (PDF, DOCX, TXT):</label>
|
| 87 |
+
<input type="file" id="qaFile" accept=".pdf,.docx,.txt">
|
| 88 |
+
</div>
|
| 89 |
+
<div class="form-group">
|
| 90 |
+
<label for="qaQuestion">Enter Question:</label>
|
| 91 |
+
<input type="text" id="qaQuestion" placeholder="Enter your question..." required>
|
| 92 |
+
</div>
|
| 93 |
+
<button type="submit">Get Answer</button>
|
| 94 |
+
</form>
|
| 95 |
+
<div class="result" id="qaResult"></div>
|
| 96 |
+
</div>
|
| 97 |
|
| 98 |
+
<!-- Visual Question Answering Section -->
|
| 99 |
+
<div class="section">
|
| 100 |
+
<h2>Visual Question Answering</h2>
|
| 101 |
+
<form id="vqaForm">
|
| 102 |
+
<div class="form-group">
|
| 103 |
+
<label for="vqaImage">Upload an Image (JPEG, PNG):</label>
|
| 104 |
+
<input type="file" id="vqaImage" accept="image/jpeg, image/png" required>
|
| 105 |
+
</div>
|
| 106 |
+
<div class="form-group">
|
| 107 |
+
<label for="vqaQuestion">Enter Question:</label>
|
| 108 |
+
<input type="text" id="vqaQuestion" placeholder="Enter your question..." required>
|
| 109 |
+
</div>
|
| 110 |
+
<button type="submit">Get Answer</button>
|
| 111 |
+
</form>
|
| 112 |
+
<div class="result" id="vqaResult"></div>
|
| 113 |
+
</div>
|
| 114 |
|
| 115 |
+
<!-- Data Visualization Code Generation Section -->
|
| 116 |
+
<div class="section">
|
| 117 |
+
<h2>Data Visualization Code Generation</h2>
|
| 118 |
+
<form id="visualizeForm">
|
| 119 |
+
<div class="form-group">
|
| 120 |
+
<label for="visualizeFile">Upload an Excel File:</label>
|
| 121 |
+
<input type="file" id="visualizeFile" accept=".xlsx,.xls" required>
|
| 122 |
+
</div>
|
| 123 |
+
<div class="form-group">
|
| 124 |
+
<label for="visualizeRequest">Enter Visualization Request:</label>
|
| 125 |
+
<input type="text" id="visualizeRequest" placeholder="e.g., bar chart, line chart" required>
|
| 126 |
+
</div>
|
| 127 |
+
<button type="submit">Generate Code</button>
|
| 128 |
+
</form>
|
| 129 |
+
<div class="result" id="visualizeResult"></div>
|
| 130 |
+
</div>
|
| 131 |
|
| 132 |
+
<!-- Document Translation Section -->
|
| 133 |
+
<div class="section">
|
| 134 |
+
<h2>Document Translation</h2>
|
| 135 |
+
<form id="translateForm">
|
| 136 |
+
<div class="form-group">
|
| 137 |
+
<label for="translateText">Enter Text:</label>
|
| 138 |
+
<textarea id="translateText" rows="5" placeholder="Paste your text here..."></textarea>
|
| 139 |
+
</div>
|
| 140 |
+
<div class="form-group">
|
| 141 |
+
<label for="translateFile">Or Upload a File (PDF, DOCX, TXT):</label>
|
| 142 |
+
<input type="file" id="translateFile" accept=".pdf,.docx,.txt">
|
| 143 |
+
</div>
|
| 144 |
+
<div class="form-group">
|
| 145 |
+
<label for="translateLanguage">Select Target Language:</label>
|
| 146 |
+
<select id="translateLanguage">
|
| 147 |
+
<option value="fr">French</option>
|
| 148 |
+
<option value="es">Spanish</option>
|
| 149 |
+
<option value="de">German</option>
|
| 150 |
+
</select>
|
| 151 |
+
</div>
|
| 152 |
+
<button type="submit">Translate</button>
|
| 153 |
+
</form>
|
| 154 |
+
<div class="result" id="translateResult"></div>
|
| 155 |
+
</div>
|
| 156 |
|
| 157 |
+
<script>
|
| 158 |
+
// Summarization
|
| 159 |
+
document.getElementById('summarizeForm').addEventListener('submit', async (e) => {
|
| 160 |
+
e.preventDefault();
|
| 161 |
+
const text = document.getElementById('summarizeText').value.trim();
|
| 162 |
+
const file = document.getElementById('summarizeFile').files[0];
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
+
if (!text && !file) {
|
| 165 |
+
alert("Please enter text or upload a file.");
|
| 166 |
+
return;
|
| 167 |
+
}
|
| 168 |
|
| 169 |
+
const formData = new FormData();
|
| 170 |
+
if (file) formData.append('file', file);
|
| 171 |
+
if (text) formData.append('text', text);
|
|
|
|
|
|
|
| 172 |
|
| 173 |
+
try {
|
| 174 |
+
const response = await fetch('/summarize', {
|
| 175 |
+
method: 'POST',
|
| 176 |
+
body: formData
|
| 177 |
+
});
|
| 178 |
+
const data = await response.json();
|
| 179 |
+
document.getElementById('summarizeResult').innerText = `Summary: ${data.summary}`;
|
| 180 |
+
} catch (error) {
|
| 181 |
+
console.error('Error:', error);
|
| 182 |
+
document.getElementById('summarizeResult').innerText = 'Failed to summarize. Please try again.';
|
| 183 |
+
}
|
| 184 |
+
});
|
| 185 |
|
| 186 |
+
// Image Captioning
|
| 187 |
+
document.getElementById('captionForm').addEventListener('submit', async (e) => {
|
| 188 |
+
e.preventDefault();
|
| 189 |
+
const file = document.getElementById('imageInput').files[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
+
if (!file) {
|
| 192 |
+
alert("Please select an image file.");
|
| 193 |
+
return;
|
| 194 |
+
}
|
| 195 |
|
| 196 |
+
const formData = new FormData();
|
| 197 |
+
formData.append('file', file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
+
try {
|
| 200 |
+
const response = await fetch('/caption', {
|
| 201 |
+
method: 'POST',
|
| 202 |
+
body: formData
|
| 203 |
+
});
|
| 204 |
+
const data = await response.json();
|
| 205 |
+
document.getElementById('captionResult').innerText = `Caption: ${data.caption}`;
|
| 206 |
+
} catch (error) {
|
| 207 |
+
console.error('Error:', error);
|
| 208 |
+
document.getElementById('captionResult').innerText = 'Failed to generate caption. Please try again.';
|
| 209 |
+
}
|
| 210 |
+
});
|
| 211 |
|
| 212 |
+
// Question Answering
|
| 213 |
+
document.getElementById('qaForm').addEventListener('submit', async (e) => {
|
| 214 |
+
e.preventDefault();
|
| 215 |
+
const text = document.getElementById('qaText').value.trim();
|
| 216 |
+
const file = document.getElementById('qaFile').files[0];
|
| 217 |
+
const question = document.getElementById('qaQuestion').value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
+
if (!text && !file) {
|
| 220 |
+
alert("Please enter text or upload a file.");
|
| 221 |
+
return;
|
| 222 |
+
}
|
| 223 |
|
| 224 |
+
const formData = new FormData();
|
| 225 |
+
if (file) formData.append('file', file);
|
| 226 |
+
if (text) formData.append('text', text);
|
| 227 |
+
formData.append('question', question);
|
|
|
|
|
|
|
| 228 |
|
| 229 |
+
try {
|
| 230 |
+
const response = await fetch('/answer', {
|
| 231 |
+
method: 'POST',
|
| 232 |
+
body: formData
|
| 233 |
+
});
|
| 234 |
+
const data = await response.json();
|
| 235 |
+
document.getElementById('qaResult').innerText = `Answer: ${data.answer}`;
|
| 236 |
+
} catch (error) {
|
| 237 |
+
console.error('Error:', error);
|
| 238 |
+
document.getElementById('qaResult').innerText = 'Failed to get an answer. Please try again.';
|
| 239 |
+
}
|
| 240 |
+
});
|
| 241 |
|
| 242 |
+
// Visual Question Answering
|
| 243 |
+
document.getElementById('vqaForm').addEventListener('submit', async (e) => {
|
| 244 |
+
e.preventDefault();
|
| 245 |
+
const file = document.getElementById('vqaImage').files[0];
|
| 246 |
+
const question = document.getElementById('vqaQuestion').value.trim();
|
| 247 |
|
| 248 |
+
if (!file) {
|
| 249 |
+
alert("Please select an image file.");
|
| 250 |
+
return;
|
| 251 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
+
const formData = new FormData();
|
| 254 |
+
formData.append('file', file);
|
| 255 |
+
formData.append('question', question);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
+
try {
|
| 258 |
+
const response = await fetch('/vqa', {
|
| 259 |
+
method: 'POST',
|
| 260 |
+
body: formData
|
| 261 |
+
});
|
| 262 |
+
const data = await response.json();
|
| 263 |
+
document.getElementById('vqaResult').innerText = `Answer: ${data.answer}`;
|
| 264 |
+
} catch (error) {
|
| 265 |
+
console.error('Error:', error);
|
| 266 |
+
document.getElementById('vqaResult').innerText = 'Failed to get an answer. Please try again.';
|
| 267 |
+
}
|
| 268 |
+
});
|
|
|
|
|
|
|
|
|
|
| 269 |
|
| 270 |
+
// Data Visualization Code Generation
|
| 271 |
+
document.getElementById('visualizeForm').addEventListener('submit', async (e) => {
|
| 272 |
+
e.preventDefault();
|
| 273 |
+
const file = document.getElementById('visualizeFile').files[0];
|
| 274 |
+
const request = document.getElementById('visualizeRequest').value.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
+
if (!file) {
|
| 277 |
+
alert("Please upload an Excel file.");
|
| 278 |
+
return;
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
const formData = new FormData();
|
| 282 |
+
formData.append('file', file);
|
| 283 |
+
formData.append('request', request);
|
| 284 |
+
|
| 285 |
+
try {
|
| 286 |
+
const response = await fetch('/visualize', {
|
| 287 |
+
method: 'POST',
|
| 288 |
+
body: formData
|
| 289 |
+
});
|
| 290 |
+
const data = await response.json();
|
| 291 |
+
document.getElementById('visualizeResult').innerHTML = `<pre>${data.code}</pre>`;
|
| 292 |
+
} catch (error) {
|
| 293 |
+
console.error('Error:', error);
|
| 294 |
+
document.getElementById('visualizeResult').innerText = 'Failed to generate code. Please try again.';
|
| 295 |
+
}
|
| 296 |
});
|
| 297 |
|
| 298 |
+
// Document Translation
|
| 299 |
+
document.getElementById('translateForm').addEventListener('submit', async (e) => {
|
|
|
|
|
|
|
|
|
|
| 300 |
e.preventDefault();
|
| 301 |
+
const text = document.getElementById('translateText').value.trim();
|
| 302 |
+
const file = document.getElementById('translateFile').files[0];
|
| 303 |
+
const language = document.getElementById('translateLanguage').value;
|
| 304 |
+
|
| 305 |
+
if (!text && !file) {
|
| 306 |
+
alert("Please enter text or upload a file.");
|
| 307 |
return;
|
| 308 |
}
|
| 309 |
+
|
| 310 |
+
const formData = new FormData();
|
| 311 |
+
if (file) formData.append('file', file);
|
| 312 |
+
if (text) formData.append('text', text);
|
| 313 |
+
formData.append('target_language', language);
|
| 314 |
+
|
| 315 |
try {
|
| 316 |
+
const response = await fetch('/translate', {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
method: 'POST',
|
| 318 |
body: formData
|
| 319 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
const data = await response.json();
|
| 321 |
+
document.getElementById('translateResult').innerText = `Translated Text: ${data.translated_text}`;
|
|
|
|
| 322 |
} catch (error) {
|
| 323 |
console.error('Error:', error);
|
| 324 |
+
document.getElementById('translateResult').innerText = 'Failed to translate. Please try again.';
|
| 325 |
}
|
| 326 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
</script>
|
| 328 |
</body>
|
| 329 |
</html>
|