felixflier03 commited on
Commit
cf200e4
·
verified ·
1 Parent(s): 92f970e

Update ui_utils.py

Browse files
Files changed (1) hide show
  1. ui_utils.py +177 -217
ui_utils.py CHANGED
@@ -10,227 +10,187 @@ from chatbot_new import IntelligentRAGChatbot, InitializationError
10
  BASE_PATH = os.path.dirname(os.path.abspath(__file__))
11
  VECTOR_STORE_PATH = os.path.join(BASE_PATH, "vector_stores")
12
 
13
- # Diese Funktionen müssen VOR der IntelligentRAGChatbot-Klasse platziert werden
14
  def apply_enhanced_custom_css():
15
- dark_mode = st.checkbox("Dark Mode") # Checkbox für Dark Mode
16
-
17
- background_dark = "#0a1930"
18
- background_light = "#f8fafc" # Hintergrund für Light Mode
19
- text_primary_dark = "#f8fafc"
20
- text_primary_light = "#1e293b" # Textfarbe für Light Mode
21
- surface_dark = "rgba(30, 27, 75, 0.5)"
22
- surface_light = "rgba(248, 250, 252, 0.5)" # Oberfläche für Light Mode
23
-
24
-
25
- if dark_mode: # CSS basierend auf dem Dark Mode Status dynamisch erstellen
26
- bg_color = background_dark
27
- text_color = text_primary_dark
28
- surface_color = surface_dark
29
- else:
30
- bg_color = background_light
31
- text_color = text_primary_light
32
- surface_color = surface_light
33
-
34
-
35
  st.markdown(
36
- f"""
37
- <style>
38
- @import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');
39
-
40
- :root {{
41
- --primary: #06b6d4;
42
- --primary-light: #22d3ee;
43
- --primary-dark: #0891b2;
44
- --background-color: {bg_color}; /* Dynamische Hintergrundfarbe */
45
- --surface: {surface_color}; /* Dynamische Oberflächenfarbe */
46
- --text-primary: {text_color}; /* Dynamische Textfarbe */
47
- --text-secondary: {'#cbd5e1' if dark_mode else '#475569'};
48
- }}
49
-
50
- .stApp {
51
- background: linear-gradient(145deg, var(--background-color) 0%, {'#164e63' if dark_mode else '#e2e8f0'} 100%) !important;
52
- color: var(--text-primary);
53
- font-family: 'Plus Jakarta Sans', sans-serif;
54
- }
55
-
56
- /* Remove default header */
57
- header[data-testid="stHeader"] {
58
- display: none;
59
- }
60
-
61
- /* Clean up sidebar */
62
- section[data-testid="stSidebar"] {
63
- background: linear-gradient(180deg, var(--background-dark) 0%, #164e63 100%) !important;
64
- border-right: 1px solid rgba(6, 182, 212, 0.1);
65
- }
66
-
67
- .stSidebar > div:first-child {
68
- padding-top: 2rem;
69
- }
70
-
71
- /* Typography */
72
- h1 {
73
- color: var(--text-primary);
74
- text-align: center;
75
- font-size: 2.5rem;
76
- font-weight: 700;
77
- margin-bottom: 2.5rem;
78
- letter-spacing: -0.02em;
79
- background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 50%, #0891b2 100%);
80
- -webkit-background-clip: text;
81
- -webkit-text-fill-color: transparent;
82
- }
83
-
84
- /* Chat Messages */
85
- .stChatMessage {
86
- background: rgba(30, 27, 75, 0.3) !important;
87
- backdrop-filter: blur(12px);
88
- border: 1px solid rgba(6, 182, 212, 0.1);
89
- border-radius: 16px;
90
- padding: 1.5rem;
91
- margin: 1.5rem 0;
92
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
93
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
94
- /* User and Assistant Messages */
95
- .stChatMessage[data-testid="user-message"],
96
- .stChatMessage[data-testid="assistant-message"] {
97
- color: var(--text-primary) !important; /* Weiß */
98
- }
99
- }
100
-
101
- /* Anpassung der Nachrichtenhintergründe an den Modus */
102
- .stChatMessage[data-testid="user-message"] {{
103
- background: {'rgba(6, 182, 212, 0.1)' if dark_mode else 'rgba(6, 182, 212, 0.05)'} !important;
104
- }}
105
- .stChatMessage[data-testid="assistant-message"] {{
106
- background: {'rgba(10, 25, 48, 0.7)' if dark_mode else 'rgba(248, 250, 252, 0.7)'} !important;
107
- color: {'var(--text-primary)' if dark_mode else '#1e293b'};
108
- }}
109
-
110
- /* Enhanced Input Area */
111
- .stChatInput {
112
- background-color: transparent !important;
113
- }
114
-
115
- .stChatInput > div {
116
- background-color: transparent !important;
117
- }
118
-
119
- div[data-testid="stChatInput"] {
120
- background-color: transparent !important;
121
- }
122
-
123
- .stTextInput > div {
124
- background-color: transparent !important;
125
- }
126
-
127
- div[data-testid="textInput"] {
128
- background-color: transparent !important;
129
- }
130
-
131
- .stTextInput > div > div {
132
- background-color: transparent !important;
133
- }
134
-
135
- .stTextInput > div > div > input {
136
- background: rgba(10, 25, 48, 0.7) !important;
137
- color: var(--text-primary);
138
- border: 1px solid rgba(6, 182, 212, 0.3);
139
- border-radius: 12px;
140
- padding: 1rem 1.5rem;
141
- font-size: 1rem;
142
- font-weight: 500;
143
- transition: all 0.2s ease;
144
- margin-bottom: 1rem;
145
- width: 100%;
146
- }
147
-
148
- .stTextInput > div > div > input:focus {
149
- border-color: var(--primary);
150
- box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
151
- }
152
-
153
- /* Chat Input Container Fix */
154
- .stChatInputContainer {
155
- background-color: transparent !important;
156
- border: none !important;
157
- padding: 0 !important;
158
- }
159
-
160
- section[data-testid="stChatInput"] {
161
- background-color: transparent !important;
162
- border: none !important;
163
- padding: 0 !important;
164
- }
165
-
166
- /* Source Details */
167
- .streamlit-expanderHeader {
168
- background: rgba(6, 182, 212, 0.08);
169
- border-radius: 10px;
170
- padding: 1rem;
171
- border: 1px solid rgba(6, 182, 212, 0.15);
172
- transition: all 0.2s ease;
173
- }
174
-
175
- /* Copy Button */
176
- button[data-testid="baseButton-secondary"] {
177
- background: rgba(6, 182, 212, 0.1);
178
- color: var(--primary-light);
179
- border: 1px solid rgba(6, 182, 212, 0.2);
180
- border-radius: 8px;
181
- padding: 0.5rem 1rem;
182
- font-weight: 500;
183
- transition: all 0.2s ease;
184
- }
185
-
186
- button[data-testid="baseButton-secondary"]:hover {
187
- background: rgba(6, 182, 212, 0.2);
188
- border-color: var(--primary);
189
- }
190
-
191
- /* Footer Area */
192
- footer {
193
- visibility: hidden;
194
- }
195
-
196
- /* Sidebar Text Size Control */
197
- .stSlider {
198
- padding: 1rem;
199
- }
200
-
201
- .stSlider > div > div > div {
202
- background-color: var(--primary) !important;
203
- }
204
-
205
- /* Remove Bottom Space */
206
- .main .block-container {
207
- padding-bottom: 2rem;
208
- max-width: 1000px;
209
- }
210
-
211
- /* Custom Scrollbar */
212
- ::-webkit-scrollbar {
213
- width: 8px;
214
- height: 8px;
215
- }
216
-
217
- ::-webkit-scrollbar-track {
218
- background: rgba(10, 25, 48, 0.1);
219
- }
220
-
221
- ::-webkit-scrollbar-thumb {
222
- background: var(--primary);
223
- border-radius: 4px;
224
- }
225
-
226
- ::-webkit-scrollbar-thumb:hover {
227
- background: var(--primary-light);
228
- }
229
- </style>
230
- """,
231
- unsafe_allow_html=True
232
  )
