Wfafa commited on
Commit
6522d73
Β·
verified Β·
1 Parent(s): ac256cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -25
app.py CHANGED
@@ -113,7 +113,7 @@ def clear_memory():
113
  os.remove(MEMORY_FILE)
114
  return [], "🧹 Chat memory cleared! Start fresh."
115
 
116
- # πŸ–Œ Custom CSS for dark theme and professional look, with file uploader as a symbol in the text area
117
  custom_css = """
118
  @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600&display=swap');
119
 
@@ -134,8 +134,8 @@ body {
134
  text-align: center;
135
  margin-bottom: 20px;
136
  font-weight: 600;
137
- color: #4CAF50;
138
- text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
139
  }
140
  .sidebar {
141
  background: #2a2a2a;
@@ -148,7 +148,7 @@ body {
148
  font-size: 20px;
149
  font-weight: 500;
150
  margin-bottom: 15px;
151
- color: #4CAF50;
152
  }
153
  .accordion {
154
  border-radius: 10px;
@@ -165,7 +165,7 @@ body {
165
  transition: background 0.3s;
166
  }
167
  .accordion-header:hover {
168
- background: #4CAF50;
169
  color: #1e1e1e;
170
  }
171
  .main-chat {
@@ -188,12 +188,12 @@ body {
188
  border: 1px solid #333;
189
  }
190
  .chatbox .message.user {
191
- background: #4CAF50;
192
  color: #1e1e1e;
193
  border-radius: 12px;
194
  padding: 12px 15px;
195
  margin: 8px 0;
196
- box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
197
  }
198
  .chatbox .message.bot {
199
  background: #333;
@@ -218,7 +218,7 @@ body {
218
  transition: border-color 0.3s;
219
  }
220
  .chat-input:focus {
221
- border-color: #4CAF50;
222
  outline: none;
223
  }
224
  .file-upload {
@@ -236,22 +236,9 @@ body {
236
  font-size: 18px;
237
  }
238
  .file-upload:hover {
239
- background: #4CAF50;
240
  color: #1e1e1e;
241
  }
242
- .btn-send {
243
- background: #4CAF50;
244
- color: #1e1e1e;
245
- border-radius: 10px;
246
- padding: 12px 20px;
247
- border: none;
248
- font-weight: 500;
249
- cursor: pointer;
250
- transition: background 0.3s;
251
- }
252
- .btn-send:hover {
253
- background: #45a049;
254
- }
255
  .btn-clear {
256
  background: #f44336;
257
  color: white;
@@ -278,7 +265,7 @@ body {
278
  }
279
  """
280
 
281
- # 🎨 Gradio Interface with dark theme and professional styling, file uploader as a symbol in the text area
282
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as iface: # Using Base theme for full custom control
283
  gr.Markdown("# πŸŽ“ **EduAI β€” Your Professional Study Companion**", elem_classes="header-title")
284
 
@@ -335,13 +322,12 @@ with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as iface: # Using Base t
335
  with gr.Row(elem_classes="input-row"):
336
  msg = gr.Textbox(label="Ask EduAI:", placeholder="Type your question here...", elem_classes="chat-input", show_label=False)
337
  file_input = gr.File(label="πŸ“Ž", file_types=[".pdf", ".docx", ".png", ".jpg"], elem_classes="file-upload", show_label=False)
338
- send = gr.Button("Send ✈️", elem_classes="btn-send")
339
 
340
  # Event Handlers
341
  subj.change(update_context, inputs=subj, outputs=context_display)
342
  planner.change(update_context, inputs=planner, outputs=context_display)
343
  lang.change(update_context, inputs=lang, outputs=context_display)
344
- send.click(chat_with_model, inputs=[msg, chatbot, context_display, file_input], outputs=[chatbot, chatbot])
345
  clear_btn.click(clear_memory, outputs=[chatbot, context_display])
346
 
347
  iface.launch()
 
113
  os.remove(MEMORY_FILE)
114
  return [], "🧹 Chat memory cleared! Start fresh."
115
 
116
+ # πŸ–Œ Custom CSS for dark theme without green, using blue accents, file uploader as symbol in text area, no send button
117
  custom_css = """
118
  @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600&display=swap');
119
 
 
134
  text-align: center;
135
  margin-bottom: 20px;
136
  font-weight: 600;
137
+ color: #007BFF;
138
+ text-shadow: 0 0 10px rgba(0, 123, 255, 0.5);
139
  }
140
  .sidebar {
141
  background: #2a2a2a;
 
148
  font-size: 20px;
149
  font-weight: 500;
150
  margin-bottom: 15px;
151
+ color: #007BFF;
152
  }
153
  .accordion {
154
  border-radius: 10px;
 
165
  transition: background 0.3s;
166
  }
167
  .accordion-header:hover {
168
+ background: #007BFF;
169
  color: #1e1e1e;
170
  }
171
  .main-chat {
 
188
  border: 1px solid #333;
189
  }
190
  .chatbox .message.user {
191
+ background: #007BFF;
192
  color: #1e1e1e;
193
  border-radius: 12px;
194
  padding: 12px 15px;
195
  margin: 8px 0;
196
+ box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
197
  }
198
  .chatbox .message.bot {
199
  background: #333;
 
218
  transition: border-color 0.3s;
219
  }
220
  .chat-input:focus {
221
+ border-color: #007BFF;
222
  outline: none;
223
  }
224
  .file-upload {
 
236
  font-size: 18px;
237
  }
238
  .file-upload:hover {
239
+ background: #007BFF;
240
  color: #1e1e1e;
241
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  .btn-clear {
243
  background: #f44336;
244
  color: white;
 
265
  }
266
  """
267
 
268
+ # 🎨 Gradio Interface with dark theme (blue accents, no green), file uploader as symbol, send on Enter (no send button)
269
  with gr.Blocks(theme=gr.themes.Base(), css=custom_css) as iface: # Using Base theme for full custom control
270
  gr.Markdown("# πŸŽ“ **EduAI β€” Your Professional Study Companion**", elem_classes="header-title")
271
 
 
322
  with gr.Row(elem_classes="input-row"):
323
  msg = gr.Textbox(label="Ask EduAI:", placeholder="Type your question here...", elem_classes="chat-input", show_label=False)
324
  file_input = gr.File(label="πŸ“Ž", file_types=[".pdf", ".docx", ".png", ".jpg"], elem_classes="file-upload", show_label=False)
 
325
 
326
  # Event Handlers
327
  subj.change(update_context, inputs=subj, outputs=context_display)
328
  planner.change(update_context, inputs=planner, outputs=context_display)
329
  lang.change(update_context, inputs=lang, outputs=context_display)
330
+ msg.submit(chat_with_model, inputs=[msg, chatbot, context_display, file_input], outputs=[chatbot, chatbot]) # Send on Enter
331
  clear_btn.click(clear_memory, outputs=[chatbot, context_display])
332
 
333
  iface.launch()