chansung commited on
Commit
50e7067
·
verified ·
1 Parent(s): 013949c

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +24 -0
  2. ui-temp.html +101 -61
README.md CHANGED
@@ -227,3 +227,27 @@ $ python main.py # or gradio main.py
227
 
228
  # Acknowledgments
229
  This is a project built during the Vertex sprints held by Google's ML Developer Programs team. We are thankful to be granted good amount of GCP credits to do this project.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
 
228
  # Acknowledgments
229
  This is a project built during the Vertex sprints held by Google's ML Developer Programs team. We are thankful to be granted good amount of GCP credits to do this project.
230
+ # AdaptSum
231
+
232
+ AdaptSum stands for Adaptive Summarization. This project focuses on developing an LLM-powered system for dynamic summarization. Instead of generating entirely new summaries with each update, the system intelligently identifies and modifies only the necessary parts of the existing summary. This approach aims to create a more efficient and fluid summarization process within a continuous chat interaction with an LLM.
233
+
234
+ # Instructions
235
+
236
+ 1. Install dependencies
237
+ ```shell
238
+ $ pip install requirements.txt
239
+ ```
240
+
241
+ 2. Setup Gemini API Key
242
+ ```shell
243
+ $ export GEMINI_API_KEY=xxxxx
244
+ ```
245
+ > note that GEMINI API KEY should be obtained from Google AI Studio. Vertex AI is not supported at the moment (this is because Gemini SDK does not provide file uploading functionality for Vertex AI usage now).
246
+
247
+ 3. Run Gradio app
248
+ ```shell
249
+ $ python main.py # or gradio main.py
250
+ ```
251
+
252
+ # Acknowledgments
253
+ This is a project built during the Vertex sprints held by Google's ML Developer Programs team. We are thankful to be granted good amount of GCP credits to do this project.
ui-temp.html CHANGED
@@ -22,14 +22,19 @@
22
  display: flex;
23
  width: 100vw;
24
  height: 100vh;
 
25
  }
26
- /* Left Navigation Bar for Chat History */
27
  .nav-bar {
28
- width: 250px;
29
  background: #ffffff;
30
  padding: 20px;
31
  box-shadow: 2px 0 12px rgba(0,0,0,0.1);
32
  overflow-y: auto;
 
 
 
 
33
  }
34
  .nav-bar h3 {
35
  margin-top: 0;
@@ -47,8 +52,8 @@
47
  border-radius: 8px;
48
  cursor: pointer;
49
  display: flex;
50
- justify-content: space-between;
51
  align-items: center;
 
52
  transition: background 0.3s;
53
  font-size: 1.1em;
54
  }
@@ -57,12 +62,29 @@
57
  background: #667eea;
58
  color: #fff;
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  .nav-bar li button.remove-session {
61
  background: transparent;
62
  border: none;
63
  color: inherit;
64
  font-size: 1em;
65
  cursor: pointer;
 
66
  }
67
  .new-session-btn {
68
  width: 100%;
@@ -86,33 +108,22 @@
86
  flex-direction: column;
87
  overflow: hidden;
88
  position: relative;
 
89
  }
90
- /* Top Buttons for Overlays */
91
- .top-buttons {
92
  position: absolute;
93
  top: 20px;
94
- left: 50%;
95
- transform: translateX(-50%);
96
- display: flex;
97
- gap: 10px;
98
- z-index: 15;
99
- }
100
- .top-button {
101
- height: 40px;
102
  background: #667eea;
103
  color: #fff;
104
  border: none;
105
- border-radius: 20px;
 
 
106
  cursor: pointer;
107
- box-shadow: 0 2px 6px rgba(0,0,0,0.2);
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- font-size: 1.1em;
112
- text-transform: uppercase;
113
- padding: 0 20px;
114
  }
115
- .top-button:hover { background: #556cd6; }
116
  /* Turn Label */
117
  #turnLabel {
118
  position: absolute;
@@ -288,7 +299,7 @@
288
  }
