Wfafa commited on
Commit
f9b8bb6
Β·
verified Β·
1 Parent(s): e719bd3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -22
app.py CHANGED
@@ -113,29 +113,43 @@ def clear_memory():
113
  os.remove(MEMORY_FILE)
114
  return [], "🧹 Chat memory cleared! Start fresh."
115
 
116
- # πŸ–Œ Custom CSS for professional look
117
  custom_css = """
118
- .header-title { font-size: 36px; text-align:center; margin-bottom:20px; }
119
- .sidebar { background-color:#f5f3ff; padding:15px; border-radius:12px; box-shadow:0 2px 6px rgba(0,0,0,0.1); }
120
- .menu-title { font-size:20px; font-weight:bold; margin-bottom:10px; }
121
- .main-chat { padding:10px; }
122
- .context-box { background-color:#ffffff; padding:10px; border-radius:10px; box-shadow:0 1px 4px rgba(0,0,0,0.1); margin-bottom:10px; }
123
- .chatbox .message.user { background-color:#e0d7ff; border-radius:10px; padding:8px; margin:5px 0; }
124
- .chatbox .message.bot { background-color:#ffffff; border-radius:10px; padding:8px; margin:5px 0; box-shadow:0 1px 2px rgba(0,0,0,0.05);}
125
- .chat-input { border-radius:10px; padding:8px; width:100%; }
126
- .btn-send { background-color:#7c3aed; color:white; border-radius:10px; padding:8px 16px; }
127
- .btn-clear { background-color:#ef4444; color:white; border-radius:10px; padding:6px 12px; }
128
- .file-upload { border:2px dashed #d4b5ff; border-radius:10px; padding:10px; text-align:center; }
129
- .about-text { font-size:14px; color:#4b5563; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  """
131
 
132
- # 🎨 Gradio Interface with CSS included
133
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet"), css=custom_css) as iface:
134
- gr.Markdown("# πŸŽ“ **EduAI β€” Your Smart Study Companion**", elem_classes="header-title")
135
 
136
  with gr.Row():
137
- # Sidebar
138
- with gr.Column(scale=1, min_width=250, elem_classes="sidebar"):
139
  gr.Markdown("### 🧭 **Main Menu**", elem_classes="menu-title")
140
 
141
  with gr.Accordion("πŸ“š Subject Tutor", open=False):
@@ -168,7 +182,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet"), css=custom_css) as if
168
  Helps learners understand **Science, ICT, English, and more** in a simple, friendly way! πŸ’¬
169
  """, elem_classes="about-text")
170
 
171
- # Main Chat Area
172
  with gr.Column(scale=4, elem_classes="main-chat"):
173
  context_display = gr.Markdown(
174
  "πŸ“˜ **You are in General Mode.** Ask EduAI anything about your studies!",
@@ -177,14 +191,14 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet"), css=custom_css) as if
177
 
178
  chatbot = gr.Chatbot(
179
  label="EduAI Chat",
180
- height=500,
181
  render_markdown=True,
182
- type="messages", # βœ… Fixed deprecation warning
183
  latex_delimiters=[{"left": "$$", "right": "$$", "display": True}, {"left": "\\[", "right": "\\]", "display": True}]
184
  )
185
 
186
  with gr.Row():
187
- msg = gr.Textbox(label="Ask EduAI:", placeholder="Type your question here...", elem_classes="chat-input")
188
  file_input = gr.File(label="πŸ“‚ Upload a study file", file_types=[".pdf", ".docx", ".png", ".jpg"], elem_classes="file-upload")
189
  send = gr.Button("Send ✈️", elem_classes="btn-send")
190
 
 
113
  os.remove(MEMORY_FILE)
114
  return [], "🧹 Chat memory cleared! Start fresh."
115
 
116
+ # πŸ–Œ Custom CSS for elegant, modern look (enhanced for sophistication)
117
  custom_css = """
