Paar, F. (Ferdinand) commited on
Commit
90fb67f
·
1 Parent(s): 7d10b52

thubnail filled and layer head box next to each other

Browse files
Files changed (1) hide show
  1. frontend/script.js +5 -26
frontend/script.js CHANGED
@@ -13,36 +13,15 @@ document.getElementById('textForm').addEventListener('submit', async (e) => {
13
  if (!response.ok) {
14
  throw new Error('Network response was not ok');
15
  }
16
-
17
  const data = await response.json();
18
 
19
- console.log("Received Data:", data); // Debugging output
20
-
21
- // Check if tokens and attention exist
22
- if (!data.tokens || !data.attention) {
23
- console.error("Error: Missing tokens or attention data.");
24
- document.getElementById('output').innerText = 'Error: Missing tokens or attention data.';
25
- return;
26
- }
27
-
28
- // Ensure the thumbnail container is available
29
- const container = document.getElementById("thumbnailContainer");
30
- if (!container) {
31
- console.error("Error: #thumbnailContainer not found in DOM.");
32
- return;
33
- }
34
-
35
- container.innerHTML = "";
36
-
37
  displayHoverTokens(data, 0, 0);
 
38
  renderModelView(data);
39
-
40
- setTimeout(() => {
41
- createFirstThumbnail(data);
42
- }, 100); // Short delay to prevent conflicts
43
-
44
  } catch (error) {
45
- console.error("Error:", error);
46
  document.getElementById('output').innerText = 'Error processing text.';
47
  }
48
  });
@@ -174,7 +153,7 @@ function createAttentionThumbnail(data, layerIdx, headIdx) {
174
 
175
  const maxLineWidth = 4;
176
  const maxOpacity = 0.8;
177
- const xRight = width - 10;
178
 
179
  // Create a thumbnail container using D3.
180
  const thumbnail = d3.select(document.createElement("div"))
 
13
  if (!response.ok) {
14
  throw new Error('Network response was not ok');
15
  }
 
16
  const data = await response.json();
17
 
18
+ // Use data.tokens and data.attention from your POST response
19
+ // displayOutput(data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  displayHoverTokens(data, 0, 0);
21
+ // Changed call here to pass the entire data object
22
  renderModelView(data);
 
 
 
 
 
23
  } catch (error) {
24
+ console.error('Error:', error);
25
  document.getElementById('output').innerText = 'Error processing text.';
26
  }
27
  });
 
153
 
154
  const maxLineWidth = 4;
155
  const maxOpacity = 0.8;
156
+ const xRight = width - padding;
157
 
158
  // Create a thumbnail container using D3.
159
  const thumbnail = d3.select(document.createElement("div"))