Add 2 files
Browse files- index.html +704 -151
- prompts.txt +2 -1
index.html
CHANGED
@@ -7,26 +7,53 @@
|
|
7 |
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
|
9 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
|
10 |
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
11 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
body {
|
13 |
font-family: 'Inter', sans-serif;
|
14 |
-
background: linear-gradient(135deg, #
|
15 |
min-height: 100vh;
|
16 |
}
|
17 |
|
|
|
|
|
|
|
|
|
18 |
.tab-button {
|
19 |
transition: all 0.3s ease;
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
.tab-button
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
|
27 |
.result-box {
|
28 |
transition: all 0.3s ease;
|
29 |
min-height: 200px;
|
|
|
30 |
}
|
31 |
|
32 |
.loading-dots {
|
@@ -38,7 +65,7 @@
|
|
38 |
width: 8px;
|
39 |
height: 8px;
|
40 |
border-radius: 50%;
|
41 |
-
background-color:
|
42 |
margin: 0 2px;
|
43 |
animation: bounce 1.4s infinite ease-in-out both;
|
44 |
}
|
@@ -54,18 +81,20 @@
|
|
54 |
@keyframes bounce {
|
55 |
0%, 80%, 100% {
|
56 |
transform: scale(0);
|
57 |
-
}
|
|
|
58 |
transform: scale(1);
|
59 |
}
|
60 |
}
|
61 |
|
62 |
.file-input-label {
|
63 |
transition: all 0.3s ease;
|
|
|
64 |
}
|
65 |
|
66 |
.file-input-label:hover {
|
67 |
transform: translateY(-2px);
|
68 |
-
box-shadow: 0 4px 6px -1px rgba(
|
69 |
}
|
70 |
|
71 |
.glow {
|
@@ -74,103 +103,308 @@
|
|
74 |
|
75 |
@keyframes glow {
|
76 |
from {
|
77 |
-
box-shadow: 0 0 5px rgba(
|
78 |
}
|
79 |
to {
|
80 |
-
box-shadow: 0 0 20px rgba(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
</style>
|
84 |
</head>
|
85 |
-
<body class="
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
<!-- Header -->
|
88 |
-
<div class="text-center mb-
|
89 |
-
<
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
</div>
|
92 |
|
93 |
<!-- API Key Input -->
|
94 |
-
<div class="bg-white rounded-xl
|
95 |
-
<
|
96 |
-
<div class="
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
>
|
103 |
-
<
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
</div>
|
110 |
-
<p class="mt-2 text-sm text-gray-500">Your API key is only used for requests and is not stored.</p>
|
111 |
</div>
|
112 |
|
113 |
-
<!-- Tabs -->
|
114 |
-
<div class="flex space-x-2 mb-
|
115 |
<button
|
116 |
id="pdf-tab"
|
117 |
onclick="switchTab('pdf')"
|
118 |
-
class="tab-button active px-
|
119 |
>
|
|
|
120 |
PDF Analysis
|
121 |
</button>
|
122 |
<button
|
123 |
id="image-tab"
|
124 |
onclick="switchTab('image')"
|
125 |
-
class="tab-button px-
|
126 |
>
|
|
|
127 |
Image Analysis
|
128 |
</button>
|
129 |
</div>
|
130 |
|
131 |
<!-- PDF Analysis Tab -->
|
132 |
<div id="pdf-content" class="animate__animated animate__fadeIn">
|
133 |
-
<div class="bg-white rounded-xl
|
134 |
-
<div class="p-
|
135 |
-
<h2 class="text-2xl font-semibold text-gray-800 mb-
|
|
|
|
|
|
|
136 |
|
137 |
-
<div class="mb-
|
138 |
-
<label class="block text-sm font-medium text-gray-700 mb-
|
139 |
-
<
|
140 |
-
<
|
141 |
-
<
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
</
|
147 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
</div>
|
149 |
|
150 |
-
<div class="mb-
|
151 |
-
<label for="pdf-prompt" class="block text-sm font-medium text-gray-700 mb-
|
152 |
<textarea
|
153 |
id="pdf-prompt"
|
154 |
-
rows="
|
155 |
-
class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
|
156 |
-
placeholder="
|
157 |
>What is this PDF about?</textarea>
|
158 |
</div>
|
159 |
|
160 |
-
<div class="mb-
|
161 |
-
<label class="block text-sm font-medium text-gray-700 mb-
|
162 |
-
<div class="
|
163 |
-
<label class="inline-flex items-center">
|
164 |
-
<input type="radio" name="pdf-effort" value="low" class="h-
|
165 |
-
<
|
|
|
|
|
|
|
166 |
</label>
|
167 |
-
<label class="inline-flex items-center">
|
168 |
-
<input type="radio" name="pdf-effort" value="medium" checked class="h-
|
169 |
-
<
|
|
|
|
|
|
|
170 |
</label>
|
171 |
-
<label class="inline-flex items-center">
|
172 |
-
<input type="radio" name="pdf-effort" value="high" class="h-
|
173 |
-
<
|
|
|
|
|
|
|
174 |
</label>
|
175 |
</div>
|
176 |
</div>
|
@@ -178,110 +412,263 @@
|
|
178 |
<button
|
179 |
id="analyze-pdf-btn"
|
180 |
onclick="analyzePDF()"
|
181 |
-
class="w-full py-
|
182 |
>
|
|
|
183 |
Analyze PDF
|
184 |
</button>
|
185 |
</div>
|
186 |
|
187 |
-
<div id="pdf-result" class="result-box border-t border-gray-200 p-
|
188 |
-
<
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
</div>
|
191 |
</div>
|
192 |
</div>
|
193 |
|
194 |
<!-- Image Analysis Tab -->
|
195 |
<div id="image-content" class="hidden animate__animated animate__fadeIn">
|
196 |
-
<div class="bg-white rounded-xl
|
197 |
-
<div class="p-
|
198 |
-
<h2 class="text-2xl font-semibold text-gray-800 mb-
|
|
|
|
|
|
|
199 |
|
200 |
-
<div class="
|
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 |
</div>
|
234 |
|
235 |
-
<div
|
236 |
-
<
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
<
|
245 |
-
</
|
246 |
-
<
|
247 |
-
<
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
</div>
|
251 |
</div>
|
252 |
</div>
|
253 |
</div>
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
<button
|
256 |
id="analyze-image-btn"
|
257 |
onclick="analyzeImage()"
|
258 |
-
class="w-full py-
|
259 |
>
|
|
|
260 |
Analyze Image
|
261 |
</button>
|
262 |
</div>
|
263 |
|
264 |
-
<div id="image-result" class="result-box border-t border-gray-200 p-
|
265 |
-
<
|
266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
</div>
|
268 |
</div>
|
269 |
</div>
|
270 |
|
271 |
-
<!--
|
272 |
-
<div class="mt-
|
273 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
</div>
|
275 |
</div>
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
<script>
|
278 |
// Toggle API key visibility
|
279 |
function toggleApiKeyVisibility() {
|
280 |
const apiKeyInput = document.getElementById('api-key');
|
|
|
|
|
281 |
if (apiKeyInput.type === 'password') {
|
282 |
apiKeyInput.type = 'text';
|
|
|
283 |
} else {
|
284 |
apiKeyInput.type = 'password';
|
|
|
285 |
}
|
286 |
}
|
287 |
|
@@ -293,10 +680,10 @@
|
|
293 |
const imageContent = document.getElementById('image-content');
|
294 |
|
295 |
if (tab === 'pdf') {
|
296 |
-
pdfTab.classList.remove('bg-gray-
|
297 |
-
pdfTab.classList.add('bg-indigo-600', '
|
298 |
-
imageTab.classList.remove('bg-indigo-600', '
|
299 |
-
imageTab.classList.add('bg-gray-
|
300 |
|
301 |
pdfContent.classList.remove('hidden');
|
302 |
imageContent.classList.add('hidden');
|
@@ -306,10 +693,10 @@
|
|
306 |
void pdfContent.offsetWidth; // Trigger reflow
|
307 |
pdfContent.classList.add('animate__fadeIn');
|
308 |
} else {
|
309 |
-
imageTab.classList.remove('bg-gray-
|
310 |
-
imageTab.classList.add('bg-indigo-600', '
|
311 |
-
pdfTab.classList.remove('bg-indigo-600', '
|
312 |
-
pdfTab.classList.add('bg-gray-
|
313 |
|
314 |
imageContent.classList.remove('hidden');
|
315 |
pdfContent.classList.add('hidden');
|
@@ -321,32 +708,161 @@
|
|
321 |
}
|
322 |
}
|
323 |
|
324 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
document.getElementById('pdf-upload').addEventListener('change', function(e) {
|
|
|
|
|
326 |
const filenameDisplay = document.getElementById('pdf-filename');
|
|
|
|
|
327 |
if (this.files.length > 0) {
|
328 |
-
|
329 |
-
filenameDisplay.
|
|
|
|
|
|
|
|
|
330 |
} else {
|
331 |
-
|
|
|
332 |
}
|
333 |
});
|
334 |
|
|
|
335 |
document.getElementById('image-upload').addEventListener('change', function(e) {
|
336 |
-
const
|
|
|
|
|
|
|
337 |
if (this.files.length > 0) {
|
338 |
-
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
} else {
|
341 |
-
|
|
|
342 |
}
|
343 |
});
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
// Show loading state
|
346 |
function showLoading(element) {
|
347 |
-
element.innerHTML =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
}
|
349 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
// Analyze PDF function
|
351 |
async function analyzePDF() {
|
352 |
const apiKey = document.getElementById('api-key').value;
|
@@ -357,12 +873,12 @@
|
|
357 |
const resultBox = document.getElementById('pdf-result');
|
358 |
|
359 |
if (!apiKey) {
|
360 |
-
|
361 |
return;
|
362 |
}
|
363 |
|
364 |
if (!pdfFile) {
|
365 |
-
|
366 |
return;
|
367 |
}
|
368 |
|
@@ -454,17 +970,17 @@
|
|
454 |
const resultBox = document.getElementById('image-result');
|
455 |
|
456 |
if (!apiKey) {
|
457 |
-
|
458 |
return;
|
459 |
}
|
460 |
|
461 |
if (!imageFile && !imageUrl) {
|
462 |
-
|
463 |
return;
|
464 |
}
|
465 |
|
466 |
if (!prompt) {
|
467 |
-
|
468 |
return;
|
469 |
}
|
470 |
|
@@ -576,9 +1092,36 @@
|
|
576 |
}
|
577 |
}
|
578 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
579 |
// Add glow effect to buttons on hover
|
580 |
document.querySelectorAll('button').forEach(button => {
|
581 |
-
if (button.id !== 'api-key-toggle') {
|
582 |
button.addEventListener('mouseenter', () => {
|
583 |
button.classList.add('glow');
|
584 |
});
|
@@ -587,6 +1130,16 @@
|
|
587 |
});
|
588 |
}
|
589 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
590 |
</script>
|
591 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=shukdevdatta123/openai-o4-mini-multi-modal-chat-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
592 |
</html>
|
|
|
7 |
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
|
9 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
10 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
11 |
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
12 |
<style>
|
13 |
+
:root {
|
14 |
+
--primary: #6366f1;
|
15 |
+
--primary-dark: #4f46e5;
|
16 |
+
--primary-light: #818cf8;
|
17 |
+
}
|
18 |
+
|
19 |
body {
|
20 |
font-family: 'Inter', sans-serif;
|
21 |
+
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
|
22 |
min-height: 100vh;
|
23 |
}
|
24 |
|
25 |
+
.gradient-bg {
|
26 |
+
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
27 |
+
}
|
28 |
+
|
29 |
.tab-button {
|
30 |
transition: all 0.3s ease;
|
31 |
+
position: relative;
|
32 |
+
overflow: hidden;
|
33 |
}
|
34 |
|
35 |
+
.tab-button::after {
|
36 |
+
content: '';
|
37 |
+
position: absolute;
|
38 |
+
bottom: 0;
|
39 |
+
left: 0;
|
40 |
+
width: 100%;
|
41 |
+
height: 3px;
|
42 |
+
background: white;
|
43 |
+
transform: scaleX(0);
|
44 |
+
transform-origin: right;
|
45 |
+
transition: transform 0.3s ease;
|
46 |
+
}
|
47 |
+
|
48 |
+
.tab-button.active::after {
|
49 |
+
transform: scaleX(1);
|
50 |
+
transform-origin: left;
|
51 |
}
|
52 |
|
53 |
.result-box {
|
54 |
transition: all 0.3s ease;
|
55 |
min-height: 200px;
|
56 |
+
background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
|
57 |
}
|
58 |
|
59 |
.loading-dots {
|
|
|
65 |
width: 8px;
|
66 |
height: 8px;
|
67 |
border-radius: 50%;
|
68 |
+
background-color: var(--primary);
|
69 |
margin: 0 2px;
|
70 |
animation: bounce 1.4s infinite ease-in-out both;
|
71 |
}
|
|
|
81 |
@keyframes bounce {
|
82 |
0%, 80%, 100% {
|
83 |
transform: scale(0);
|
84 |
+
}
|
85 |
+
40% {
|
86 |
transform: scale(1);
|
87 |
}
|
88 |
}
|
89 |
|
90 |
.file-input-label {
|
91 |
transition: all 0.3s ease;
|
92 |
+
position: relative;
|
93 |
}
|
94 |
|
95 |
.file-input-label:hover {
|
96 |
transform: translateY(-2px);
|
97 |
+
box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3), 0 2px 4px -1px rgba(99, 102, 241, 0.06);
|
98 |
}
|
99 |
|
100 |
.glow {
|
|
|
103 |
|
104 |
@keyframes glow {
|
105 |
from {
|
106 |
+
box-shadow: 0 0 5px rgba(99, 102, 241, 0.5);
|
107 |
}
|
108 |
to {
|
109 |
+
box-shadow: 0 0 20px rgba(99, 102, 241, 0.8);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
.card {
|
114 |
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
|
115 |
+
transition: all 0.3s ease;
|
116 |
+
}
|
117 |
+
|
118 |
+
.card:hover {
|
119 |
+
transform: translateY(-5px);
|
120 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
121 |
+
}
|
122 |
+
|
123 |
+
.btn-primary {
|
124 |
+
background: var(--primary);
|
125 |
+
transition: all 0.3s ease;
|
126 |
+
}
|
127 |
+
|
128 |
+
.btn-primary:hover {
|
129 |
+
background: var(--primary-dark);
|
130 |
+
transform: translateY(-2px);
|
131 |
+
}
|
132 |
+
|
133 |
+
.btn-secondary {
|
134 |
+
background: #f1f5f9;
|
135 |
+
transition: all 0.3s ease;
|
136 |
+
}
|
137 |
+
|
138 |
+
.btn-secondary:hover {
|
139 |
+
background: #e2e8f0;
|
140 |
+
transform: translateY(-2px);
|
141 |
+
}
|
142 |
+
|
143 |
+
.input-field {
|
144 |
+
transition: all 0.3s ease;
|
145 |
+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
|
146 |
+
}
|
147 |
+
|
148 |
+
.input-field:focus {
|
149 |
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
|
150 |
+
}
|
151 |
+
|
152 |
+
.preview-container {
|
153 |
+
position: relative;
|
154 |
+
border-radius: 0.5rem;
|
155 |
+
overflow: hidden;
|
156 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
157 |
+
}
|
158 |
+
|
159 |
+
.remove-btn {
|
160 |
+
position: absolute;
|
161 |
+
top: 0.5rem;
|
162 |
+
right: 0.5rem;
|
163 |
+
background: rgba(0, 0, 0, 0.6);
|
164 |
+
color: white;
|
165 |
+
border-radius: 50%;
|
166 |
+
width: 2rem;
|
167 |
+
height: 2rem;
|
168 |
+
display: flex;
|
169 |
+
align-items: center;
|
170 |
+
justify-content: center;
|
171 |
+
cursor: pointer;
|
172 |
+
transition: all 0.3s ease;
|
173 |
+
}
|
174 |
+
|
175 |
+
.remove-btn:hover {
|
176 |
+
background: rgba(239, 68, 68, 0.8);
|
177 |
+
transform: scale(1.1);
|
178 |
+
}
|
179 |
+
|
180 |
+
.pulse {
|
181 |
+
animation: pulse 2s infinite;
|
182 |
+
}
|
183 |
+
|
184 |
+
@keyframes pulse {
|
185 |
+
0% {
|
186 |
+
transform: scale(1);
|
187 |
+
}
|
188 |
+
50% {
|
189 |
+
transform: scale(1.05);
|
190 |
+
}
|
191 |
+
100% {
|
192 |
+
transform: scale(1);
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
.floating {
|
197 |
+
animation: floating 6s ease-in-out infinite;
|
198 |
+
}
|
199 |
+
|
200 |
+
@keyframes floating {
|
201 |
+
0% {
|
202 |
+
transform: translateY(0px);
|
203 |
+
}
|
204 |
+
50% {
|
205 |
+
transform: translateY(-10px);
|
206 |
+
}
|
207 |
+
100% {
|
208 |
+
transform: translateY(0px);
|
209 |
}
|
210 |
}
|
211 |
+
|
212 |
+
.wave {
|
213 |
+
position: absolute;
|
214 |
+
bottom: 0;
|
215 |
+
left: 0;
|
216 |
+
width: 100%;
|
217 |
+
overflow: hidden;
|
218 |
+
line-height: 0;
|
219 |
+
}
|
220 |
+
|
221 |
+
.wave svg {
|
222 |
+
position: relative;
|
223 |
+
display: block;
|
224 |
+
width: calc(100% + 1.3px);
|
225 |
+
height: 150px;
|
226 |
+
}
|
227 |
+
|
228 |
+
.wave .shape-fill {
|
229 |
+
fill: #FFFFFF;
|
230 |
+
}
|
231 |
+
|
232 |
+
.feature-icon {
|
233 |
+
width: 60px;
|
234 |
+
height: 60px;
|
235 |
+
border-radius: 50%;
|
236 |
+
background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(99, 102, 241, 0.2) 100%);
|
237 |
+
display: flex;
|
238 |
+
align-items: center;
|
239 |
+
justify-content: center;
|
240 |
+
margin-bottom: 1rem;
|
241 |
+
}
|
242 |
</style>
|
243 |
</head>
|
244 |
+
<body class="antialiased">
|
245 |
+
<!-- Wave Background -->
|
246 |
+
<div class="fixed top-0 left-0 w-full h-full -z-10 opacity-10">
|
247 |
+
<div class="absolute top-0 left-0 w-full h-full bg-gradient-to-br from-indigo-100 to-purple-100"></div>
|
248 |
+
</div>
|
249 |
+
|
250 |
+
<!-- Main Container -->
|
251 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
252 |
<!-- Header -->
|
253 |
+
<div class="text-center mb-16 animate__animated animate__fadeIn">
|
254 |
+
<div class="inline-flex items-center justify-center mb-4 px-6 py-2 rounded-full bg-indigo-50 text-indigo-600">
|
255 |
+
<i class="fas fa-bolt mr-2"></i>
|
256 |
+
<span class="font-medium">AI-Powered Analysis</span>
|
257 |
+
</div>
|
258 |
+
<h1 class="text-5xl font-bold text-gray-900 mb-4">OpenAI O4 Mini <span class="text-indigo-600">Analysis</span></h1>
|
259 |
+
<p class="text-xl text-gray-600 max-w-2xl mx-auto">Unlock insights from your documents and images with cutting-edge AI technology</p>
|
260 |
+
</div>
|
261 |
+
|
262 |
+
<!-- Features Section -->
|
263 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-16">
|
264 |
+
<div class="bg-white rounded-xl card p-6 text-center">
|
265 |
+
<div class="feature-icon mx-auto">
|
266 |
+
<i class="fas fa-file-pdf text-indigo-600 text-2xl"></i>
|
267 |
+
</div>
|
268 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">PDF Analysis</h3>
|
269 |
+
<p class="text-gray-600">Extract key information and insights from your PDF documents with AI-powered analysis.</p>
|
270 |
+
</div>
|
271 |
+
|
272 |
+
<div class="bg-white rounded-xl card p-6 text-center">
|
273 |
+
<div class="feature-icon mx-auto">
|
274 |
+
<i class="fas fa-image text-indigo-600 text-2xl"></i>
|
275 |
+
</div>
|
276 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">Image Analysis</h3>
|
277 |
+
<p class="text-gray-600">Understand visual content with advanced image recognition and description capabilities.</p>
|
278 |
+
</div>
|
279 |
+
|
280 |
+
<div class="bg-white rounded-xl card p-6 text-center">
|
281 |
+
<div class="feature-icon mx-auto">
|
282 |
+
<i class="fas fa-brain text-indigo-600 text-2xl"></i>
|
283 |
+
</div>
|
284 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">Smart Insights</h3>
|
285 |
+
<p class="text-gray-600">Get comprehensive answers to your questions with adjustable reasoning levels.</p>
|
286 |
+
</div>
|
287 |
</div>
|
288 |
|
289 |
<!-- API Key Input -->
|
290 |
+
<div class="bg-white rounded-xl card p-8 mb-12 animate__animated animate__fadeInUp relative overflow-hidden">
|
291 |
+
<div class="absolute -top-10 -right-10 w-32 h-32 rounded-full bg-indigo-100 opacity-50"></div>
|
292 |
+
<div class="absolute -bottom-10 -left-10 w-32 h-32 rounded-full bg-purple-100 opacity-50"></div>
|
293 |
+
|
294 |
+
<div class="relative z-10">
|
295 |
+
<label for="api-key" class="block text-sm font-medium text-gray-700 mb-2 flex items-center">
|
296 |
+
<i class="fas fa-key mr-2 text-indigo-600"></i>
|
297 |
+
OpenAI API Key
|
298 |
+
</label>
|
299 |
+
<div class="relative">
|
300 |
+
<input
|
301 |
+
type="password"
|
302 |
+
id="api-key"
|
303 |
+
placeholder="Enter your OpenAI API key here..."
|
304 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
|
305 |
+
>
|
306 |
+
<button
|
307 |
+
onclick="toggleApiKeyVisibility()"
|
308 |
+
class="absolute right-3 top-3 text-gray-500 hover:text-indigo-600 focus:outline-none"
|
309 |
+
>
|
310 |
+
<i class="far fa-eye"></i>
|
311 |
+
</button>
|
312 |
+
</div>
|
313 |
+
<p class="mt-2 text-sm text-gray-500">
|
314 |
+
<i class="fas fa-info-circle mr-1 text-indigo-500"></i>
|
315 |
+
Your API key is only used for requests and is not stored.
|
316 |
+
</p>
|
317 |
</div>
|
|
|
318 |
</div>
|
319 |
|
320 |
+
<!-- Tabs Navigation -->
|
321 |
+
<div class="flex space-x-2 mb-8 animate__animated animate__fadeIn">
|
322 |
<button
|
323 |
id="pdf-tab"
|
324 |
onclick="switchTab('pdf')"
|
325 |
+
class="tab-button active px-8 py-4 rounded-t-lg font-medium bg-white text-indigo-600 border-b-2 border-indigo-600"
|
326 |
>
|
327 |
+
<i class="fas fa-file-pdf mr-2"></i>
|
328 |
PDF Analysis
|
329 |
</button>
|
330 |
<button
|
331 |
id="image-tab"
|
332 |
onclick="switchTab('image')"
|
333 |
+
class="tab-button px-8 py-4 rounded-t-lg font-medium bg-white text-gray-600 hover:text-indigo-600 border-b-2 border-transparent hover:border-gray-300"
|
334 |
>
|
335 |
+
<i class="fas fa-image mr-2"></i>
|
336 |
Image Analysis
|
337 |
</button>
|
338 |
</div>
|
339 |
|
340 |
<!-- PDF Analysis Tab -->
|
341 |
<div id="pdf-content" class="animate__animated animate__fadeIn">
|
342 |
+
<div class="bg-white rounded-b-xl rounded-tr-xl card overflow-hidden">
|
343 |
+
<div class="p-8">
|
344 |
+
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
|
345 |
+
<i class="fas fa-file-pdf mr-3 text-indigo-600"></i>
|
346 |
+
PDF Document Analysis
|
347 |
+
</h2>
|
348 |
|
349 |
+
<div class="mb-8">
|
350 |
+
<label class="block text-sm font-medium text-gray-700 mb-3">Upload PDF</label>
|
351 |
+
<div id="pdf-upload-container">
|
352 |
+
<label for="pdf-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200">
|
353 |
+
<i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
|
354 |
+
<span class="text-sm font-medium text-gray-600">Drag & drop your PDF here or click to browse</span>
|
355 |
+
<span class="text-xs text-gray-500 mt-1">Supports .pdf files up to 10MB</span>
|
356 |
+
<input id="pdf-upload" type="file" accept=".pdf" class="hidden">
|
357 |
+
</label>
|
358 |
+
</div>
|
359 |
+
<div id="pdf-preview-container" class="hidden mt-4">
|
360 |
+
<div class="preview-container p-4 bg-gray-50 rounded-lg">
|
361 |
+
<div class="flex items-center">
|
362 |
+
<i class="fas fa-file-pdf text-3xl text-red-500 mr-3"></i>
|
363 |
+
<div>
|
364 |
+
<p id="pdf-filename" class="font-medium text-gray-800"></p>
|
365 |
+
<p id="pdf-filesize" class="text-sm text-gray-500"></p>
|
366 |
+
</div>
|
367 |
+
<button id="remove-pdf" class="ml-auto remove-btn">
|
368 |
+
<i class="fas fa-times"></i>
|
369 |
+
</button>
|
370 |
+
</div>
|
371 |
+
</div>
|
372 |
+
</div>
|
373 |
</div>
|
374 |
|
375 |
+
<div class="mb-8">
|
376 |
+
<label for="pdf-prompt" class="block text-sm font-medium text-gray-700 mb-3">Analysis Prompt</label>
|
377 |
<textarea
|
378 |
id="pdf-prompt"
|
379 |
+
rows="4"
|
380 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
|
381 |
+
placeholder="What would you like to know about this PDF? (e.g., 'Summarize this document', 'What are the key points?', 'Extract the main ideas')"
|
382 |
>What is this PDF about?</textarea>
|
383 |
</div>
|
384 |
|
385 |
+
<div class="mb-8">
|
386 |
+
<label class="block text-sm font-medium text-gray-700 mb-3">Reasoning Effort Level</label>
|
387 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
388 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
389 |
+
<input type="radio" name="pdf-effort" value="low" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
390 |
+
<div class="ml-3">
|
391 |
+
<span class="block text-sm font-medium text-gray-700">Quick Scan</span>
|
392 |
+
<span class="block text-xs text-gray-500">Basic analysis, faster results</span>
|
393 |
+
</div>
|
394 |
</label>
|
395 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
396 |
+
<input type="radio" name="pdf-effort" value="medium" checked class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
397 |
+
<div class="ml-3">
|
398 |
+
<span class="block text-sm font-medium text-gray-700">Standard</span>
|
399 |
+
<span class="block text-xs text-gray-500">Balanced speed and depth</span>
|
400 |
+
</div>
|
401 |
</label>
|
402 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
403 |
+
<input type="radio" name="pdf-effort" value="high" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
404 |
+
<div class="ml-3">
|
405 |
+
<span class="block text-sm font-medium text-gray-700">Deep Dive</span>
|
406 |
+
<span class="block text-xs text-gray-500">Comprehensive, detailed analysis</span>
|
407 |
+
</div>
|
408 |
</label>
|
409 |
</div>
|
410 |
</div>
|
|
|
412 |
<button
|
413 |
id="analyze-pdf-btn"
|
414 |
onclick="analyzePDF()"
|
415 |
+
class="w-full py-4 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-[1.02] focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 flex items-center justify-center"
|
416 |
>
|
417 |
+
<i class="fas fa-magic mr-2"></i>
|
418 |
Analyze PDF
|
419 |
</button>
|
420 |
</div>
|
421 |
|
422 |
+
<div id="pdf-result" class="result-box border-t border-gray-200 p-8 hidden">
|
423 |
+
<div class="flex items-center justify-between mb-6">
|
424 |
+
<h3 class="text-xl font-semibold text-gray-800 flex items-center">
|
425 |
+
<i class="fas fa-chart-line mr-2 text-indigo-600"></i>
|
426 |
+
Analysis Results
|
427 |
+
</h3>
|
428 |
+
<button id="copy-pdf-result" class="text-sm text-indigo-600 hover:text-indigo-800 flex items-center">
|
429 |
+
<i class="far fa-copy mr-1"></i> Copy
|
430 |
+
</button>
|
431 |
+
</div>
|
432 |
+
<div id="pdf-result-content" class="min-h-40 p-6 bg-white rounded-lg border border-gray-200 shadow-sm"></div>
|
433 |
</div>
|
434 |
</div>
|
435 |
</div>
|
436 |
|
437 |
<!-- Image Analysis Tab -->
|
438 |
<div id="image-content" class="hidden animate__animated animate__fadeIn">
|
439 |
+
<div class="bg-white rounded-b-xl rounded-tr-xl card overflow-hidden">
|
440 |
+
<div class="p-8">
|
441 |
+
<h2 class="text-2xl font-semibold text-gray-800 mb-6 flex items-center">
|
442 |
+
<i class="fas fa-image mr-3 text-indigo-600"></i>
|
443 |
+
Image Analysis
|
444 |
+
</h2>
|
445 |
|
446 |
+
<div class="mb-8">
|
447 |
+
<label class="block text-sm font-medium text-gray-700 mb-3">Image Source</label>
|
448 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
449 |
+
<div>
|
450 |
+
<div class="flex items-center space-x-4 mb-4">
|
451 |
+
<div class="flex-1 border-b-2 border-indigo-600 pb-2">
|
452 |
+
<h4 class="font-medium text-indigo-600 flex items-center">
|
453 |
+
<i class="fas fa-upload mr-2"></i>
|
454 |
+
Upload Image
|
455 |
+
</h4>
|
456 |
+
</div>
|
457 |
+
<div class="flex-1 text-center text-gray-400 pb-2">
|
458 |
+
<h4 class="font-medium">or</h4>
|
459 |
+
</div>
|
460 |
+
<div class="flex-1 border-b-2 border-gray-200 pb-2">
|
461 |
+
<h4 class="font-medium text-gray-600 hover:text-indigo-600 cursor-pointer flex items-center justify-end" onclick="switchImageSource('url')">
|
462 |
+
<i class="fas fa-link mr-2"></i>
|
463 |
+
Use URL
|
464 |
+
</h4>
|
465 |
+
</div>
|
466 |
+
</div>
|
467 |
+
|
468 |
+
<div id="image-upload-container">
|
469 |
+
<label for="image-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200">
|
470 |
+
<i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
|
471 |
+
<span class="text-sm font-medium text-gray-600">Drag & drop your image here or click to browse</span>
|
472 |
+
<span class="text-xs text-gray-500 mt-1">Supports JPG, PNG, GIF up to 5MB</span>
|
473 |
+
<input id="image-upload" type="file" accept="image/*" class="hidden">
|
474 |
+
</label>
|
475 |
+
</div>
|
476 |
+
|
477 |
+
<div id="image-preview-container" class="hidden mt-4">
|
478 |
+
<div class="preview-container">
|
479 |
+
<img id="image-preview" src="" alt="Preview" class="w-full h-auto rounded-lg">
|
480 |
+
<button id="remove-image" class="remove-btn">
|
481 |
+
<i class="fas fa-times"></i>
|
482 |
+
</button>
|
483 |
+
</div>
|
484 |
+
</div>
|
485 |
</div>
|
486 |
|
487 |
+
<div id="image-url-container" class="hidden">
|
488 |
+
<div class="flex items-center space-x-4 mb-4">
|
489 |
+
<div class="flex-1 border-b-2 border-gray-200 pb-2">
|
490 |
+
<h4 class="font-medium text-gray-600 hover:text-indigo-600 cursor-pointer flex items-center" onclick="switchImageSource('upload')">
|
491 |
+
<i class="fas fa-upload mr-2"></i>
|
492 |
+
Upload Image
|
493 |
+
</h4>
|
494 |
+
</div>
|
495 |
+
<div class="flex-1 text-center text-gray-400 pb-2">
|
496 |
+
<h4 class="font-medium">or</h4>
|
497 |
+
</div>
|
498 |
+
<div class="flex-1 border-b-2 border-indigo-600 pb-2">
|
499 |
+
<h4 class="font-medium text-indigo-600 flex items-center justify-end">
|
500 |
+
<i class="fas fa-link mr-2"></i>
|
501 |
+
Use URL
|
502 |
+
</h4>
|
503 |
+
</div>
|
504 |
+
</div>
|
505 |
+
|
506 |
+
<div class="mb-4">
|
507 |
+
<label for="image-url" class="block text-sm font-medium text-gray-700 mb-2">Image URL</label>
|
508 |
+
<input
|
509 |
+
type="text"
|
510 |
+
id="image-url"
|
511 |
+
placeholder="https://example.com/image.jpg"
|
512 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
|
513 |
+
>
|
514 |
+
</div>
|
515 |
+
|
516 |
+
<div id="url-preview-container" class="hidden mt-4">
|
517 |
+
<div class="preview-container">
|
518 |
+
<img id="url-preview" src="" alt="Preview" class="w-full h-auto rounded-lg">
|
519 |
+
<button id="remove-url" class="remove-btn">
|
520 |
+
<i class="fas fa-times"></i>
|
521 |
+
</button>
|
522 |
+
</div>
|
523 |
</div>
|
524 |
</div>
|
525 |
</div>
|
526 |
</div>
|
527 |
|
528 |
+
<div class="mb-8">
|
529 |
+
<label for="image-prompt" class="block text-sm font-medium text-gray-700 mb-3">Analysis Prompt</label>
|
530 |
+
<textarea
|
531 |
+
id="image-prompt"
|
532 |
+
rows="4"
|
533 |
+
class="w-full px-4 py-3 rounded-lg border border-gray-300 input-field focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200"
|
534 |
+
placeholder="What would you like to know about this image? (e.g., 'Describe this image', 'What objects are visible?', 'What is the main subject?')"
|
535 |
+
>What is this image about?</textarea>
|
536 |
+
</div>
|
537 |
+
|
538 |
+
<div class="mb-8">
|
539 |
+
<label class="block text-sm font-medium text-gray-700 mb-3">Reasoning Effort Level</label>
|
540 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
541 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
542 |
+
<input type="radio" name="image-effort" value="low" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
543 |
+
<div class="ml-3">
|
544 |
+
<span class="block text-sm font-medium text-gray-700">Quick Scan</span>
|
545 |
+
<span class="block text-xs text-gray-500">Basic analysis, faster results</span>
|
546 |
+
</div>
|
547 |
+
</label>
|
548 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
549 |
+
<input type="radio" name="image-effort" value="medium" checked class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
550 |
+
<div class="ml-3">
|
551 |
+
<span class="block text-sm font-medium text-gray-700">Standard</span>
|
552 |
+
<span class="block text-xs text-gray-500">Balanced speed and depth</span>
|
553 |
+
</div>
|
554 |
+
</label>
|
555 |
+
<label class="inline-flex items-center bg-gray-50 hover:bg-gray-100 rounded-lg p-4 cursor-pointer transition duration-200">
|
556 |
+
<input type="radio" name="image-effort" value="high" class="h-5 w-5 text-indigo-600 focus:ring-indigo-500">
|
557 |
+
<div class="ml-3">
|
558 |
+
<span class="block text-sm font-medium text-gray-700">Deep Dive</span>
|
559 |
+
<span class="block text-xs text-gray-500">Comprehensive, detailed analysis</span>
|
560 |
+
</div>
|
561 |
+
</label>
|
562 |
+
</div>
|
563 |
+
</div>
|
564 |
+
|
565 |
<button
|
566 |
id="analyze-image-btn"
|
567 |
onclick="analyzeImage()"
|
568 |
+
class="w-full py-4 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-[1.02] focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 flex items-center justify-center"
|
569 |
>
|
570 |
+
<i class="fas fa-magic mr-2"></i>
|
571 |
Analyze Image
|
572 |
</button>
|
573 |
</div>
|
574 |
|
575 |
+
<div id="image-result" class="result-box border-t border-gray-200 p-8 hidden">
|
576 |
+
<div class="flex items-center justify-between mb-6">
|
577 |
+
<h3 class="text-xl font-semibold text-gray-800 flex items-center">
|
578 |
+
<i class="fas fa-chart-line mr-2 text-indigo-600"></i>
|
579 |
+
Analysis Results
|
580 |
+
</h3>
|
581 |
+
<button id="copy-image-result" class="text-sm text-indigo-600 hover:text-indigo-800 flex items-center">
|
582 |
+
<i class="far fa-copy mr-1"></i> Copy
|
583 |
+
</button>
|
584 |
+
</div>
|
585 |
+
<div id="image-result-content" class="min-h-40 p-6 bg-white rounded-lg border border-gray-200 shadow-sm"></div>
|
586 |
</div>
|
587 |
</div>
|
588 |
</div>
|
589 |
|
590 |
+
<!-- How It Works Section -->
|
591 |
+
<div class="mt-20 bg-white rounded-xl card p-8 relative overflow-hidden">
|
592 |
+
<div class="absolute -top-20 -right-20 w-64 h-64 rounded-full bg-indigo-100 opacity-30"></div>
|
593 |
+
<div class="absolute -bottom-20 -left-20 w-64 h-64 rounded-full bg-purple-100 opacity-30"></div>
|
594 |
+
|
595 |
+
<div class="relative z-10">
|
596 |
+
<h2 class="text-3xl font-bold text-center text-gray-900 mb-12">
|
597 |
+
<span class="text-indigo-600">How It Works</span>
|
598 |
+
</h2>
|
599 |
+
|
600 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
601 |
+
<div class="flex flex-col items-center text-center">
|
602 |
+
<div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
|
603 |
+
1
|
604 |
+
</div>
|
605 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">Upload Your File</h3>
|
606 |
+
<p class="text-gray-600">Select a PDF document or image you want to analyze by uploading from your device or providing a URL.</p>
|
607 |
+
</div>
|
608 |
+
|
609 |
+
<div class="flex flex-col items-center text-center">
|
610 |
+
<div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
|
611 |
+
2
|
612 |
+
</div>
|
613 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">Set Your Preferences</h3>
|
614 |
+
<p class="text-gray-600">Enter your analysis prompt and choose the reasoning effort level that suits your needs.</p>
|
615 |
+
</div>
|
616 |
+
|
617 |
+
<div class="flex flex-col items-center text-center">
|
618 |
+
<div class="w-16 h-16 rounded-full bg-indigo-100 text-indigo-600 flex items-center justify-center mb-4 text-2xl">
|
619 |
+
3
|
620 |
+
</div>
|
621 |
+
<h3 class="text-xl font-semibold text-gray-800 mb-2">Get AI Insights</h3>
|
622 |
+
<p class="text-gray-600">Receive comprehensive analysis and answers to your questions powered by OpenAI's advanced models.</p>
|
623 |
+
</div>
|
624 |
+
</div>
|
625 |
+
</div>
|
626 |
</div>
|
627 |
</div>
|
628 |
+
|
629 |
+
<!-- Footer -->
|
630 |
+
<footer class="bg-gray-900 text-white py-12 mt-20 relative">
|
631 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
632 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
633 |
+
<div>
|
634 |
+
<h3 class="text-xl font-semibold mb-4">OpenAI O4 Mini Analysis</h3>
|
635 |
+
<p class="text-gray-400">Unlock the power of AI to analyze your documents and images with ease.</p>
|
636 |
+
</div>
|
637 |
+
<div>
|
638 |
+
<h3 class="text-xl font-semibold mb-4">Quick Links</h3>
|
639 |
+
<ul class="space-y-2">
|
640 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition duration-200">Home</a></li>
|
641 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition duration-200">PDF Analysis</a></li>
|
642 |
+
<li><a href="#" class="text-gray-400 hover:text-white transition duration-200">Image Analysis</a></li>
|
643 |
+
</ul>
|
644 |
+
</div>
|
645 |
+
<div>
|
646 |
+
<h3 class="text-xl font-semibold mb-4">Connect</h3>
|
647 |
+
<div class="flex space-x-4">
|
648 |
+
<a href="#" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-twitter"></i></a>
|
649 |
+
<a href="#" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-github"></i></a>
|
650 |
+
<a href="#" class="text-gray-400 hover:text-white transition duration-200 text-xl"><i class="fab fa-linkedin"></i></a>
|
651 |
+
</div>
|
652 |
+
</div>
|
653 |
+
</div>
|
654 |
+
<div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400">
|
655 |
+
<p>© 2023 OpenAI O4 Mini Analysis. All rights reserved.</p>
|
656 |
+
</div>
|
657 |
+
</div>
|
658 |
+
</footer>
|
659 |
+
|
660 |
<script>
|
661 |
// Toggle API key visibility
|
662 |
function toggleApiKeyVisibility() {
|
663 |
const apiKeyInput = document.getElementById('api-key');
|
664 |
+
const toggleBtn = apiKeyInput.nextElementSibling;
|
665 |
+
|
666 |
if (apiKeyInput.type === 'password') {
|
667 |
apiKeyInput.type = 'text';
|
668 |
+
toggleBtn.innerHTML = '<i class="far fa-eye-slash"></i>';
|
669 |
} else {
|
670 |
apiKeyInput.type = 'password';
|
671 |
+
toggleBtn.innerHTML = '<i class="far fa-eye"></i>';
|
672 |
}
|
673 |
}
|
674 |
|
|
|
680 |
const imageContent = document.getElementById('image-content');
|
681 |
|
682 |
if (tab === 'pdf') {
|
683 |
+
pdfTab.classList.remove('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
|
684 |
+
pdfTab.classList.add('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
|
685 |
+
imageTab.classList.remove('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
|
686 |
+
imageTab.classList.add('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
|
687 |
|
688 |
pdfContent.classList.remove('hidden');
|
689 |
imageContent.classList.add('hidden');
|
|
|
693 |
void pdfContent.offsetWidth; // Trigger reflow
|
694 |
pdfContent.classList.add('animate__fadeIn');
|
695 |
} else {
|
696 |
+
imageTab.classList.remove('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
|
697 |
+
imageTab.classList.add('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
|
698 |
+
pdfTab.classList.remove('bg-white', 'text-indigo-600', 'border-b-2', 'border-indigo-600');
|
699 |
+
pdfTab.classList.add('bg-white', 'text-gray-600', 'border-transparent', 'hover:border-gray-300');
|
700 |
|
701 |
imageContent.classList.remove('hidden');
|
702 |
pdfContent.classList.add('hidden');
|
|
|
708 |
}
|
709 |
}
|
710 |
|
711 |
+
// Switch between image upload and URL
|
712 |
+
function switchImageSource(source) {
|
713 |
+
const uploadContainer = document.getElementById('image-upload-container');
|
714 |
+
const urlContainer = document.getElementById('image-url-container');
|
715 |
+
const uploadPreview = document.getElementById('image-preview-container');
|
716 |
+
const urlPreview = document.getElementById('url-preview-container');
|
717 |
+
|
718 |
+
if (source === 'upload') {
|
719 |
+
uploadContainer.classList.remove('hidden');
|
720 |
+
urlContainer.classList.add('hidden');
|
721 |
+
urlPreview.classList.add('hidden');
|
722 |
+
document.getElementById('image-url').value = '';
|
723 |
+
} else {
|
724 |
+
uploadContainer.classList.add('hidden');
|
725 |
+
urlContainer.classList.remove('hidden');
|
726 |
+
uploadPreview.classList.add('hidden');
|
727 |
+
document.getElementById('image-upload').value = '';
|
728 |
+
}
|
729 |
+
}
|
730 |
+
|
731 |
+
// Handle file upload display for PDF
|
732 |
document.getElementById('pdf-upload').addEventListener('change', function(e) {
|
733 |
+
const uploadContainer = document.getElementById('pdf-upload-container');
|
734 |
+
const previewContainer = document.getElementById('pdf-preview-container');
|
735 |
const filenameDisplay = document.getElementById('pdf-filename');
|
736 |
+
const filesizeDisplay = document.getElementById('pdf-filesize');
|
737 |
+
|
738 |
if (this.files.length > 0) {
|
739 |
+
const file = this.files[0];
|
740 |
+
filenameDisplay.textContent = file.name;
|
741 |
+
filesizeDisplay.textContent = formatFileSize(file.size);
|
742 |
+
|
743 |
+
uploadContainer.classList.add('hidden');
|
744 |
+
previewContainer.classList.remove('hidden');
|
745 |
} else {
|
746 |
+
uploadContainer.classList.remove('hidden');
|
747 |
+
previewContainer.classList.add('hidden');
|
748 |
}
|
749 |
});
|
750 |
|
751 |
+
// Handle file upload display for Image
|
752 |
document.getElementById('image-upload').addEventListener('change', function(e) {
|
753 |
+
const uploadContainer = document.getElementById('image-upload-container');
|
754 |
+
const previewContainer = document.getElementById('image-preview-container');
|
755 |
+
const previewImage = document.getElementById('image-preview');
|
756 |
+
|
757 |
if (this.files.length > 0) {
|
758 |
+
const file = this.files[0];
|
759 |
+
const reader = new FileReader();
|
760 |
+
|
761 |
+
reader.onload = function(event) {
|
762 |
+
previewImage.src = event.target.result;
|
763 |
+
uploadContainer.classList.add('hidden');
|
764 |
+
previewContainer.classList.remove('hidden');
|
765 |
+
}
|
766 |
+
|
767 |
+
reader.readAsDataURL(file);
|
768 |
} else {
|
769 |
+
uploadContainer.classList.remove('hidden');
|
770 |
+
previewContainer.classList.add('hidden');
|
771 |
}
|
772 |
});
|
773 |
|
774 |
+
// Handle image URL preview
|
775 |
+
document.getElementById('image-url').addEventListener('change', function(e) {
|
776 |
+
const url = this.value.trim();
|
777 |
+
const previewContainer = document.getElementById('url-preview-container');
|
778 |
+
const previewImage = document.getElementById('url-preview');
|
779 |
+
|
780 |
+
if (url) {
|
781 |
+
previewImage.src = url;
|
782 |
+
previewContainer.classList.remove('hidden');
|
783 |
+
|
784 |
+
// Check if image loads successfully
|
785 |
+
previewImage.onload = function() {
|
786 |
+
previewContainer.classList.remove('hidden');
|
787 |
+
}
|
788 |
+
|
789 |
+
previewImage.onerror = function() {
|
790 |
+
previewContainer.classList.add('hidden');
|
791 |
+
alert('Could not load image from the provided URL. Please check the URL and try again.');
|
792 |
+
}
|
793 |
+
} else {
|
794 |
+
previewContainer.classList.add('hidden');
|
795 |
+
}
|
796 |
+
});
|
797 |
+
|
798 |
+
// Remove PDF file
|
799 |
+
document.getElementById('remove-pdf').addEventListener('click', function() {
|
800 |
+
document.getElementById('pdf-upload').value = '';
|
801 |
+
document.getElementById('pdf-upload-container').classList.remove('hidden');
|
802 |
+
document.getElementById('pdf-preview-container').classList.add('hidden');
|
803 |
+
});
|
804 |
+
|
805 |
+
// Remove uploaded image
|
806 |
+
document.getElementById('remove-image').addEventListener('click', function() {
|
807 |
+
document.getElementById('image-upload').value = '';
|
808 |
+
document.getElementById('image-upload-container').classList.remove('hidden');
|
809 |
+
document.getElementById('image-preview-container').classList.add('hidden');
|
810 |
+
});
|
811 |
+
|
812 |
+
// Remove URL image
|
813 |
+
document.getElementById('remove-url').addEventListener('click', function() {
|
814 |
+
document.getElementById('image-url').value = '';
|
815 |
+
document.getElementById('url-preview-container').classList.add('hidden');
|
816 |
+
});
|
817 |
+
|
818 |
+
// Format file size
|
819 |
+
function formatFileSize(bytes) {
|
820 |
+
if (bytes === 0) return '0 Bytes';
|
821 |
+
|
822 |
+
const k = 1024;
|
823 |
+
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
824 |
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
825 |
+
|
826 |
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
827 |
+
}
|
828 |
+
|
829 |
// Show loading state
|
830 |
function showLoading(element) {
|
831 |
+
element.innerHTML = `
|
832 |
+
<div class="flex flex-col items-center justify-center py-8">
|
833 |
+
<div class="loading-dots mb-4">
|
834 |
+
<span></span>
|
835 |
+
<span></span>
|
836 |
+
<span></span>
|
837 |
+
</div>
|
838 |
+
<p class="text-gray-500">Analyzing content, please wait...</p>
|
839 |
+
</div>
|
840 |
+
`;
|
841 |
}
|
842 |
|
843 |
+
// Copy result to clipboard
|
844 |
+
document.getElementById('copy-pdf-result')?.addEventListener('click', function() {
|
845 |
+
const resultContent = document.getElementById('pdf-result-content').textContent;
|
846 |
+
navigator.clipboard.writeText(resultContent).then(() => {
|
847 |
+
const originalText = this.innerHTML;
|
848 |
+
this.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
849 |
+
setTimeout(() => {
|
850 |
+
this.innerHTML = originalText;
|
851 |
+
}, 2000);
|
852 |
+
});
|
853 |
+
});
|
854 |
+
|
855 |
+
document.getElementById('copy-image-result')?.addEventListener('click', function() {
|
856 |
+
const resultContent = document.getElementById('image-result-content').textContent;
|
857 |
+
navigator.clipboard.writeText(resultContent).then(() => {
|
858 |
+
const originalText = this.innerHTML;
|
859 |
+
this.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
860 |
+
setTimeout(() => {
|
861 |
+
this.innerHTML = originalText;
|
862 |
+
}, 2000);
|
863 |
+
});
|
864 |
+
});
|
865 |
+
|
866 |
// Analyze PDF function
|
867 |
async function analyzePDF() {
|
868 |
const apiKey = document.getElementById('api-key').value;
|
|
|
873 |
const resultBox = document.getElementById('pdf-result');
|
874 |
|
875 |
if (!apiKey) {
|
876 |
+
showAlert('Please provide an OpenAI API key.', 'error');
|
877 |
return;
|
878 |
}
|
879 |
|
880 |
if (!pdfFile) {
|
881 |
+
showAlert('Please upload a PDF file.', 'error');
|
882 |
return;
|
883 |
}
|
884 |
|
|
|
970 |
const resultBox = document.getElementById('image-result');
|
971 |
|
972 |
if (!apiKey) {
|
973 |
+
showAlert('Please provide an OpenAI API key.', 'error');
|
974 |
return;
|
975 |
}
|
976 |
|
977 |
if (!imageFile && !imageUrl) {
|
978 |
+
showAlert('Please upload an image or provide an image URL.', 'error');
|
979 |
return;
|
980 |
}
|
981 |
|
982 |
if (!prompt) {
|
983 |
+
showAlert('Please provide a prompt for the image analysis.', 'error');
|
984 |
return;
|
985 |
}
|
986 |
|
|
|
1092 |
}
|
1093 |
}
|
1094 |
|
1095 |
+
// Show alert message
|
1096 |
+
function showAlert(message, type = 'info') {
|
1097 |
+
const alertDiv = document.createElement('div');
|
1098 |
+
alertDiv.className = `fixed top-4 right-4 z-50 px-6 py-4 rounded-lg shadow-lg flex items-center ${
|
1099 |
+
type === 'error' ? 'bg-red-100 text-red-800' :
|
1100 |
+
type === 'success' ? 'bg-green-100 text-green-800' :
|
1101 |
+
'bg-blue-100 text-blue-800'
|
1102 |
+
}`;
|
1103 |
+
|
1104 |
+
const icon = type === 'error' ? 'exclamation-circle' :
|
1105 |
+
type === 'success' ? 'check-circle' : 'info-circle';
|
1106 |
+
|
1107 |
+
alertDiv.innerHTML = `
|
1108 |
+
<i class="fas fa-${icon} mr-3"></i>
|
1109 |
+
<span>${message}</span>
|
1110 |
+
<button class="ml-4 text-xl" onclick="this.parentElement.remove()">
|
1111 |
+
<i class="fas fa-times"></i>
|
1112 |
+
</button>
|
1113 |
+
`;
|
1114 |
+
|
1115 |
+
document.body.appendChild(alertDiv);
|
1116 |
+
|
1117 |
+
setTimeout(() => {
|
1118 |
+
alertDiv.remove();
|
1119 |
+
}, 5000);
|
1120 |
+
}
|
1121 |
+
|
1122 |
// Add glow effect to buttons on hover
|
1123 |
document.querySelectorAll('button').forEach(button => {
|
1124 |
+
if (!button.id.includes('remove') && button.id !== 'api-key-toggle') {
|
1125 |
button.addEventListener('mouseenter', () => {
|
1126 |
button.classList.add('glow');
|
1127 |
});
|
|
|
1130 |
});
|
1131 |
}
|
1132 |
});
|
1133 |
+
|
1134 |
+
// Add pulse animation to feature cards on hover
|
1135 |
+
document.querySelectorAll('.card').forEach(card => {
|
1136 |
+
card.addEventListener('mouseenter', () => {
|
1137 |
+
card.classList.add('glow');
|
1138 |
+
});
|
1139 |
+
card.addEventListener('mouseleave', () => {
|
1140 |
+
card.classList.remove('pulse');
|
1141 |
+
});
|
1142 |
+
});
|
1143 |
</script>
|
1144 |
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=shukdevdatta123/openai-o4-mini-multi-modal-chat-app" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
1145 |
</html>
|
prompts.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
import gradio as gr import base64 import os from openai import OpenAI import tempfile def extract_text_from_response(response): """Extract text from OpenAI API response based on the actual structure""" try: # First check if response has an output attribute if hasattr(response, 'output'): output = response.output # Look for message items in the output list for item in output: if hasattr(item, 'role') and item.role == 'assistant': for content_item in item.content: if hasattr(content_item, 'type') and content_item.type == 'output_text': return content_item.text # If we couldn't find it in the expected structure, return an error return f"Couldn't extract text from response: {str(response)}" except Exception as e: return f"Error processing response: {str(e)}" def analyze_pdf(api_key, pdf_file, prompt, effort_level): """Analyze a PDF file using OpenAI API""" if not api_key: return "Please provide an OpenAI API key." if pdf_file is None: return "Please upload a PDF file." # Initialize OpenAI client with the provided API key client = OpenAI(api_key=api_key) # Read the PDF file and encode it in base64 with open(pdf_file.name, "rb") as file: pdf_bytes = file.read() pdf_base64 = base64.b64encode(pdf_bytes).decode("utf-8") try: # Create the request response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": [ { "type": "input_text", "text": prompt }, { "type": "input_file", "filename": os.path.basename(pdf_file.name), "file_data": f"data:application/pdf;base64,{pdf_base64}" } ] } ], text={ "format": { "type": "text" } }, reasoning={ "effort": effort_level }, tools=[], store=True ) return extract_text_from_response(response) except Exception as e: return f"Error: {str(e)}" def analyze_image(api_key, image, image_url, prompt, effort_level): """Analyze an image using OpenAI API""" if not api_key: return "Please provide an OpenAI API key." if image is None and not image_url: return "Please upload an image or provide an image URL." if not prompt: return "Please provide a prompt for the image analysis." # Initialize OpenAI client with the provided API key client = OpenAI(api_key=api_key) content = [] # Add text prompt content.append({ "type": "input_text", "text": prompt }) # Add image - either from uploaded file or URL try: if image is not None: # Convert image to base64 with open(image, "rb") as img_file: img_bytes = img_file.read() img_base64 = base64.b64encode(img_bytes).decode("utf-8") content.insert(0, { "type": "input_image", "image_url": f"data:image/png;base64,{img_base64}" }) elif image_url: content.insert(0, { "type": "input_image", "image_url": image_url }) # Create the request response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": content } ], text={ "format": { "type": "text" } }, reasoning={ "effort": effort_level }, tools=[], store=True ) return extract_text_from_response(response) except Exception as e: return f"Error: {str(e)}" # Create Gradio interface with gr.Blocks(title="OpenAI O4 Analysis App") as app: gr.Markdown("# OpenAI O4 Mini Analysis Application") # API Key input (used across both tabs) api_key_input = gr.Textbox( label="OpenAI API Key", placeholder="Enter your OpenAI API key here...", type="password" ) with gr.Tab("PDF Analysis"): gr.Markdown("## Upload a PDF file for analysis") with gr.Row(): pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"]) pdf_prompt = gr.Textbox( label="Prompt", placeholder="Enter your question about the PDF...", value="What is this PDF about?" ) pdf_effort = gr.Radio( ["low", "medium", "high"], label="Reasoning Effort", value="medium" ) pdf_button = gr.Button("Analyze PDF") pdf_output = gr.Textbox(label="Analysis Result", lines=10) pdf_button.click( analyze_pdf, inputs=[api_key_input, pdf_input, pdf_prompt, pdf_effort], outputs=pdf_output ) with gr.Tab("Image Analysis"): gr.Markdown("## Upload an image or provide an image URL for analysis") with gr.Row(): with gr.Column(): img_input = gr.Image(label="Upload Image", type="filepath") img_url = gr.Textbox( label="Or enter image URL", placeholder="https://example.com/image.jpg" ) img_prompt = gr.Textbox( label="Prompt", placeholder="Enter your question about the image...", value="What is this image about?" ) img_effort = gr.Radio( ["low", "medium", "high"], label="Reasoning Effort", value="medium" ) img_output = gr.Textbox(label="Analysis Result", lines=10) img_button = gr.Button("Analyze Image") img_button.click( analyze_image, inputs=[api_key_input, img_input, img_url, img_prompt, img_effort], outputs=img_output ) gr.Markdown(""" ### Note: - Your OpenAI API key is required to use this application - The API key is only used for requests and is not stored """) # Launch the app if __name__ == "__main__": app.launch() (please convert this code to a very very awesome looking website with amazing animations... make sure the website works exactly in the same way the above project code works)
|
|
|
|
1 |
+
import gradio as gr import base64 import os from openai import OpenAI import tempfile def extract_text_from_response(response): """Extract text from OpenAI API response based on the actual structure""" try: # First check if response has an output attribute if hasattr(response, 'output'): output = response.output # Look for message items in the output list for item in output: if hasattr(item, 'role') and item.role == 'assistant': for content_item in item.content: if hasattr(content_item, 'type') and content_item.type == 'output_text': return content_item.text # If we couldn't find it in the expected structure, return an error return f"Couldn't extract text from response: {str(response)}" except Exception as e: return f"Error processing response: {str(e)}" def analyze_pdf(api_key, pdf_file, prompt, effort_level): """Analyze a PDF file using OpenAI API""" if not api_key: return "Please provide an OpenAI API key." if pdf_file is None: return "Please upload a PDF file." # Initialize OpenAI client with the provided API key client = OpenAI(api_key=api_key) # Read the PDF file and encode it in base64 with open(pdf_file.name, "rb") as file: pdf_bytes = file.read() pdf_base64 = base64.b64encode(pdf_bytes).decode("utf-8") try: # Create the request response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": [ { "type": "input_text", "text": prompt }, { "type": "input_file", "filename": os.path.basename(pdf_file.name), "file_data": f"data:application/pdf;base64,{pdf_base64}" } ] } ], text={ "format": { "type": "text" } }, reasoning={ "effort": effort_level }, tools=[], store=True ) return extract_text_from_response(response) except Exception as e: return f"Error: {str(e)}" def analyze_image(api_key, image, image_url, prompt, effort_level): """Analyze an image using OpenAI API""" if not api_key: return "Please provide an OpenAI API key." if image is None and not image_url: return "Please upload an image or provide an image URL." if not prompt: return "Please provide a prompt for the image analysis." # Initialize OpenAI client with the provided API key client = OpenAI(api_key=api_key) content = [] # Add text prompt content.append({ "type": "input_text", "text": prompt }) # Add image - either from uploaded file or URL try: if image is not None: # Convert image to base64 with open(image, "rb") as img_file: img_bytes = img_file.read() img_base64 = base64.b64encode(img_bytes).decode("utf-8") content.insert(0, { "type": "input_image", "image_url": f"data:image/png;base64,{img_base64}" }) elif image_url: content.insert(0, { "type": "input_image", "image_url": image_url }) # Create the request response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": content } ], text={ "format": { "type": "text" } }, reasoning={ "effort": effort_level }, tools=[], store=True ) return extract_text_from_response(response) except Exception as e: return f"Error: {str(e)}" # Create Gradio interface with gr.Blocks(title="OpenAI O4 Analysis App") as app: gr.Markdown("# OpenAI O4 Mini Analysis Application") # API Key input (used across both tabs) api_key_input = gr.Textbox( label="OpenAI API Key", placeholder="Enter your OpenAI API key here...", type="password" ) with gr.Tab("PDF Analysis"): gr.Markdown("## Upload a PDF file for analysis") with gr.Row(): pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"]) pdf_prompt = gr.Textbox( label="Prompt", placeholder="Enter your question about the PDF...", value="What is this PDF about?" ) pdf_effort = gr.Radio( ["low", "medium", "high"], label="Reasoning Effort", value="medium" ) pdf_button = gr.Button("Analyze PDF") pdf_output = gr.Textbox(label="Analysis Result", lines=10) pdf_button.click( analyze_pdf, inputs=[api_key_input, pdf_input, pdf_prompt, pdf_effort], outputs=pdf_output ) with gr.Tab("Image Analysis"): gr.Markdown("## Upload an image or provide an image URL for analysis") with gr.Row(): with gr.Column(): img_input = gr.Image(label="Upload Image", type="filepath") img_url = gr.Textbox( label="Or enter image URL", placeholder="https://example.com/image.jpg" ) img_prompt = gr.Textbox( label="Prompt", placeholder="Enter your question about the image...", value="What is this image about?" ) img_effort = gr.Radio( ["low", "medium", "high"], label="Reasoning Effort", value="medium" ) img_output = gr.Textbox(label="Analysis Result", lines=10) img_button = gr.Button("Analyze Image") img_button.click( analyze_image, inputs=[api_key_input, img_input, img_url, img_prompt, img_effort], outputs=img_output ) gr.Markdown(""" ### Note: - Your OpenAI API key is required to use this application - The API key is only used for requests and is not stored """) # Launch the app if __name__ == "__main__": app.launch() (please convert this code to a very very awesome looking website with amazing animations... make sure the website works exactly in the same way the above project code works)
|
2 |
+
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>OpenAI O4 Analysis App</title> <script src="https://cdn.tailwindcss.com"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> <style> body { font-family: 'Inter', sans-serif; background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); min-height: 100vh; } .tab-button { transition: all 0.3s ease; } .tab-button.active { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); } .result-box { transition: all 0.3s ease; min-height: 200px; } .loading-dots { display: inline-block; } .loading-dots span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background-color: #4f46e5; margin: 0 2px; animation: bounce 1.4s infinite ease-in-out both; } .loading-dots span:nth-child(1) { animation-delay: -0.32s; } .loading-dots span:nth-child(2) { animation-delay: -0.16s; } @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } } .file-input-label { transition: all 0.3s ease; } .file-input-label:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3), 0 2px 4px -1px rgba(79, 70, 229, 0.06); } .glow { animation: glow 2s infinite alternate; } @keyframes glow { from { box-shadow: 0 0 5px rgba(79, 70, 229, 0.5); } to { box-shadow: 0 0 20px rgba(79, 70, 229, 0.8); } } </style> </head> <body class="py-8 px-4 sm:px-6 lg:px-8"> <div class="max-w-4xl mx-auto"> <!-- Header --> <div class="text-center mb-10 animate__animated animate__fadeIn"> <h1 class="text-4xl font-bold text-indigo-600 mb-2">OpenAI O4 Mini Analysis</h1> <p class="text-lg text-gray-600">Analyze PDFs and Images with AI-powered insights</p> </div> <!-- API Key Input --> <div class="bg-white rounded-xl shadow-lg p-6 mb-8 animate__animated animate__fadeInUp"> <label for="api-key" class="block text-sm font-medium text-gray-700 mb-1">OpenAI API Key</label> <div class="relative"> <input type="password" id="api-key" placeholder="Enter your OpenAI API key here..." class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200" > <button onclick="toggleApiKeyVisibility()" class="absolute right-3 top-3 text-gray-500 hover:text-indigo-600 focus:outline-none" > 👁️ </button> </div> <p class="mt-2 text-sm text-gray-500">Your API key is only used for requests and is not stored.</p> </div> <!-- Tabs --> <div class="flex space-x-2 mb-6 animate__animated animate__fadeIn"> <button id="pdf-tab" onclick="switchTab('pdf')" class="tab-button active px-6 py-3 rounded-lg font-medium bg-indigo-600 text-white" > PDF Analysis </button> <button id="image-tab" onclick="switchTab('image')" class="tab-button px-6 py-3 rounded-lg font-medium bg-gray-200 text-gray-700 hover:bg-gray-300" > Image Analysis </button> </div> <!-- PDF Analysis Tab --> <div id="pdf-content" class="animate__animated animate__fadeIn"> <div class="bg-white rounded-xl shadow-lg overflow-hidden"> <div class="p-6"> <h2 class="text-2xl font-semibold text-gray-800 mb-4">Upload a PDF for Analysis</h2> <div class="mb-6"> <label class="block text-sm font-medium text-gray-700 mb-2">Upload PDF</label> <label for="pdf-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200"> <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400 mb-2" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" /> </svg> <span class="text-sm font-medium text-gray-600">Click to upload PDF</span> <span class="text-xs text-gray-500 mt-1">.pdf files only</span> <input id="pdf-upload" type="file" accept=".pdf" class="hidden"> </label> <p id="pdf-filename" class="mt-2 text-sm text-gray-500 hidden">Selected file: <span class="font-medium"></span></p> </div> <div class="mb-6"> <label for="pdf-prompt" class="block text-sm font-medium text-gray-700 mb-2">Prompt</label> <textarea id="pdf-prompt" rows="3" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200" placeholder="Enter your question about the PDF..." >What is this PDF about?</textarea> </div> <div class="mb-6"> <label class="block text-sm font-medium text-gray-700 mb-2">Reasoning Effort</label> <div class="flex space-x-4"> <label class="inline-flex items-center"> <input type="radio" name="pdf-effort" value="low" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">Low</span> </label> <label class="inline-flex items-center"> <input type="radio" name="pdf-effort" value="medium" checked class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">Medium</span> </label> <label class="inline-flex items-center"> <input type="radio" name="pdf-effort" value="high" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">High</span> </label> </div> </div> <button id="analyze-pdf-btn" onclick="analyzePDF()" class="w-full py-3 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" > Analyze PDF </button> </div> <div id="pdf-result" class="result-box border-t border-gray-200 p-6 bg-gray-50 hidden"> <h3 class="text-lg font-medium text-gray-800 mb-3">Analysis Result</h3> <div id="pdf-result-content" class="min-h-40 p-4 bg-white rounded-lg border border-gray-200"></div> </div> </div> </div> <!-- Image Analysis Tab --> <div id="image-content" class="hidden animate__animated animate__fadeIn"> <div class="bg-white rounded-xl shadow-lg overflow-hidden"> <div class="p-6"> <h2 class="text-2xl font-semibold text-gray-800 mb-4">Upload an Image for Analysis</h2> <div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6"> <div> <label class="block text-sm font-medium text-gray-700 mb-2">Upload Image</label> <label for="image-upload" class="file-input-label cursor-pointer flex flex-col items-center justify-center px-6 py-12 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 hover:bg-gray-100 transition duration-200"> <svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 text-gray-400 mb-2" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" /> </svg> <span class="text-sm font-medium text-gray-600">Click to upload image</span> <span class="text-xs text-gray-500 mt-1">.jpg, .png, etc.</span> <input id="image-upload" type="file" accept="image/*" class="hidden"> </label> <p id="image-filename" class="mt-2 text-sm text-gray-500 hidden">Selected file: <span class="font-medium"></span></p> <div class="mt-4"> <label for="image-url" class="block text-sm font-medium text-gray-700 mb-2">Or enter image URL</label> <input type="text" id="image-url" placeholder="https://example.com/image.jpg" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200" > </div> </div> <div> <div class="mb-6"> <label for="image-prompt" class="block text-sm font-medium text-gray-700 mb-2">Prompt</label> <textarea id="image-prompt" rows="3" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition duration-200" placeholder="Enter your question about the image..." >What is this image about?</textarea> </div> <div class="mb-6"> <label class="block text-sm font-medium text-gray-700 mb-2">Reasoning Effort</label> <div class="flex space-x-4"> <label class="inline-flex items-center"> <input type="radio" name="image-effort" value="low" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">Low</span> </label> <label class="inline-flex items-center"> <input type="radio" name="image-effort" value="medium" checked class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">Medium</span> </label> <label class="inline-flex items-center"> <input type="radio" name="image-effort" value="high" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500"> <span class="ml-2 text-gray-700">High</span> </label> </div> </div> </div> </div> <button id="analyze-image-btn" onclick="analyzeImage()" class="w-full py-3 px-6 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-lg transition duration-200 transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" > Analyze Image </button> </div> <div id="image-result" class="result-box border-t border-gray-200 p-6 bg-gray-50 hidden"> <h3 class="text-lg font-medium text-gray-800 mb-3">Analysis Result</h3> <div id="image-result-content" class="min-h-40 p-4 bg-white rounded-lg border border-gray-200"></div> </div> </div> </div> <!-- Footer --> <div class="mt-12 text-center text-gray-500 text-sm animate__animated animate__fadeIn"> <p>OpenAI O4 Mini Analysis Application</p> </div> </div> <script> // Toggle API key visibility function toggleApiKeyVisibility() { const apiKeyInput = document.getElementById('api-key'); if (apiKeyInput.type === 'password') { apiKeyInput.type = 'text'; } else { apiKeyInput.type = 'password'; } } // Switch between tabs function switchTab(tab) { const pdfTab = document.getElementById('pdf-tab'); const imageTab = document.getElementById('image-tab'); const pdfContent = document.getElementById('pdf-content'); const imageContent = document.getElementById('image-content'); if (tab === 'pdf') { pdfTab.classList.remove('bg-gray-200', 'text-gray-700'); pdfTab.classList.add('bg-indigo-600', 'text-white'); imageTab.classList.remove('bg-indigo-600', 'text-white'); imageTab.classList.add('bg-gray-200', 'text-gray-700'); pdfContent.classList.remove('hidden'); imageContent.classList.add('hidden'); // Add animation pdfContent.classList.remove('animate__fadeIn'); void pdfContent.offsetWidth; // Trigger reflow pdfContent.classList.add('animate__fadeIn'); } else { imageTab.classList.remove('bg-gray-200', 'text-gray-700'); imageTab.classList.add('bg-indigo-600', 'text-white'); pdfTab.classList.remove('bg-indigo-600', 'text-white'); pdfTab.classList.add('bg-gray-200', 'text-gray-700'); imageContent.classList.remove('hidden'); pdfContent.classList.add('hidden'); // Add animation imageContent.classList.remove('animate__fadeIn'); void imageContent.offsetWidth; // Trigger reflow imageContent.classList.add('animate__fadeIn'); } } // Handle file upload display document.getElementById('pdf-upload').addEventListener('change', function(e) { const filenameDisplay = document.getElementById('pdf-filename'); if (this.files.length > 0) { filenameDisplay.classList.remove('hidden'); filenameDisplay.querySelector('span').textContent = this.files[0].name; } else { filenameDisplay.classList.add('hidden'); } }); document.getElementById('image-upload').addEventListener('change', function(e) { const filenameDisplay = document.getElementById('image-filename'); if (this.files.length > 0) { filenameDisplay.classList.remove('hidden'); filenameDisplay.querySelector('span').textContent = this.files[0].name; } else { filenameDisplay.classList.add('hidden'); } }); // Show loading state function showLoading(element) { element.innerHTML = '<div class="loading-dots"><span></span><span></span><span></span></div>'; } // Analyze PDF function async function analyzePDF() { const apiKey = document.getElementById('api-key').value; const pdfFile = document.getElementById('pdf-upload').files[0]; const prompt = document.getElementById('pdf-prompt').value; const effortLevel = document.querySelector('input[name="pdf-effort"]:checked').value; const resultContent = document.getElementById('pdf-result-content'); const resultBox = document.getElementById('pdf-result'); if (!apiKey) { alert('Please provide an OpenAI API key.'); return; } if (!pdfFile) { alert('Please upload a PDF file.'); return; } // Show loading state resultBox.classList.remove('hidden'); showLoading(resultContent); try { // Read the PDF file and convert to base64 const pdfBase64 = await new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => { const arrayBuffer = reader.result; const bytes = new Uint8Array(arrayBuffer); let binary = ''; for (let i = 0; i < bytes.byteLength; i++) { binary += String.fromCharCode(bytes[i]); } const base64 = btoa(binary); resolve(base64); }; reader.onerror = reject; reader.readAsArrayBuffer(pdfFile); }); // Create the request payload const payload = { model: "o4-mini", input: [ { role: "user", content: [ { type: "input_text", text: prompt }, { type: "input_file", filename: pdfFile.name, file_data: `data:application/pdf;base64,${pdfBase64}` } ] } ], text: { format: { type: "text" } }, reasoning: { effort: effortLevel }, tools: [], store: true }; // Make the API request const response = await axios.post('https://api.openai.com/v1/responses', payload, { headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' } }); // Process the response const result = extractTextFromResponse(response.data); resultContent.innerHTML = `<div class="text-gray-700 whitespace-pre-wrap">${result}</div>`; } catch (error) { console.error('Error:', error); let errorMessage = 'An error occurred while analyzing the PDF.'; if (error.response) { errorMessage = `Error: ${error.response.data.error?.message || error.response.statusText}`; } else if (error.message) { errorMessage = `Error: ${error.message}`; } resultContent.innerHTML = `<div class="text-red-600">${errorMessage}</div>`; } } // Analyze Image function async function analyzeImage() { const apiKey = document.getElementById('api-key').value; const imageFile = document.getElementById('image-upload').files[0]; const imageUrl = document.getElementById('image-url').value; const prompt = document.getElementById('image-prompt').value; const effortLevel = document.querySelector('input[name="image-effort"]:checked').value; const resultContent = document.getElementById('image-result-content'); const resultBox = document.getElementById('image-result'); if (!apiKey) { alert('Please provide an OpenAI API key.'); return; } if (!imageFile && !imageUrl) { alert('Please upload an image or provide an image URL.'); return; } if (!prompt) { alert('Please provide a prompt for the image analysis.'); return; } // Show loading state resultBox.classList.remove('hidden'); showLoading(resultContent); try { const content = [ { type: "input_text", text: prompt } ]; if (imageFile) { // Read the image file and convert to base64 const imageBase64 = await new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => { const base64 = reader.result.split(',')[1]; resolve(base64); }; reader.onerror = reject; reader.readAsDataURL(imageFile); }); content.unshift({ type: "input_image", image_url: `data:image/png;base64,${imageBase64}` }); } else if (imageUrl) { content.unshift({ type: "input_image", image_url: imageUrl }); } // Create the request payload const payload = { model: "o4-mini", input: [ { role: "user", content: content } ], text: { format: { type: "text" } }, reasoning: { effort: effortLevel }, tools: [], store: true }; // Make the API request const response = await axios.post('https://api.openai.com/v1/responses', payload, { headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' } }); // Process the response const result = extractTextFromResponse(response.data); resultContent.innerHTML = `<div class="text-gray-700 whitespace-pre-wrap">${result}</div>`; } catch (error) { console.error('Error:', error); let errorMessage = 'An error occurred while analyzing the image.'; if (error.response) { errorMessage = `Error: ${error.response.data.error?.message || error.response.statusText}`; } else if (error.message) { errorMessage = `Error: ${error.message}`; } resultContent.innerHTML = `<div class="text-red-600">${errorMessage}</div>`; } } // Extract text from response function extractTextFromResponse(response) { try { // First check if response has an output attribute if (response.output) { const output = response.output; // Look for message items in the output list for (const item of output) { if (item.role === 'assistant') { for (const contentItem of item.content) { if (contentItem.type === 'output_text') { return contentItem.text; } } } } // If we couldn't find it in the expected structure, return an error return `Couldn't extract text from response: ${JSON.stringify(response)}`; } return `Unexpected response structure: ${JSON.stringify(response)}`; } catch (error) { return `Error processing response: ${error.message}`; } } // Add glow effect to buttons on hover document.querySelectorAll('button').forEach(button => { if (button.id !== 'api-key-toggle') { button.addEventListener('mouseenter', () => { button.classList.add('glow'); }); button.addEventListener('mouseleave', () => { button.classList.remove('glow'); }); } }); </script> </body> </html> (hey in this code once I select a pdf file after upload I cannot remove it so please give option for that similarly when I upload an image it get selected but I cannot remove it so please give option for that also.... In case of image chat user will atfirst to choose image upload chat... or image url chat... give me full code please) (include some html css that will make the website even more attractive)
|