seawolf2357 commited on
Commit
419b0b7
·
verified ·
1 Parent(s): 818076e

Update 백업-rag버전--문제존재-app.py

Browse files
Files changed (1) hide show
  1. 백업-rag버전--문제존재-app.py +195 -87
백업-rag버전--문제존재-app.py CHANGED
@@ -71,6 +71,7 @@ HTML_CONTENT = """<!DOCTYPE html>
71
  --hover-color: #8a5cf6;
72
  --memory-color: #4a9eff;
73
  --doc-color: #28a745;
 
74
  }
75
  body {
76
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
@@ -83,6 +84,96 @@ HTML_CONTENT = """<!DOCTYPE html>
83
  flex-direction: column;
84
  overflow: hidden;
85
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  .container {
87
  max-width: 1400px;
88
  margin: 0 auto;
@@ -94,6 +185,11 @@ HTML_CONTENT = """<!DOCTYPE html>
94
  height: 100vh;
95
  box-sizing: border-box;
96
  overflow: hidden;
 
 
 
 
 
97
  }
98
  .header {
99
  text-align: center;
@@ -317,37 +413,6 @@ HTML_CONTENT = """<!DOCTYPE html>
317
  font-size: 14px;
318
  color: var(--text-color);
319
  }
320
- /* History section */
321
- .history-section {
322
- background-color: var(--card-bg);
323
- border-radius: 12px;
324
- padding: 20px;
325
- border: 1px solid var(--border-color);
326
- max-height: 200px;
327
- overflow-y: auto;
328
- }
329
- .history-item {
330
- padding: 10px;
331
- margin-bottom: 10px;
332
- background-color: var(--dark-bg);
333
- border-radius: 6px;
334
- cursor: pointer;
335
- transition: background-color 0.2s;
336
- }
337
- .history-item:hover {
338
- background-color: var(--hover-color);
339
- }
340
- .history-date {
341
- font-size: 12px;
342
- color: #888;
343
- }
344
- .history-preview {
345
- font-size: 14px;
346
- margin-top: 5px;
347
- overflow: hidden;
348
- text-overflow: ellipsis;
349
- white-space: nowrap;
350
- }
351
  /* Text inputs */
