Yaswanth123 commited on
Commit
415bb86
·
verified ·
1 Parent(s): 69a03fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -55
app.py CHANGED
@@ -250,69 +250,51 @@ def handle_user_interaction(
250
  documentation_update,
251
  )
252
  # --- NEW AESTHETIC CSS ---
 
 
253
  custom_css = """
254
  /* --- Overall Page & Theme --- */
255
- .gradio-container {
256
- background-color: #F9FAFB; /* Light mode background */
257
- }
258
- .dark .gradio-container {
259
- background-color: #111827; /* Dark mode background */
260
- }
261
-
262
- /* --- Collapsible Header Section --- */
263
- #app-header {
264
- color: #374151; /* Light mode text */
265
- }
266
- .dark #app-header {
267
- color: #D1D5DB; /* Dark mode text */
268
- }
269
 
270
- /* --- Main Application Tabs --- */
271
- #app-tabs .tab-nav button {
272
- background-color: transparent !important;
273
- border-bottom: 2px solid transparent !important;
274
- }
275
- #app-tabs .tab-nav button.selected {
276
- border-bottom-color: #4F46E5 !important; /* Accent color */
277
- color: #4F46E5 !important;
278
- }
279
- .dark #app-tabs .tab-nav button {
280
- color: #9CA3AF;
281
- }
282
- .dark #app-tabs .tab-nav button.selected {
283
- background-color: #1F2937 !important; /* Darker tab background */
284
- color: #A5B4FC !important;
285
- border-bottom-color: #A5B4FC !important;
286
- }
287
-
288
- /* --- FIX FOR CHATBOT APPEARANCE AND SPACING --- */
289
  #chatbot {
290
- background-color: white !important; /* Distinct white background for chatbot */
 
 
291
  border: 1px solid #E5E7EB !important;
292
  border-radius: 12px !important;
293
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05) !important;
294
- margin-bottom: 0 !important; /* Remove bottom margin to close the gap */
295
  }
296
  .dark #chatbot {
297
- background-color: #1F2937 !important; /* Dark but distinct background */
298
- border: 1px solid #374151 !important;
299
  }
300
 
301
- /* FIX: Target the input row to remove the top margin, closing the gap */
302
- .chat-input-container {
303
- padding-top: 1rem !important;
304
- }
305
 
306
- /* --- Compact & Styled Buttons (already good, no changes needed) --- */
307
- .sm-button {
308
- min-width: 0 !important;
309
- padding: 0.2rem 0.6rem !important;
310
- /* ... other styles */
311
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  """
313
  # --- Gradio UI Definition ---
314
- # --- Gradio UI Definition ---
315
- # --- Gradio UI Definition ---
316
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="AI Syllabus Architect") as demo:
317
 
318
  # --- State Management ---
@@ -347,19 +329,35 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="AI Syllabus Archit
347
  with gr.Tabs(elem_id="app-tabs", visible=(APP_MODE == 'admin')) as app_tabs:
348
 
349
  # --- TAB 1: The Main Chat Interface ---
 
 
350
  with gr.Tab("Chat Interface", id="chat_tab"):
351
  with gr.Row(equal_height=False):
 
352
  # --- MAIN CHAT COLUMN ---
353
  with gr.Column(scale=7) as chat_column:
354
  open_sidebar_btn = gr.Button("Show Resources & Persona ➡️", elem_classes="sm-button", visible=False)
 
355
  initial_chat_ui = [{"role": "assistant", "content": "Hello! I'm ready to help build a personalized syllabus. What topic are you interested in learning about?"}]
356
- chatbot = gr.Chatbot(initial_chat_ui, elem_id="chatbot", type="messages", show_label=False, render_markdown=True, avatar_images=(None, "https://i.imgur.com/3pyR0Vf.png"), latex_delimiters=[{"left": "$$", "right": "$$", "display": True}, {"left": "$", "right": "$", "display": False}])
 
 
 
 
 
 
 
 
 
 
357
  with gr.Row(elem_classes="chat-input-row"):
358
- looks_good_btn = gr.Button("looks good", size="sm", visible=False)
359
- with gr.Row(elem_classes="chat-input-container"):
360
- user_input_textbox = gr.Textbox(scale=4, show_label=False, placeholder="Type your message or upload files and press Enter...", container=False)
361
- send_button = gr.Button("Send", variant="primary", scale=1, min_width=150)
362
-
 
 
363
  # --- TOOLS SIDEBAR COLUMN (Correctly nested inside the Chat Tab's Row) ---
364
  with gr.Column(scale=3, visible=True) as tools_sidebar:
365
  close_sidebar_btn = gr.Button("⬅️ Close Sidebar", elem_classes="sm-button")
 
250
  documentation_update,
251
  )
252
  # --- NEW AESTHETIC CSS ---
253
+ # --- NEW, LAYOUT-FOCUSED CSS ---
254
+ # --- FINAL, CORRECTED CSS ---
255
  custom_css = """
256
  /* --- Overall Page & Theme --- */
257
+ .gradio-container { background-color: #F9FAFB; }
258
+ .dark .gradio-container { background-color: #111827; }
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
+ /* --- THE KEY FIX: Make the chatbot tall and scrollable --- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  #chatbot {
262
+ /* Use vh (viewport height) to make the chatbot take up most of the screen */
263
+ min-height: 70vh !important;
264
+ background-color: white !important; /* Distinct white background */
265
  border: 1px solid #E5E7EB !important;
266
  border-radius: 12px !important;
 
 
267
  }
268
  .dark #chatbot {
269
+ background-color: #1F2937 !important; /* Distinct dark background for chatbot */
270
+ border-color: #374151 !important;
271
  }
272
 
273
+ /* --- Input Bar Styling --- */
274
+ /* Add a top margin to the input row to create visual space from the chatbot */
275
+ .chat-input-row { margin-top: 1rem !important; }
 
276
 
277
+ /* Style the textbox itself for a clean look */
278
+ #user_input_textbox textarea {
279
+ background-color: #FFFFFF !important;
280
+ border: 1px solid #D1D5DB !important;
281
+ border-radius: 8px !important;
282
  }
283
+ .dark #user_input_textbox textarea {
284
+ background-color: #374151 !important;
285
+ color: #F3F4F6 !important;
286
+ border-color: #4B5563 !important;
287
+ }
288
+
289
+ /* --- General styling from before (tabs, small buttons) --- */
290
+ /* (This part remains the same as the version you liked) */
291
+ #app-header { text-align: center; color: #4A5568; margin-bottom: 0.5rem !important; }
292
+ .dark #app-header { color: #D1D5DB; }
293
+ .sm-button { min-width: 0 !important; padding: 0.2rem 0.6rem !important; /* ...etc... */ }
294
+ #app-tabs .tab-nav button.selected { border-bottom-color: #4F46E5 !important; color: #4F46E5 !important; }
295
+ .dark #app-tabs .tab-nav button.selected { border-bottom-color: #A5B4FC !important; color: #A5B4FC !important; }
296
  """
297
  # --- Gradio UI Definition ---
 
 
298
  with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, title="AI Syllabus Architect") as demo:
299
 
300
  # --- State Management ---
 
329
  with gr.Tabs(elem_id="app-tabs", visible=(APP_MODE == 'admin')) as app_tabs:
330
 
331
  # --- TAB 1: The Main Chat Interface ---
332
+ # --- TAB 1: The Main Chat Interface ---
333
+ # --- TAB 1: The Main Chat Interface ---
334
  with gr.Tab("Chat Interface", id="chat_tab"):
335
  with gr.Row(equal_height=False):
336
+
337
  # --- MAIN CHAT COLUMN ---
338
  with gr.Column(scale=7) as chat_column:
339
  open_sidebar_btn = gr.Button("Show Resources & Persona ➡️", elem_classes="sm-button", visible=False)
340
+
341
  initial_chat_ui = [{"role": "assistant", "content": "Hello! I'm ready to help build a personalized syllabus. What topic are you interested in learning about?"}]
342
+ chatbot = gr.Chatbot(
343
+ initial_chat_ui, elem_id="chatbot", type="messages",
344
+ show_label=False, render_markdown=True,
345
+ avatar_images=(None, "https://i.imgur.com/3pyR0Vf.png")
346
+ )
347
+
348
+ # This row contains the suggested replies
349
+ with gr.Row():
350
+ looks_good_btn = gr.Button("looks good", size="sm", visible=False)
351
+
352
+ # This row contains the main input textbox and send button
353
  with gr.Row(elem_classes="chat-input-row"):
354
+ user_input_textbox = gr.Textbox(
355
+ elem_id="user_input_textbox", # ID for specific styling
356
+ scale=4, show_label=False,
357
+ placeholder="Type your message here...", container=False
358
+ )
359
+ send_button = gr.Button("Send", variant="primary", scale=1, min_width=120)
360
+
361
  # --- TOOLS SIDEBAR COLUMN (Correctly nested inside the Chat Tab's Row) ---
362
  with gr.Column(scale=3, visible=True) as tools_sidebar:
363
  close_sidebar_btn = gr.Button("⬅️ Close Sidebar", elem_classes="sm-button")