beeguy commited on
Commit
fe724e6
·
1 Parent(s): 6edcaaa
Files changed (3) hide show
  1. static/index.html +8 -12
  2. static/script.js +21 -0
  3. static/style.css +28 -0
static/index.html CHANGED
@@ -13,23 +13,19 @@
13
  <main>
14
  <section id="text-gen">
15
  <h1>Chat with your favorite website!</h1>
16
- <p>
17
- Model:
18
- <a href="https://huggingface.co/google/flan-t5-small" rel="noreferrer"
19
- target="_blank">google/flan-t5-small</a>
20
- </p>
21
- <p>Here you can create embeddings from the text you provide. This text should be submitted to the
22
- /embeddings endpoint.</p>
23
- <p>If you have embeddings, you can upload them instead.</p>
24
  <form class="text-gen-form">
25
- <label for="text-gen-input">Text prompt</label>
26
- <input id="text-gen-input" type="text" value="English: Translate There are many ducks. German:" />
27
  <button id="text-gen-submit">Submit</button>
28
  <button id="download-embeddings" type="button">Download Embeddings</button>
29
- <button id="upload-embeddings" type="button">Upload Embeddings</button>
30
- <input type="file" id="file-input" style="display: none;" />
31
  <p class="text-gen-output"></p>
32
  </form>
 
 
 
 
 
33
  </section>
34
  <section id="chat">
35
  <h2>Chat with the Model</h2>
 
13
  <main>
14
  <section id="text-gen">
15
  <h1>Chat with your favorite website!</h1>
16
+ <p>Here you can create a vector storage from the url you provide.</p>
 
 
 
 
 
 
 
17
  <form class="text-gen-form">
18
+ <label for="text-gen-input">The url of the website</label>
19
+ <input id="text-gen-input" type="text" />
20
  <button id="text-gen-submit">Submit</button>
21
  <button id="download-embeddings" type="button">Download Embeddings</button>
 
 
22
  <p class="text-gen-output"></p>
23
  </form>
24
+ <p>If you have embeddings, you can upload them instead.</p>
25
+ <form class="text-gen-form">
26
+ <input type="file" id="file-input" style="display: none;" />
27
+ <button id="upload-embeddings" type="button">Upload Embeddings</button>
28
+ </form>
29
  </section>
30
  <section id="chat">
31
  <h2>Chat with the Model</h2>
static/script.js CHANGED
@@ -8,8 +8,22 @@ const embedText = async (text) => {
8
  return inferJson.embeddings;
9
  };
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  textGenForm.addEventListener('submit', async (event) => {
12
  event.preventDefault();
 
13
 
14
  const textGenInput = document.getElementById('text-gen-input');
15
  const textGenParagraph = document.querySelector('.text-gen-output');
@@ -21,6 +35,8 @@ textGenForm.addEventListener('submit', async (event) => {
21
  updateDownloadButtonState(); // Update button state
22
  } catch (err) {
23
  console.error(err);
 
 
24
  }
25
  });
26
 
@@ -49,6 +65,7 @@ const uploadEmbeddings = () => {
49
  };
50
 
51
  fileInput.addEventListener('change', async (event) => {
 
52
  const file = event.target.files[0];
53
  if (file) {
54
  const reader = new FileReader();
@@ -71,9 +88,13 @@ fileInput.addEventListener('change', async (event) => {
71
  });
72
  } catch (err) {
73
  console.error('Error reading or parsing the file', err);
 
 
74
  }
75
  };
76
  reader.readAsText(file);
 
 
77
  }
78
  });
79
 
 
8
  return inferJson.embeddings;
9
  };
10
 
11
+ const spinnerOverlay = document.createElement('div');
12
+ spinnerOverlay.classList.add('spinner-overlay');
13
+ spinnerOverlay.innerHTML = '<div class="spinner"></div>';
14
+ document.body.appendChild(spinnerOverlay);
15
+
16
+ const showSpinner = () => {
17
+ spinnerOverlay.style.display = 'flex';
18
+ };
19
+
20
+ const hideSpinner = () => {
21
+ spinnerOverlay.style.display = 'none';
22
+ };
23
+
24
  textGenForm.addEventListener('submit', async (event) => {
25
  event.preventDefault();
26
+ showSpinner();
27
 
28
  const textGenInput = document.getElementById('text-gen-input');
29
  const textGenParagraph = document.querySelector('.text-gen-output');
 
35
  updateDownloadButtonState(); // Update button state
36
  } catch (err) {
37
  console.error(err);
38
+ } finally {
39
+ hideSpinner();
40
  }
41
  });
42
 
 
65
  };
66
 
67
  fileInput.addEventListener('change', async (event) => {
68
+ showSpinner();
69
  const file = event.target.files[0];
70
  if (file) {
71
  const reader = new FileReader();
 
88
  });
89
  } catch (err) {
90
  console.error('Error reading or parsing the file', err);
91
+ } finally {
92
+ hideSpinner();
93
  }
94
  };
95
  reader.readAsText(file);
96
+ } else {
97
+ hideSpinner();
98
  }
99
  });
100
 
static/style.css CHANGED
@@ -64,4 +64,32 @@ button {
64
  overflow-y: auto;
65
  resize: none;
66
  border-radius: 3px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
 
64
  overflow-y: auto;
65
  resize: none;
66
  border-radius: 3px;
67
+ }
68
+
69
+ .spinner-overlay {
70
+ position: fixed;
71
+ top: 0;
72
+ left: 0;
73
+ width: 100%;
74
+ height: 100%;
75
+ background: rgba(0, 0, 0, 0.5);
76
+ display: flex;
77
+ justify-content: center;
78
+ align-items: center;
79
+ z-index: 1000;
80
+ display: none; /* Initially hidden */
81
+ }
82
+
83
+ .spinner {
84
+ border: 8px solid rgba(255, 255, 255, 0.3);
85
+ border-top: 8px solid white;
86
+ border-radius: 50%;
87
+ width: 60px;
88
+ height: 60px;
89
+ animation: spin 1s linear infinite;
90
+ }
91
+
92
+ @keyframes spin {
93
+ 0% { transform: rotate(0deg); }
94
+ 100% { transform: rotate(360deg); }
95
  }