352
  .text-input-section {
353
  margin-top: 15px;
@@ -470,8 +535,31 @@ HTML_CONTENT = """<!DOCTYPE html>
470
  .sidebar {
471
  width: 300px;
472
  }
 
 
 
 
 
 
473
  }
474
  @media (max-width: 768px) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  .main-content {
476
  flex-direction: column;
477
  }
@@ -645,74 +733,85 @@ HTML_CONTENT = """<!DOCTYPE html>
645
 
646
  <body>
647
  <div id="error-toast" class="toast"></div>
648
- <div class="container">
649
- <div class="header">
650
- <div class="logo">
651
- <div class="user-avatar" id="user-avatar">👤</div>
652
- <h1>Personal AI Assistant</h1>
 
 
 
653
  </div>
654
- <div class="status-indicator">
655
- <div id="status-dot" class="status-dot disconnected"></div>
656
- <span id="status-text">연결 대기 중</span>
657
  </div>
658
  </div>
659
 
660
- <div class="main-content">
661
- <div class="sidebar">
662
- <div class="settings-section">
663
- <h3 style="margin: 0 0 15px 0; color: var(--primary-color);">설정</h3>
664
- <div class="settings-grid">
665
- <div class="setting-item">
666
- <span class="setting-label">웹 검색</span>
667
- <div id="search-toggle" class="toggle-switch">
668
- <div class="toggle-slider"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  </div>
670
  </div>
 
 
 
 
671
  </div>
672
- <div class="text-input-section">
673
- <label for="user-name" class="setting-label">사용자 이름:</label>
674
- <input type="text" id="user-name" placeholder="이름을 입력하세요..." />
 
 
 
 
 
 
 
 
 
 
675
  </div>
676
- </div>
677
-
678
- <div class="document-section">
679
- <h3 style="margin: 0 0 15px 0; color: var(--doc-color);">문서 관리</h3>
680
- <div class="file-upload-area" id="file-upload-area">
681
- <p>📄 파일을 드래그하거나 클릭하여 업로드</p>
682
- <p style="font-size: 12px; color: #888;">PDF, TXT, CSV 지원</p>
683
  </div>
684
- <input type="file" id="file-input" accept=".pdf,.txt,.csv" multiple />
685
- <div class="memory-type-selector">
686
- <button class="memory-type-btn active" data-type="temporary">단기 기억</button>
687
- <button class="memory-type-btn" data-type="permanent">영구 기억</button>
688
  </div>
689
- <div class="document-list" id="document-list"></div>
690
- </div>
691
-
692
- <div class="memory-section">
693
- <h3 style="margin: 0 0 15px 0; color: var(--memory-color);">기억된 정보</h3>
694
- <div id="memory-list"></div>
695
- </div>
696
-
697
- <div class="history-section">
698
- <h3 style="margin: 0 0 15px 0; color: var(--primary-color);">대화 기록</h3>
699
- <div id="history-list"></div>
700
  </div>
701
 
702
- <div class="controls">
703
- <button id="start-button">대화 시작</button>
704
- <button id="end-session-button" style="display: none;">기억 업데이트</button>
705
- </div>
706
- </div>
707
-
708
- <div class="chat-section">
709
- <div class="chat-container">
710
- <h3 style="margin: 0 0 15px 0; color: var(--primary-color);">대화</h3>
711
- <div class="chat-messages" id="chat-messages"></div>
712
- <div class="text-input-section" style="margin-top: 10px;">
713
- <div style="display: flex; gap: 10px;">
714
- <input type="text" id="text-input" placeholder="텍스트 메시지를 입력하세요..." style="flex-grow: 1;" />
715
- <button id="send-button" style="display: none;">전송</button>
716
  </div>
717
  </div>
718
  </div>
@@ -747,12 +846,18 @@ HTML_CONTENT = """<!DOCTYPE html>
747
  const fileUploadArea = document.getElementById('file-upload-area');
748
  const documentList = document.getElementById('document-list');
749
  const memoryTypeBtns = document.querySelectorAll('.memory-type-btn');
 
750
  let audioLevel = 0;
751
  let animationFrame;
752
  let audioContext, analyser, audioSource;
753
  let dataChannel = null;
754
  let isVoiceActive = false;
755
 
 
 
 
 
 
756
  // Initialize user name
757
  userNameInput.value = userName;
758
  if (userName) {
@@ -984,6 +1089,9 @@ HTML_CONTENT = """<!DOCTYPE html>
984
  messages.forEach(msg => {
985
  addMessage(msg.role, msg.content, false);
986
  });
 
 
 
987
  } catch (error) {
988
  console.error('Failed to load conversation:', error);
989
  }
 
71
  --hover-color: #8a5cf6;
72
  --memory-color: #4a9eff;
73
  --doc-color: #28a745;
74
+ --sidebar-width: 280px;
75
  }
76
  body {
77
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, sans-serif;
 
84
  flex-direction: column;
85
  overflow: hidden;
86
  }