289
  .input-container button:hover { background: #556cd6; }
290
  #fileInput { display: none; }
291
- /* Summary Overlay Panel (Per‑Session) */
292
  #summaryOverlay {
293
  position: fixed;
294
  top: 0;
@@ -338,7 +349,6 @@
338
  overflow-y: auto;
339
  flex: 1;
340
  }
341
- /* Summary content now displays rendered markdown */
342
  /* Settings Overlay Panel (Per‑Session) */
343
  #settingsOverlay {
344
  position: fixed;
@@ -406,7 +416,6 @@
406
  .input-container { padding: 15px; }
407
  .input-row { flex-direction: column; gap: 10px; }
408
  .input-container button { width: 100%; }
409
- .top-button { font-size: 1em; height: 40px; padding: 0 20px; }
410
  #summaryOverlay, #settingsOverlay { width: 80%; }
411
  }
412
  </style>
@@ -414,17 +423,15 @@
414
  <body>
415
  <div class="app-container">
416
  <!-- Left Nav Bar for Chat History & Session Management -->
417
- <div class="nav-bar">
418
  <h3>Chat History</h3>
419
  <ul id="sessionList"></ul>
420
  <button class="new-session-btn" id="newSessionBtn">New Chat</button>
421
  </div>
422
  <!-- Main Chat Wrapper -->
423
  <div class="chat-wrapper">
424
- <div class="top-buttons">
425
- <button id="summaryBtn" class="top-button">Summary</button>
426
- <button id="settingsBtn" class="top-button">Settings</button>
427
- </div>
428
  <!-- Turn Label -->
429
  <div id="turnLabel">Turn: 0/0</div>
430
  <div class="carousel-wrapper">
@@ -519,16 +526,59 @@
519
  renderCurrentSession();
520
  }
521
 
522
- // Render the left nav bar session list
523
  function renderSessionList() {
524
  const sessionList = document.getElementById('sessionList');
525
  sessionList.innerHTML = "";
526
  sessions.forEach((session, index) => {
527
  const li = document.createElement('li');
528
- li.textContent = session.name;
529
- li.dataset.index = index;
530
- if (index === currentSessionIndex) li.classList.add('active');
531
- // Remove button for each session
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
532
  const removeBtn = document.createElement('button');
533
  removeBtn.textContent = "×";
534
  removeBtn.className = "remove-session";
@@ -537,12 +587,14 @@
537
  removeSession(index);
538
  });
539
  li.appendChild(removeBtn);
 
540
  li.addEventListener('click', () => {
541
  currentSessionIndex = index;
542
  currentCardIndex = 0;
543
  renderSessionList();
544
  renderCurrentSession();
545
  });
 
546
  sessionList.appendChild(li);
547
  });
548
  }
@@ -722,19 +774,10 @@
722
 
723
  // ----------------- Summary Overlay (Per‑Session) -----------------
724
  const summaryOverlay = document.getElementById('summaryOverlay');
725
- const summaryBtn = document.getElementById('summaryBtn');
726
  const closeSummaryBtn = document.getElementById('closeSummaryBtn');
727
  const summaryContent = document.getElementById('summaryContent');
728
  const downloadSummaryBtn = document.getElementById('downloadSummary');
729
 
730
- summaryBtn.addEventListener('click', (e) => {
731
- // Close settings if open
732
- settingsOverlay.classList.remove('active');
733
- // Load current session's summary and render as markdown
734
- summaryContent.innerHTML = marked.parse(sessions[currentSessionIndex].summary);
735
- summaryOverlay.classList.toggle('active');
736
- e.stopPropagation();
737
- });
738
  closeSummaryBtn.addEventListener('click', () => { summaryOverlay.classList.remove('active'); });