233
 
 
234
  def add_copy_button(text: str, key: str):
235
  if st.button("📋 Kopieren", key=f"copy_{key}"):
236
  st.session_state[f"copied_{key}"] = True
 
10
  BASE_PATH = os.path.dirname(os.path.abspath(__file__))
11
  VECTOR_STORE_PATH = os.path.join(BASE_PATH, "vector_stores")
12
 
 
13
  def apply_enhanced_custom_css():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  st.markdown(
15
+ """
16
+ <style>
17
+ @import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');
18
+ /* Color Variables */
19
+ :root {
20
+ --primary: #06b6d4;
21
+ --primary-light: #22d3ee;
22
+ --primary-dark: #0891b2;
23
+ --background-dark: #0a1930;
24
+ --background-light: #1a1f3c;
25
+ --surface: rgba(30, 27, 75, 0.5);
26
+ --text-primary: #f8fafc;
27
+ --text-secondary: #cbd5e1;
28
+ }
29
+ /* Base Styles & Navigation Bar Fix */
30
+ .stApp {
31
+ background: linear-gradient(145deg, var(--background-dark) 0%, #164e63 100%) !important;
32
+ color: var(--text-primary);
33
+ font-family: 'Plus Jakarta Sans', sans-serif;
34
+ line-height: 1.7;
35
+ }
36
+ /* Remove default header */
37
+ header[data-testid="stHeader"] {
38
+ display: none;
39
+ }
40
+ /* Clean up sidebar */
41
+ section[data-testid="stSidebar"] {
42
+ background: linear-gradient(180deg, var(--background-dark) 0%, #164e63 100%) !important;
43
+ border-right: 1px solid rgba(6, 182, 212, 0.1);
44
+ }
45
+ .stSidebar > div:first-child {
46
+ padding-top: 2rem;
47
+ }
48
+ /* Typography */
49
+ h1 {
50
+ color: var(--text-primary);
51
+ text-align: center;
52
+ font-size: 2.5rem;
53
+ font-weight: 700;
54
+ margin-bottom: 2.5rem;
55
+ letter-spacing: -0.02em;
56
+ background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 50%, #0891b2 100%);
57
+ -webkit-background-clip: text;
58
+ -webkit-text-fill-color: transparent;
59
+ }
60
+ /* Chat Messages */
61
+ .stChatMessage {
62
+ background: rgba(30, 27, 75, 0.3) !important;
63
+ backdrop-filter: blur(12px);
64
+ border: 1px solid rgba(6, 182, 212, 0.1);
65
+ border-radius: 16px;
66
+ padding: 1.5rem;
67
+ margin: 1.5rem 0;
68
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
69
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
70
+ }
71
+ /* User and Assistant Messages */
72
+ .stChatMessage[data-testid="user-message"],
73
+ .stChatMessage[data-testid="assistant-message"] {
74
+ color: #ffffff !important; /* Weiß */
75
+ }
76
+ /* Message Layout */
77
+ .stChatMessage[data-testid="user-message"] {
78
+ background: rgba(6, 182, 212, 0.1) !important;
79
+ margin-left: 12%;
80
+ margin-right: 2%;
81
+ border-left: 3px solid var(--primary);
82
+ }
83
+ .stChatMessage[data-testid="assistant-message"] {
84
+ background: rgba(10, 25, 48, 0.7) !important;
85
+ margin-right: 12%;
86
+ margin-left: 2%;
87
+ border-right: 3px solid var(--primary);
88
+ }
89
+ /* Enhanced Input Area */
90
+ .stChatInput {
91
+ background-color: transparent !important;
92
+ }
93
+ .stChatInput > div {
94
+ background-color: transparent !important;
95
+ }
96
+ div[data-testid="stChatInput"] {
97
+ background-color: transparent !important;
98
+ }
99
+ .stTextInput > div {
100
+ background-color: transparent !important;
101
+ }
102
+ div[data-testid="textInput"] {
103
+ background-color: transparent !important;
104
+ }
105
+ .stTextInput > div > div {
106
+ background-color: transparent !important;
107
+ }
108
+ .stTextInput > div > div > input {
109
+ background: rgba(10, 25, 48, 0.7) !important;
110
+ color: var(--text-primary);
111
+ border: 1px solid rgba(6, 182, 212, 0.3);
112
+ border-radius: 12px;
113
+ padding: 1rem 1.5rem;
114
+ font-size: 1rem;
115
+ font-weight: 500;
116
+ transition: all 0.2s ease;
117
+ margin-bottom: 1rem;
118
+ width: 100%;
119
+ }
120
+ .stTextInput > div > div > input:focus {
121
+ border-color: var(--primary);
122
+ box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
123
+ }
124
+ /* Chat Input Container Fix */
125
+ .stChatInputContainer {
126
+ background-color: transparent !important;
127
+ border: none !important;
128
+ padding: 0 !important;
129
+ }
130
+ section[data-testid="stChatInput"] {
131
+ background-color: transparent !important;
132
+ border: none !important;
133
+ padding: 0 !important;
134
+ }
135
+ /* Source Details */
136
+ .streamlit-expanderHeader {
137
+ background: rgba(6, 182, 212, 0.08);
138
+ border-radius: 10px;
139
+ padding: 1rem;
140
+ border: 1px solid rgba(6, 182, 212, 0.15);
141
+ transition: all 0.2s ease;
142
+ }
143
+ /* Copy Button */
144
+ button[data-testid="baseButton-secondary"] {
145
+ background: rgba(6, 182, 212, 0.1);
146
+ color: var(--primary-light);
147
+ border: 1px solid rgba(6, 182, 212, 0.2);
148
+ border-radius: 8px;
149
+ padding: 0.5rem 1rem;
150
+ font-weight: 500;
151
+ transition: all 0.2s ease;
152
+ }
153
+ button[data-testid="baseButton-secondary"]:hover {
154
+ background: rgba(6, 182, 212, 0.2);
155
+ border-color: var(--primary);
156
+ }
157
+ /* Footer Area */
158
+ footer {
159
+ visibility: hidden;
160
+ }
161
+ /* Sidebar Text Size Control */
162
+ .stSlider {
163
+ padding: 1rem;
164
+ }
165
+ .stSlider > div > div > div {
166
+ background-color: var(--primary) !important;
167
+ }
168
+ /* Remove Bottom Space */
169
+ .main .block-container {
170
+ padding-bottom: 2rem;
171
+ max-width: 1000px;
172
+ }
173
+ /* Custom Scrollbar */
174
+ ::-webkit-scrollbar {
175
+ width: 8px;
176
+ height: 8px;
177
+ }
178
+ ::-webkit-scrollbar-track {
179
+ background: rgba(10, 25, 48, 0.1);
180
+ }
181
+ ::-webkit-scrollbar-thumb {
182
+ background: var(--primary);
183
+ border-radius: 4px;
184
+ }
185
+ ::-webkit-scrollbar-thumb:hover {
186
+ background: var(--primary-light);
187
+ }
188
+ </style>
189
+ """,
190
+ unsafe_allow_html=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  )
192
 
193
+
194
  def add_copy_button(text: str, key: str):
195
  if st.button("📋 Kopieren", key=f"copy_{key}"):
196
  st.session_state[f"copied_{key}"] = True