Update app.py
Browse files
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 |
-
|
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 |
-
/* ---
|
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 |
-
|
|
|
|
|
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; /*
|
298 |
-
border:
|
299 |
}
|
300 |
|
301 |
-
/*
|
302 |
-
|
303 |
-
|
304 |
-
}
|
305 |
|
306 |
-
/*
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
with gr.Row(elem_classes="chat-input-row"):
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
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")
|