87
+ .app-wrapper {
88
+ display: flex;
89
+ height: 100vh;
90
+ position: relative;
91
+ }
92
+ /* Left sidebar for history */
93
+ .history-sidebar {
94
+ position: fixed;
95
+ left: 0;
96
+ top: 0;
97
+ height: 100vh;
98
+ width: var(--sidebar-width);
99
+ background-color: var(--card-bg);
100
+ border-right: 1px solid var(--border-color);
101
+ transform: translateX(calc(-1 * var(--sidebar-width) + 40px));
102
+ transition: transform 0.3s ease;
103
+ z-index: 100;
104
+ display: flex;
105
+ box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
106
+ }
107
+ .history-sidebar.expanded {
108
+ transform: translateX(0);
109
+ }
110
+ .history-content {
111
+ flex-grow: 1;
112
+ overflow-y: auto;
113
+ padding: 20px;
114
+ padding-right: 10px;
115
+ }
116
+ .history-toggle {
117
+ position: absolute;
118
+ right: 0;
119
+ top: 0;
120
+ width: 40px;
121
+ height: 100%;
122
+ background-color: var(--card-bg);
123
+ border-left: 1px solid var(--border-color);
124
+ cursor: pointer;
125
+ display: flex;
126
+ align-items: center;
127
+ justify-content: center;
128
+ transition: background-color 0.3s;
129
+ }
130
+ .history-toggle:hover {
131
+ background-color: var(--hover-color);
132
+ }
133
+ .history-toggle-icon {
134
+ font-size: 20px;
135
+ transition: transform 0.3s;
136
+ }
137
+ .history-sidebar.expanded .history-toggle-icon {
138
+ transform: rotate(180deg);
139
+ }
140
+ .history-header {
141
+ margin: 0 0 20px 0;
142
+ padding-bottom: 15px;
143
+ border-bottom: 1px solid var(--border-color);
144
+ }
145
+ .history-header h3 {
146
+ margin: 0;
147
+ color: var(--primary-color);
148
+ font-size: 18px;
149
+ }
150
+ .history-item {
151
+ padding: 12px;
152
+ margin-bottom: 10px;
153
+ background-color: var(--dark-bg);
154
+ border-radius: 8px;
155
+ cursor: pointer;
156
+ transition: all 0.2s;
157
+ border: 1px solid transparent;
158
+ }
159
+ .history-item:hover {
160
+ background-color: rgba(111, 66, 193, 0.1);
161
+ border-color: var(--primary-color);
162
+ transform: translateX(5px);
163
+ }
164
+ .history-date {
165
+ font-size: 12px;
166
+ color: #888;
167
+ margin-bottom: 5px;
168
+ }
169
+ .history-preview {
170
+ font-size: 14px;
171
+ overflow: hidden;
172
+ text-overflow: ellipsis;
173
+ white-space: nowrap;
174
+ color: var(--text-color);
175
+ }
176
+ /* Main container adjustment */
177
  .container {
178
  max-width: 1400px;
179
  margin: 0 auto;
 
185
  height: 100vh;
186
  box-sizing: border-box;
187
  overflow: hidden;
188
+ margin-left: 40px; /* Space for collapsed sidebar */
189
+ transition: margin-left 0.3s ease;
190
+ }
191
+ .history-sidebar.expanded ~ .container {
192
+ margin-left: var(--sidebar-width);
193
  }