118
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
119
+
120
+ body { font-family: 'Inter', sans-serif; background: linear-gradient(135deg, #f8fafc, #e2e8f0); color: #334155; }
121
+ .header-title { font-size: 32px; text-align: center; margin-bottom: 20px; font-weight: 700; color: #0f172a; letter-spacing: -0.5px; }
122
+ .sidebar { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 20px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border: 1px solid #e2e8f0; }
123
+ .menu-title { font-size: 20px; font-weight: 600; margin-bottom: 15px; color: #0f172a; }
124
+ .accordion { border-radius: 12px; margin-bottom: 10px; }
125
+ .accordion-header { background: #f1f5f9; border-radius: 12px; padding: 12px; font-weight: 500; transition: all 0.3s ease; }
126
+ .accordion-header:hover { background: #e2e8f0; }
127
+ .main-chat { padding: 20px; background: transparent; }
128
+ .context-box { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); padding: 15px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 15px; border: 1px solid #e2e8f0; font-size: 14px; }
129
+ .chatbox { border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); background: #ffffff; }
130
+ .chatbox .message.user { background: linear-gradient(135deg, #14b8a6, #06b6d4); color: white; border-radius: 16px; padding: 12px 16px; margin: 8px 0; box-shadow: 0 2px 6px rgba(20, 184, 166, 0.3); animation: fadeIn 0.5s ease-in; }
131
+ .chatbox .message.bot { background: #f8fafc; color: #334155; border-radius: 16px; padding: 12px 16px; margin: 8px 0; box-shadow: 0 1px 4px rgba(0,0,0,0.05); border: 1px solid #e2e8f0; animation: fadeIn 0.5s ease-in; }
132
+ @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
133
+ .chat-input { border-radius: 20px; padding: 12px 16px; width: 100%; border: 1px solid #d1d5db; transition: all 0.3s ease; }
134
+ .chat-input:focus { outline: none; border-color: #14b8a6; box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2); }
135
+ .btn-send { background: linear-gradient(135deg, #14b8a6, #06b6d4); color: white; border-radius: 20px; padding: 12px 24px; border: none; font-weight: 500; transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3); }
136
+ .btn-send:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4); }
137
+ .btn-clear { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border-radius: 12px; padding: 8px 16px; border: none; font-weight: 500; transition: all 0.3s ease; }
138
+ .btn-clear:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4); }
139
+ .file-upload { border: 2px dashed #14b8a6; border-radius: 12px; padding: 15px; text-align: center; background: #f8fafc; transition: all 0.3s ease; }
140
+ .file-upload:hover { background: #e2e8f0; border-color: #06b6d4; }
141
+ .about-text { font-size: 14px; color: #64748b; line-height: 1.5; }
142
+ .radio { margin: 10px 0; }
143
+ .radio label { font-weight: 400; }
144
  """
145
 
146
+ # 🎨 Gradio Interface with enhanced CSS and layout
147
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="teal"), css=custom_css) as iface:
148
+ gr.Markdown("# πŸŽ“ **EduAI β€” Your Elegant Study Companion**", elem_classes="header-title")
149
 
150
  with gr.Row():
151
+ # Sidebar (refined for elegance)
152
+ with gr.Column(scale=1, min_width=280, elem_classes="sidebar"):
153
  gr.Markdown("### 🧭 **Main Menu**", elem_classes="menu-title")
154
 
155
  with gr.Accordion("πŸ“š Subject Tutor", open=False):
 
182
  Helps learners understand **Science, ICT, English, and more** in a simple, friendly way! πŸ’¬
183
  """, elem_classes="about-text")
184
 
185
+ # Main Chat Area (enhanced for modern look)
186
  with gr.Column(scale=4, elem_classes="main-chat"):
187
  context_display = gr.Markdown(
188
  "πŸ“˜ **You are in General Mode.** Ask EduAI anything about your studies!",
 
191
 
192
  chatbot = gr.Chatbot(
193
  label="EduAI Chat",
194
+ height=550,
195
  render_markdown=True,
196
+ type="messages",
197
  latex_delimiters=[{"left": "$$", "right": "$$", "display": True}, {"left": "\\[", "right": "\\]", "display": True}]
198
  )
199
 
200
  with gr.Row():
201
+ msg = gr.Textbox(label="Ask EduAI:", placeholder="Share your study query...", elem_classes="chat-input")
202
  file_input = gr.File(label="πŸ“‚ Upload a study file", file_types=[".pdf", ".docx", ".png", ".jpg"], elem_classes="file-upload")
203
  send = gr.Button("Send ✈️", elem_classes="btn-send")
204