fix examples

#1
by akhaliq HF Staff - opened
Files changed (2) hide show
  1. static/app.js +49 -17
  2. static/index.html +7 -7
static/app.js CHANGED
@@ -68,6 +68,36 @@ marked.setOptions({
68
 
69
  // Setup Initial State & Event Handlers
70
  async function initializeApp() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  // 1. Connect Gradio Client in background (Non-blocking)
72
  Client.connect(window.location.origin)
73
  .then(app => {
@@ -299,28 +329,26 @@ function removeFile(id) {
299
 
300
  // Load Cookbook Showcase Recipes
301
  function loadRecipe(recipeType) {
302
- const mockImageBase64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
303
  STATE.uploadedFiles = [];
304
-
305
  let promptText = "";
306
 
307
- if (recipeType === "whiteboard") {
308
- promptText = "Here is a snapshot of our whiteboard project plan sketch. Translate this visual sequence of tasks and boxes into a clean, itemized roadmap plan with a structured markdown table.";
309
  STATE.uploadedFiles.push({
310
- id: "recipe-whiteboard",
311
- name: "whiteboard_gantt.png",
312
- type: "image/png",
313
- size: "0.02 MB",
314
- base64: mockImageBase64
315
  });
316
- } else if (recipeType === "diagnostic") {
317
- promptText = "This is a recorded visual sequence of steps leading to a runtime exception crash. Provide a detailed reconstruction of the event timeline, summarize the diagnostic signals, and suggest an engineering hotfix.";
318
  STATE.uploadedFiles.push({
319
- id: "recipe-diagnostics",
320
- name: "console_bug.mp4",
321
  type: "video/mp4",
322
- size: "1.45 MB",
323
- base64: mockImageBase64
324
  });
325
  }
326
 
@@ -479,7 +507,7 @@ function appendUserBubble(text, files) {
479
  } else {
480
  attachmentsHtml += `
481
  <div class="bubble-attachment-card">
482
- <div class="media-chip-preview" style="width:100%;height:100%;">🎬</div>
483
  <div class="bubble-attachment-label">VIDEO</div>
484
  </div>
485
  `;
@@ -638,4 +666,8 @@ function scrollToBottom() {
638
  }
639
 
640
  // Initialise application when DOM is fully set up
641
- window.addEventListener("DOMContentLoaded", initializeApp);
 
 
 
 
 
68
 
69
  // Setup Initial State & Event Handlers
70
  async function initializeApp() {
71
+ // Re-query all DOM elements to ensure they are fully resolved after DOMContentLoaded
72
+ dom.effortRadioButtons = document.querySelectorAll('input[name="reasoning-effort"]');
73
+ dom.maxTokensSlider = document.getElementById("max-tokens-slider");
74
+ dom.maxTokensVal = document.getElementById("max-tokens-val");
75
+ dom.temperatureSlider = document.getElementById("temperature-slider");
76
+ dom.temperatureVal = document.getElementById("temperature-val");
77
+ dom.sidebarRight = document.getElementById("sidebar-right");
78
+ dom.sidebarOverlay = document.getElementById("sidebar-overlay");
79
+ dom.btnToggleRight = document.getElementById("btn-toggle-right");
80
+ dom.btnCloseDrawer = document.getElementById("btn-close-drawer");
81
+ dom.studioDashboard = document.getElementById("studio-dashboard");
82
+ dom.chatThreadContainer = document.getElementById("chat-thread-container");
83
+ dom.chatMessagesFeed = document.getElementById("chat-messages-feed");
84
+ dom.studioPromptInput = document.getElementById("studio-prompt-input");
85
+ dom.innerShelfPreview = document.getElementById("inner-shelf-preview");
86
+ dom.studioUploadTrigger = document.getElementById("studio-upload-trigger");
87
+ dom.studioSendBtn = document.getElementById("studio-send-button");
88
+ dom.studioSpinner = document.getElementById("studio-spinner");
89
+ dom.miniPromptInput = document.getElementById("mini-prompt-input");
90
+ dom.miniShelfPreview = document.getElementById("mini-shelf-preview");
91
+ dom.miniUploadTrigger = document.getElementById("mini-upload-trigger");
92
+ dom.miniSendBtn = document.getElementById("mini-send-button");
93
+ dom.miniSpinner = document.getElementById("mini-spinner");
94
+ dom.fileUploader = document.getElementById("file-uploader");
95
+ dom.shelfList = document.getElementById("shelf-list");
96
+ dom.dropZone = document.getElementById("drop-zone");
97
+ dom.menuNewChat = document.getElementById("menu-new-chat");
98
+ dom.clearChatBtn = document.getElementById("clear-chat-button");
99
+ dom.recipeChips = document.querySelectorAll(".recipe-chip");
100
+
101
  // 1. Connect Gradio Client in background (Non-blocking)
102
  Client.connect(window.location.origin)
103
  .then(app => {
 
329
 
330
  // Load Cookbook Showcase Recipes
331
  function loadRecipe(recipeType) {
 
332
  STATE.uploadedFiles = [];
 
333
  let promptText = "";
334
 
335
+ if (recipeType === "landscape") {
336
+ promptText = "Analyze this landscape photograph. Describe the lighting, composition, colors, and the general mood of the environment shown.";
337
  STATE.uploadedFiles.push({
338
+ id: "recipe-landscape",
339
+ name: "nature_landscape.jpg",
340
+ type: "image/jpeg",
341
+ size: "0.15 MB",
342
+ base64: "https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?auto=format&fit=crop&w=800&q=80"
343
  });
344
+ } else if (recipeType === "wildlife") {
345
+ promptText = "Describe the subject in this video, its actions, the environment it's in, and compile a second-by-second activity log of what happens.";
346
  STATE.uploadedFiles.push({
347
+ id: "recipe-wildlife",
348
+ name: "wildlife_clip.mp4",
349
  type: "video/mp4",
350
+ size: "0.68 MB",
351
+ base64: "https://www.w3schools.com/html/mov_bbb.mp4"
352
  });
353
  }
354
 
 
507
  } else {
508
  attachmentsHtml += `
509
  <div class="bubble-attachment-card">
510
+ <video src="${file.base64}" controls preload="metadata"></video>
511
  <div class="bubble-attachment-label">VIDEO</div>
512
  </div>
513
  `;
 
666
  }
667
 
668
  // Initialise application when DOM is fully set up
669
+ if (document.readyState === "loading") {
670
+ window.addEventListener("DOMContentLoaded", initializeApp);
671
+ } else {
672
+ initializeApp();
673
+ }
static/index.html CHANGED
@@ -14,7 +14,7 @@
14
  <!-- Marked.js for Markdown Parsing -->
15
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
16
  <!-- Custom Style Sheet -->
17
- <link rel="stylesheet" href="/static/style.css">
18
  </head>
19
  <body>
20
  <div class="app-container">
@@ -70,13 +70,13 @@
70
  <div class="showcase-section">
71
  <h3 class="showcase-title">Try these tasks</h3>
72
  <div class="showcase-chips-row">
73
- <div class="recipe-chip" data-recipe="whiteboard">
74
- <span class="chip-icon">🖼️</span>
75
- <span class="chip-text">Analyze Whiteboard Gantt</span>
76
  </div>
77
- <div class="recipe-chip" data-recipe="diagnostic">
78
  <span class="chip-icon">🎬</span>
79
- <span class="chip-text">Diagnose Video Logs</span>
80
  </div>
81
  </div>
82
  </div>
@@ -170,6 +170,6 @@
170
  </div>
171
 
172
  <!-- Gradio Client JS connection -->
173
- <script type="module" src="/static/app.js"></script>
174
  </body>
175
  </html>
 
14
  <!-- Marked.js for Markdown Parsing -->
15
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
16
  <!-- Custom Style Sheet -->
17
+ <link rel="stylesheet" href="/static/style.css?v=3">
18
  </head>
19
  <body>
20
  <div class="app-container">
 
70
  <div class="showcase-section">
71
  <h3 class="showcase-title">Try these tasks</h3>
72
  <div class="showcase-chips-row">
73
+ <div class="recipe-chip" data-recipe="landscape">
74
+ <span class="chip-icon">🌳</span>
75
+ <span class="chip-text">Analyze Landscape Image</span>
76
  </div>
77
+ <div class="recipe-chip" data-recipe="wildlife">
78
  <span class="chip-icon">🎬</span>
79
+ <span class="chip-text">Analyze Wildlife Video</span>
80
  </div>
81
  </div>
82
  </div>
 
170
  </div>
171
 
172
  <!-- Gradio Client JS connection -->
173
+ <script type="module" src="/static/app.js?v=4"></script>
174
  </body>
175
  </html>