739
  downloadSummaryBtn.addEventListener('click', () => {
740
  const blob = new Blob([sessions[currentSessionIndex].summary], { type: "text/markdown" });
@@ -748,7 +791,6 @@
748
 
749
  // ----------------- Settings Overlay (Per‑Session) -----------------
750
  const settingsOverlay = document.getElementById('settingsOverlay');
751
- const settingsBtn = document.getElementById('settingsBtn');
752
  const closeSettingsBtn = document.getElementById('closeSettingsBtn');
753
  const temperatureInput = document.getElementById('temperature');
754
  const temperatureValue = document.getElementById('temperatureValue');
@@ -756,18 +798,6 @@
756
  const personaSelect = document.getElementById('persona');
757
  const saveSettingsBtn = document.getElementById('saveSettings');
758
 
759
- settingsBtn.addEventListener('click', (e) => {
760
- // Close summary if open
761
- summaryOverlay.classList.remove('active');
762
- // Load current session's settings
763
- const settings = sessions[currentSessionIndex].settings;
764
- temperatureInput.value = settings.temperature;
765
- temperatureValue.textContent = settings.temperature;
766
- maxTokensInput.value = settings.maxTokens;
767
- personaSelect.value = settings.persona;
768
- settingsOverlay.classList.toggle('active');
769
- e.stopPropagation();
770
- });
771
  closeSettingsBtn.addEventListener('click', () => { settingsOverlay.classList.remove('active'); });
772
  temperatureInput.addEventListener('input', () => {
773
  temperatureValue.textContent = temperatureInput.value;
@@ -785,13 +815,11 @@
785
  // ----------------- Auto-Dismiss Overlays on Outside Click -----------------
786
  document.addEventListener('click', (e) => {
787
  if (summaryOverlay.classList.contains('active') &&
788
- !summaryOverlay.contains(e.target) &&
789
- e.target !== summaryBtn) {
790
  summaryOverlay.classList.remove('active');
791
  }
792
  if (settingsOverlay.classList.contains('active') &&
793
- !settingsOverlay.contains(e.target) &&
794
- e.target !== settingsBtn) {
795
  settingsOverlay.classList.remove('active');
796
  }
797
  });
@@ -812,6 +840,18 @@
812
  }
813
  });
814
 
 
 
 
 
 
 
 
 
 
 
 
 
815
  // ----------------- Initialization -----------------
816
  initSessions();
817
  </script>
 
22
  display: flex;
23
  width: 100vw;
24
  height: 100vh;
25
+ transition: all 0.3s ease;
26
  }
27
+ /* Left Navigation Bar */
28
  .nav-bar {
29
+ width: 300px;
30
  background: #ffffff;
31
  padding: 20px;
32
  box-shadow: 2px 0 12px rgba(0,0,0,0.1);
33
  overflow-y: auto;
34
+ transition: width 0.3s ease, padding 0.3s ease;
35
+ }
36
+ .nav-bar.hidden {
37
+ display: none;
38
  }
39
  .nav-bar h3 {
40
  margin-top: 0;
 
52
  border-radius: 8px;
53
  cursor: pointer;
54
  display: flex;
 
55
  align-items: center;
56
+ justify-content: space-between;
57
  transition: background 0.3s;
58
  font-size: 1.1em;
59
  }
 
62
  background: #667eea;
63
  color: #fff;
64
  }
65
+ .session-actions {
66
+ display: inline-flex;
67
+ gap: 5px;
68
+ margin-left: 10px;
69
+ }
70
+ .session-summary-btn,
71
+ .session-settings-btn {
72
+ background: transparent;
73
+ border: none;
74
+ cursor: pointer;
75
+ font-size: 1.2em;
76
+ }
77
+ .session-summary-btn:hover,
78
+ .session-settings-btn:hover {
79
+ color: #667eea;
80
+ }
81
  .nav-bar li button.remove-session {
82
  background: transparent;
83
  border: none;
84
  color: inherit;
85
  font-size: 1em;
86
  cursor: pointer;
87
+ margin-left: auto;
88
  }
