ganna217 commited on
Commit
4adf837
·
1 Parent(s): 1646ac1

Update app with integrated HTML and lighter model

Browse files
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. index.html +26 -17
__pycache__/app.cpython-311.pyc ADDED
Binary file (5.42 kB). View file
 
index.html CHANGED
@@ -6,6 +6,7 @@
6
  <title>QuickBrief</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Papyrus&display=swap" rel="stylesheet">
8
  <style>
 
9
  * {
10
  box-sizing: border-box;
11
  margin: 0;
@@ -232,11 +233,21 @@
232
  </div>
233
  <script>
234
  console.log("Script loaded successfully");
 
235
  async function summarize() {
236
  const text = document.getElementById("inputText").value;
 
 
 
 
 
 
237
  try {
238
  const controller = new AbortController();
239
- const timeoutId = setTimeout(() => controller.abort(), 120000);
 
 
 
240
  const response = await fetch("/summarize", {
241
  method: "POST",
242
  headers: { "Content-Type": "application/json" },
@@ -246,27 +257,29 @@
246
  clearTimeout(timeoutId);
247
  const data = await response.json();
248
  console.log("Summarize response:", JSON.stringify(data, null, 2));
249
- if (data.summary) {
250
- document.getElementById("summary").innerText = data.summary;
251
- } else {
252
- document.getElementById("summary").innerText = "Error: " + (data.error || "No summary returned");
253
- }
254
  } catch (error) {
255
- console.error("Summarize error:", error);
256
- document.getElementById("summary").innerText = "Failed to summarize: " + error.message;
257
  }
258
  }
 
259
  async function doTranslate() {
260
  const summary = document.getElementById("summary").innerText;
261
  const lang = document.getElementById("language").value;
 
262
  if (lang === "default" || summary === "") {
263
- document.getElementById("translation").innerText = "Please select a language and ensure a summary is available.";
264
  return;
265
  }
 
266
  console.log("Translate called with lang:", lang, "Text:", summary);
267
  try {
268
  const controller = new AbortController();
269
- const timeoutId = setTimeout(() => controller.abort(), 120000);
 
 
 
270
  const response = await fetch("/translate", {
271
  method: "POST",
272
  headers: { "Content-Type": "application/json" },
@@ -276,14 +289,10 @@
276
  clearTimeout(timeoutId);
277
  const data = await response.json();
278
  console.log("Translate response:", JSON.stringify(data, null, 2));
279
- if (data.translation) {
280
- document.getElementById("translation").innerText = data.translation;
281
- } else {
282
- document.getElementById("translation").innerText = "Error: " + (data.error || "No translation returned");
283
- }
284
  } catch (error) {
285
- console.error("Translate error:", error);
286
- document.getElementById("translation").innerText = "Failed to translate: " + error.message;
287
  }
288
  }
289
  </script>
 
6
  <title>QuickBrief</title>
7
  <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Papyrus&display=swap" rel="stylesheet">
8
  <style>
9
+ /* Same styles as before */
10
  * {
11
  box-sizing: border-box;
12
  margin: 0;
 
233
  </div>
234
  <script>
235
  console.log("Script loaded successfully");
236
+
237
  async function summarize() {
238
  const text = document.getElementById("inputText").value;
239
+ const summaryDiv = document.getElementById("summary");
240
+ if (text.length > 1000) {
241
+ summaryDiv.innerText = "Input too long; please use less than 1000 characters.";
242
+ return;
243
+ }
244
+ summaryDiv.innerText = "Summarizing...";
245
  try {
246
  const controller = new AbortController();
247
+ const timeoutId = setTimeout(() => {
248
+ controller.abort();
249
+ console.warn("Summarize timed out after 300 seconds");
250
+ }, 300000); // Increased to 5 minutes
251
  const response = await fetch("/summarize", {
252
  method: "POST",
253
  headers: { "Content-Type": "application/json" },
 
257
  clearTimeout(timeoutId);
258
  const data = await response.json();
259
  console.log("Summarize response:", JSON.stringify(data, null, 2));
260
+ summaryDiv.innerText = data.summary || "Error: " + (data.error || "No summary returned");
 
 
 
 
261
  } catch (error) {
262
+ console.error("Summarize error:", error.name, error.message);
263
+ summaryDiv.innerText = `Failed to summarize: ${error.message}${error.name === "AbortError" ? " (Timeout?)" : ""}`;
264
  }
265
  }
266
+
267
  async function doTranslate() {
268
  const summary = document.getElementById("summary").innerText;
269
  const lang = document.getElementById("language").value;
270
+ const translationDiv = document.getElementById("translation");
271
  if (lang === "default" || summary === "") {
272
+ translationDiv.innerText = "Please select a language and ensure a summary is available.";
273
  return;
274
  }
275
+ translationDiv.innerText = "Translating...";
276
  console.log("Translate called with lang:", lang, "Text:", summary);
277
  try {
278
  const controller = new AbortController();
279
+ const timeoutId = setTimeout(() => {
280
+ controller.abort();
281
+ console.warn("Translate timed out after 300 seconds");
282
+ }, 300000); // Increased to 5 minutes
283
  const response = await fetch("/translate", {
284
  method: "POST",
285
  headers: { "Content-Type": "application/json" },
 
289
  clearTimeout(timeoutId);
290
  const data = await response.json();
291
  console.log("Translate response:", JSON.stringify(data, null, 2));
292
+ translationDiv.innerText = data.translation || "Error: " + (data.error || "No translation returned");
 
 
 
 
293
  } catch (error) {
294
+ console.error("Translate error:", error.name, error.message);
295
+ translationDiv.innerText = `Failed to translate: ${error.message}${error.name === "AbortError" ? " (Timeout?)" : ""}`;
296
  }
297
  }
298
  </script>