194
  .header {
195
  text-align: center;
 
413
  font-size: 14px;
414
  color: var(--text-color);
415
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  /* Text inputs */
417
  .text-input-section {
418
  margin-top: 15px;
 
535
  .sidebar {
536
  width: 300px;
537
  }
538
+ .history-sidebar {
539
+ width: 250px;
540
+ }
541
+ :root {
542
+ --sidebar-width: 250px;
543
+ }
544
  }
545
  @media (max-width: 768px) {
546
+ .app-wrapper {
547
+ flex-direction: column;
548
+ }
549
+ .history-sidebar {
550
+ position: static;
551
+ width: 100%;
552
+ height: 200px;
553
+ transform: none;
554
+ border-right: none;
555
+ border-bottom: 1px solid var(--border-color);
556
+ }
557
+ .history-sidebar.expanded {
558
+ transform: none;
559
+ }
560
+ .container {
561
+ margin-left: 0 !important;
562
+ }
563
  .main-content {
564
  flex-direction: column;
565
  }
 
733
 
734
  <body>
735
  <div id="error-toast" class="toast"></div>
736
+ <div class="app-wrapper">
737
+ <!-- History Sidebar -->
738
+ <div class="history-sidebar" id="history-sidebar">
739
+ <div class="history-content">
740
+ <div class="history-header">
741
+ <h3>📋 대화 기록</h3>
742
+ </div>
743
+ <div id="history-list"></div>
744
  </div>
745
+ <div class="history-toggle" onclick="toggleHistorySidebar()">
746
+ <span class="history-toggle-icon">▶</span>
 
747
  </div>
748
  </div>
749
 
750
+ <!-- Main Container -->
751
+ <div class="container">
752
+ <div class="header">
753
+ <div class="logo">
754
+ <div class="user-avatar" id="user-avatar">👤</div>
755
+ <h1>Personal AI Assistant</h1>
756
+ </div>
757
+ <div class="status-indicator">
758
+ <div id="status-dot" class="status-dot disconnected"></div>
759
+ <span id="status-text">연결 대기 중</span>
760
+ </div>
761
+ </div>
762
+
763
+ <div class="main-content">
764
+ <div class="sidebar">
765
+ <div class="settings-section">
766
+ <h3 style="margin: 0 0 15px 0; color: var(--primary-color);">설정</h3>
767
+ <div class="settings-grid">
768
+ <div class="setting-item">
769
+ <span class="setting-label">웹 검색</span>
770
+ <div id="search-toggle" class="toggle-switch">
771
+ <div class="toggle-slider"></div>
772
+ </div>
773
  </div>
774
  </div>
775
+ <div class="text-input-section">
776
+ <label for="user-name" class="setting-label">사용자 이름:</label>
777
+ <input type="text" id="user-name" placeholder="이름을 입력하세요..." />
778
+ </div>
779
  </div>
780
+
781
+ <div class="document-section">
782
+ <h3 style="margin: 0 0 15px 0; color: var(--doc-color);">문서 관리</h3>
783
+ <div class="file-upload-area" id="file-upload-area">
784
+ <p>📄 파일을 드래그하거나 클릭하여 업로드</p>
785
+ <p style="font-size: 12px; color: #888;">PDF, TXT, CSV 지원</p>
786
+ </div>
787
+ <input type="file" id="file-input" accept=".pdf,.txt,.csv" multiple />
788
+ <div class="memory-type-selector">
789
+ <button class="memory-type-btn active" data-type="temporary">단기 기억</button>
790
+ <button class="memory-type-btn" data-type="permanent">영구 기억</button>
791
+ </div>
792
+ <div class="document-list" id="document-list"></div>
793
  </div>
794
+
795
+ <div class="memory-section">
796
+ <h3 style="margin: 0 0 15px 0; color: var(--memory-color);">기억된 정보</h3>
797
+ <div id="memory-list"></div>
 
 
 
798
  </div>
799
+
800
+ <div class="controls">
801
+ <button id="start-button">대화 시작</button>
802
+ <button id="end-session-button" style="display: none;">기억 업데이트</button>
803
  </div>
 
 
 
 
 
 
 
 
 
 
 
804
  </div>
805
 
806
+ <div class="chat-section">
807
+ <div class="chat-container">
808
+ <h3 style="margin: 0 0 15px 0; color: var(--primary-color);">대화</h3>
809
+ <div class="chat-messages" id="chat-messages"></div>
810
+ <div class="text-input-section" style="margin-top: 10px;">
811
+ <div style="display: flex; gap: 10px;">
812
+ <input type="text" id="text-input" placeholder="텍스트 메시지를 입력하세요..." style="flex-grow: 1;" />
813
+ <button id="send-button" style="display: none;">전송</button>
814
+ </div>
 
 
 
 
 
815
  </div>
816
  </div>
817
  </div>
 
846
  const fileUploadArea = document.getElementById('file-upload-area');
847
  const documentList = document.getElementById('document-list');
848
  const memoryTypeBtns = document.querySelectorAll('.memory-type-btn');
849
+ const historySidebar = document.getElementById('history-sidebar');
850
  let audioLevel = 0;
851
  let animationFrame;
852
  let audioContext, analyser, audioSource;
853
  let dataChannel = null;
854
  let isVoiceActive = false;
855
 
856
+ // Toggle history sidebar
857
+ function toggleHistorySidebar() {
858
+ historySidebar.classList.toggle('expanded');
859
+ }
860
+
861
  // Initialize user name
862
  userNameInput.value = userName;
863
  if (userName) {
 
1089
  messages.forEach(msg => {
1090
  addMessage(msg.role, msg.content, false);
1091
  });
1092
+
1093
+ // Close sidebar after loading conversation
1094
+ historySidebar.classList.remove('expanded');
1095
  } catch (error) {
1096
  console.error('Failed to load conversation:', error);
1097
  }