Spaces:
Running
Running
Update static/appS.js
Browse files- static/appS.js +19 -11
static/appS.js
CHANGED
@@ -152,15 +152,21 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
152 |
return bubble;
|
153 |
}
|
154 |
|
155 |
-
|
156 |
if (!selectedFile) {
|
157 |
-
|
158 |
return;
|
159 |
}
|
160 |
|
161 |
const length = document.querySelector('input[name="optionS"]:checked')?.value || "medium";
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
const thinkingBubble = createMessageBubble(
|
163 |
-
"Analyzing
|
164 |
"Aidan"
|
165 |
);
|
166 |
|
@@ -180,23 +186,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
180 |
}
|
181 |
|
182 |
const result = await response.json();
|
|
|
|
|
183 |
thinkingBubble.remove();
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
"Aidan",
|
190 |
-
result.audio_url
|
191 |
);
|
|
|
192 |
} catch (error) {
|
193 |
thinkingBubble.remove();
|
194 |
-
|
195 |
} finally {
|
196 |
resetFileInputs();
|
197 |
}
|
198 |
}
|
199 |
|
|
|
200 |
async function handleCaption() {
|
201 |
if (!selectedFile) {
|
202 |
alert("Please upload an image first");
|
|
|
152 |
return bubble;
|
153 |
}
|
154 |
|
155 |
+
async function handleSummarize() {
|
156 |
if (!selectedFile) {
|
157 |
+
displayError('Please upload a document first');
|
158 |
return;
|
159 |
}
|
160 |
|
161 |
const length = document.querySelector('input[name="optionS"]:checked')?.value || "medium";
|
162 |
+
|
163 |
+
// Clear conversation and show file preview
|
164 |
+
convo.innerHTML = '';
|
165 |
+
displayFileInfo(selectedFile.name, 'document');
|
166 |
+
|
167 |
+
// Show correct processing message for summarization
|
168 |
const thinkingBubble = createMessageBubble(
|
169 |
+
"Analyzing document and generating summary... <div class='loader'></div>",
|
170 |
"Aidan"
|
171 |
);
|
172 |
|
|
|
186 |
}
|
187 |
|
188 |
const result = await response.json();
|
189 |
+
|
190 |
+
// Remove thinking message and show results
|
191 |
thinkingBubble.remove();
|
192 |
+
displaySummaryResult(
|
193 |
+
selectedFile.name,
|
194 |
+
result.summary,
|
195 |
+
result.audio_url || result.audioUrl,
|
196 |
+
result.pdf_url || result.pdfUrl
|
|
|
|
|
197 |
);
|
198 |
+
|
199 |
} catch (error) {
|
200 |
thinkingBubble.remove();
|
201 |
+
displayError(error.message || 'Failed to summarize document');
|
202 |
} finally {
|
203 |
resetFileInputs();
|
204 |
}
|
205 |
}
|
206 |
|
207 |
+
|
208 |
async function handleCaption() {
|
209 |
if (!selectedFile) {
|
210 |
alert("Please upload an image first");
|