89
  .new-session-btn {
90
  width: 100%;
 
108
  flex-direction: column;
109
  overflow: hidden;
110
  position: relative;
111
+ transition: width 0.3s ease;
112
  }
113
+ /* Hamburger Button inside Chat Wrapper */
114
+ #hamburgerBtn {
115
  position: absolute;
116
  top: 20px;
117
+ left: 20px;
 
 
 
 
 
 
 
118
  background: #667eea;
119
  color: #fff;
120
  border: none;
121
+ padding: 10px;
122
+ font-size: 1.4em;
123
+ border-radius: 4px;
124
  cursor: pointer;
125
+ z-index: 20;
 
 
 
 
 
 
126
  }
 
127
  /* Turn Label */
128
  #turnLabel {
129
  position: absolute;
 
299
  }
300
  .input-container button:hover { background: #556cd6; }
301
  #fileInput { display: none; }
302
+ /* Summary Overlay Panel (Per‑Session, rendered markdown) */
303
  #summaryOverlay {
304
  position: fixed;
305
  top: 0;
 
349
  overflow-y: auto;
350
  flex: 1;
351
  }
 
352
  /* Settings Overlay Panel (Per‑Session) */
353
  #settingsOverlay {
354
  position: fixed;
 
416
  .input-container { padding: 15px; }
417
  .input-row { flex-direction: column; gap: 10px; }
418
  .input-container button { width: 100%; }
 
419
  #summaryOverlay, #settingsOverlay { width: 80%; }
420
  }
421
  </style>
 
423
  <body>
424
  <div class="app-container">
425
  <!-- Left Nav Bar for Chat History & Session Management -->
426
+ <div class="nav-bar" id="navBar">
427
  <h3>Chat History</h3>
428
  <ul id="sessionList"></ul>
429
  <button class="new-session-btn" id="newSessionBtn">New Chat</button>
430
  </div>
431
  <!-- Main Chat Wrapper -->
432
  <div class="chat-wrapper">
433
+ <!-- Hamburger Button (placed inside chat area) -->
434
+ <button id="hamburgerBtn">&#9776;</button>
 
 
435
  <!-- Turn Label -->
436
  <div id="turnLabel">Turn: 0/0</div>
437
  <div class="carousel-wrapper">
 
526
  renderCurrentSession();
527
  }
528
 
529
+ // Render the left nav bar session list with icons
530
  function renderSessionList() {
531
  const sessionList = document.getElementById('sessionList');
532
  sessionList.innerHTML = "";
533
  sessions.forEach((session, index) => {
534
  const li = document.createElement('li');
535
+
536
+ // Session name
537
+ const nameSpan = document.createElement('span');
538
+ nameSpan.textContent = session.name;
539
+ li.appendChild(nameSpan);
540
+
541
+ // Action icons container
542
+ const actionsDiv = document.createElement('div');
543
+ actionsDiv.className = "session-actions";
544
+
545
+ const summaryBtn = document.createElement('button');
546
+ summaryBtn.className = "session-summary-btn";
547
+ summaryBtn.innerHTML = "📄";
548
+ summaryBtn.addEventListener('click', (e) => {
549
+ e.stopPropagation();
550
+ currentSessionIndex = index;
551
+ renderSessionList();
552
+ renderCurrentSession();
553
+ // Open summary overlay for this session
554
+ document.getElementById('summaryContent').innerHTML = marked.parse(sessions[currentSessionIndex].summary);
555
+ summaryOverlay.classList.add('active');
556
+ settingsOverlay.classList.remove('active');
557
+ });
558
+ actionsDiv.appendChild(summaryBtn);
559
+
560
+ const settingsBtn = document.createElement('button');
561
+ settingsBtn.className = "session-settings-btn";
562
+ settingsBtn.innerHTML = "⚙";
563
+ settingsBtn.addEventListener('click', (e) => {
564
+ e.stopPropagation();
565
+ currentSessionIndex = index;
566
+ renderSessionList();
567
+ renderCurrentSession();
568
+ // Open settings overlay for this session
569
+ const settings = sessions[currentSessionIndex].settings;
570
+ temperatureInput.value = settings.temperature;
571
+ temperatureValue.textContent = settings.temperature;
572
+ maxTokensInput.value = settings.maxTokens;
573
+ personaSelect.value = settings.persona;
574
+ settingsOverlay.classList.add('active');
575
+ summaryOverlay.classList.remove('active');
576
+ });
577
+ actionsDiv.appendChild(settingsBtn);
578
+
579
+ li.appendChild(actionsDiv);
580
+
581
+ // Remove session button
582
  const removeBtn = document.createElement('button');
583
  removeBtn.textContent = "×";
584
  removeBtn.className = "remove-session";
 
587
  removeSession(index);
588
  });
589
  li.appendChild(removeBtn);
590
+
591
  li.addEventListener('click', () => {
592
  currentSessionIndex = index;
593
  currentCardIndex = 0;
594
  renderSessionList();
595
  renderCurrentSession();
596
  });
597
+ if (index === currentSessionIndex) li.classList.add('active');
598
  sessionList.appendChild(li);
599
  });
600
  }
 
774
 
775
  // ----------------- Summary Overlay (Per‑Session) -----------------
776
  const summaryOverlay = document.getElementById('summaryOverlay');
 
777
  const closeSummaryBtn = document.getElementById('closeSummaryBtn');
778
  const summaryContent = document.getElementById('summaryContent');
779
  const downloadSummaryBtn = document.getElementById('downloadSummary');
780
 
 
 
 
 
 
 
 
 
781
  closeSummaryBtn.addEventListener('click', () => { summaryOverlay.classList.remove('active'); });
782
  downloadSummaryBtn.addEventListener('click', () => {
783
  const blob = new Blob([sessions[currentSessionIndex].summary], { type: "text/markdown" });
 
791
 
792
  // ----------------- Settings Overlay (Per‑Session) -----------------
793
  const settingsOverlay = document.getElementById('settingsOverlay');
 
794
  const closeSettingsBtn = document.getElementById('closeSettingsBtn');
795
  const temperatureInput = document.getElementById('temperature');
796
  const temperatureValue = document.getElementById('temperatureValue');
 
798
  const personaSelect = document.getElementById('persona');
799
  const saveSettingsBtn = document.getElementById('saveSettings');
800
 
 
 
 
 
 
 
 
 
 
 
 
 
801
  closeSettingsBtn.addEventListener('click', () => { settingsOverlay.classList.remove('active'); });
802
  temperatureInput.addEventListener('input', () => {
803
  temperatureValue.textContent = temperatureInput.value;
 
815
  // ----------------- Auto-Dismiss Overlays on Outside Click -----------------
816
  document.addEventListener('click', (e) => {
817
  if (summaryOverlay.classList.contains('active') &&
818
+ !summaryOverlay.contains(e.target)) {
 
819
  summaryOverlay.classList.remove('active');
820
  }
821
  if (settingsOverlay.classList.contains('active') &&
822
+ !settingsOverlay.contains(e.target)) {
 
823
  settingsOverlay.classList.remove('active');
824
  }
825
  });
 
840
  }
841
  });
842
 
843
+ // ----------------- Hamburger Button (Toggle Nav Bar) -----------------
844
+ const hamburgerBtn = document.getElementById('hamburgerBtn');
845
+ const navBar = document.getElementById('navBar');
846
+ hamburgerBtn.addEventListener('click', (e) => {
847
+ e.stopPropagation();
848
+ if (navBar.classList.contains('hidden')) {
849
+ navBar.classList.remove('hidden');
850
+ } else {
851
+ navBar.classList.add('hidden');
852
+ }
853
+ });
854
+
855
  // ----------------- Initialization -----------------
856
  initSessions();
857
  </script>