jdesiree commited on
Commit
d06e7bd
·
verified ·
1 Parent(s): 1a347be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +96 -45
app.py CHANGED
@@ -172,57 +172,81 @@ def respond_with_enhanced_streaming(message, history):
172
 
173
  # --- Gradio UI and CSS ---
174
  custom_css = """
175
- /* Main container and background */
176
  .gradio-container {
177
  background-color: rgb(240, 236, 230) !important;
178
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
179
  height: 100vh !important;
 
180
  overflow: hidden;
 
 
 
181
  }
182
 
183
- /* Main layout container */
184
  .main-container {
185
- height: 100vh;
 
 
186
  display: flex;
187
  flex-direction: column;
188
- max-width: none !important;
189
- margin: 0 !important;
190
- padding: 0 !important;
191
  }
192
 
193
- /* Chat content area */
194
- .chat-content {
195
- flex: 1;
 
 
 
 
196
  display: flex;
197
- flex-direction: column;
198
- overflow: hidden;
199
- max-width: 800px;
200
- margin: 0 auto;
201
- padding: 1rem;
202
- padding-bottom: 0;
203
  }
204
 
205
  /* Model name title */
206
  .model-name {
207
- font-size: 1.5rem;
208
  font-weight: bold;
209
  color: black;
210
- margin-bottom: 1rem;
211
  text-align: left;
 
 
212
  }
213
 
214
- /* Chatbot styling */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  .gradio-chatbot {
216
- flex: 1;
217
  overflow-y: auto;
218
  border: none !important;
219
  background-color: transparent !important;
220
- margin-bottom: 0 !important;
 
 
 
 
221
  }
222
 
223
  /* Message container styling */
224
  .gradio-chatbot .message-wrap {
225
  margin: 0.5rem 0 !important;
 
226
  }
227
 
228
  /* Bot message styling */
@@ -233,7 +257,7 @@ custom_css = """
233
  padding: 12px 16px !important;
234
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
235
  border: none !important;
236
- max-width: 80%;
237
  margin-left: 0;
238
  margin-right: auto;
239
  }
@@ -246,7 +270,7 @@ custom_css = """
246
  padding: 12px 16px !important;
247
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
248
  border: none !important;
249
- max-width: 80%;
250
  margin-left: auto;
251
  margin-right: 0;
252
  }
@@ -256,21 +280,28 @@ custom_css = """
256
  display: none !important;
257
  }
258
 
259
- /* Full-width input container at bottom */
260
- .input-bottom {
261
- position: sticky;
262
- bottom: 0;
263
- left: 0;
264
- right: 0;
265
  background-color: rgb(240, 236, 230);
266
- padding: 1rem;
267
- border-top: 1px solid rgba(28, 18, 5, 0.1);
 
 
 
 
 
 
268
  }
269
 
270
- /* Input textbox styling - full width */
271
  .input-container {
272
  width: 100% !important;
273
  max-width: none !important;
 
 
 
274
  }
275
 
276
  .input-container .wrap {
@@ -279,6 +310,8 @@ custom_css = """
279
  border-radius: 20px !important;
280
  box-shadow: none !important;
281
  width: 100% !important;
 
 
282
  }
283
 
284
  .input-container textarea {
@@ -291,6 +324,8 @@ custom_css = """
291
  outline: none !important;
292
  width: 100% !important;
293
  resize: none !important;
 
 
294
  }
295
 
296
  .input-container textarea:focus {
@@ -304,11 +339,11 @@ custom_css = """
304
  display: none !important;
305
  }
306
 
307
- /* Clear button styling - positioned in top right */
308
  .clear-btn {
309
  position: absolute;
310
  top: 1rem;
311
- right: 1rem;
312
  background-color: rgb(28, 18, 5) !important;
313
  color: white !important;
314
  border: none !important;
@@ -321,34 +356,50 @@ custom_css = """
321
  .clear-btn:hover {
322
  background-color: rgba(28, 18, 5, 0.8) !important;
323
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  """
325
 
326
  with gr.Blocks(css=custom_css, title="EduBot") as demo:
327
  with gr.Column(elem_classes=["main-container"]):
328
- # Clear button in top right
329
- clear = gr.Button("Clear", elem_classes=["clear-btn"])
330
 
331
- # Chat content area
332
- with gr.Column(elem_classes=["chat-content"]):
333
- # Model Name in the top-left corner
334
  gr.HTML('<div class="model-name">🎓 EduBot</div>')
335
-
336
- # The main chatbot interface
 
337
  chatbot = gr.Chatbot(
338
  type="messages",
339
- height="100%",
340
- show_copy_button=False,
341
  show_share_button=False,
342
  avatar_images=None
343
  )
344
 
345
- # Full-width input at bottom
346
- with gr.Column(elem_classes=["input-bottom"]):
 
347
  msg = gr.Textbox(
348
  placeholder="Ask me about math, research, study strategies, or any educational topic...",
349
  show_label=False,
350
  lines=1,
351
- max_lines=4,
352
  elem_classes=["input-container"]
353
  )
354
 
 
172
 
173
  # --- Gradio UI and CSS ---
174
  custom_css = """
175
+ /* Main container and background - full viewport */
176
  .gradio-container {
177
  background-color: rgb(240, 236, 230) !important;
178
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
179
  height: 100vh !important;
180
+ width: 100vw !important;
181
  overflow: hidden;
182
+ margin: 0 !important;
183
+ padding: 0 !important;
184
+ max-width: none !important;
185
  }
186
 
187
+ /* Main layout container - full width, sectioned heights */
188
  .main-container {
189
+ width: 98vw; /* Sets the width to 98% of the viewport width */
190
+ height: 100vh; /* Fill the entire viewport height */
191
+ margin: 0 auto; /* Center the container horizontally */
192
  display: flex;
193
  flex-direction: column;
 
 
 
194
  }
195
 
196
+ /* Section 1: Title section - 15% of viewport height */
197
+ .title-section {
198
+ height: 15vh;
199
+ width: 100vw;
200
+ padding: 1rem 2rem;
201
+ background-color: rgb(240, 236, 230);
202
+ border-bottom: 2px solid rgba(28, 18, 5, 0.1);
203
  display: flex;
204
+ align-items: center;
205
+ box-sizing: border-box;
206
+ flex-shrink: 0;
 
 
 
207
  }
208
 
209
  /* Model name title */
210
  .model-name {
211
+ font-size: 1.8rem;
212
  font-weight: bold;
213
  color: black;
 
214
  text-align: left;
215
+ margin: 0;
216
+ width: 100%;
217
  }
218
 
219
+ /* Section 2: Chat content area - 60% of viewport height */
220
+ .chat-content {
221
+ height: 60vh;
222
+ width: 100vw;
223
+ display: flex;
224
+ flex-direction: column;
225
+ overflow: hidden;
226
+ max-width: none !important;
227
+ margin: 0 !important;
228
+ padding: 0 !important;
229
+ background-color: rgb(240, 236, 230);
230
+ flex-shrink: 0;
231
+ }
232
+
233
+ /* Chatbot styling - uses full 60vh */
234
  .gradio-chatbot {
235
+ height: 100% !important;
236
  overflow-y: auto;
237
  border: none !important;
238
  background-color: transparent !important;
239
+ margin: 0 !important;
240
+ padding: 1rem 2rem !important;
241
+ width: 100% !important;
242
+ max-width: none !important;
243
+ box-sizing: border-box;
244
  }
245
 
246
  /* Message container styling */
247
  .gradio-chatbot .message-wrap {
248
  margin: 0.5rem 0 !important;
249
+ max-width: none !important;
250
  }
251
 
252
  /* Bot message styling */
 
257
  padding: 12px 16px !important;
258
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
259
  border: none !important;
260
+ max-width: 70%;
261
  margin-left: 0;
262
  margin-right: auto;
263
  }
 
270
  padding: 12px 16px !important;
271
  box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
272
  border: none !important;
273
+ max-width: 70%;
274
  margin-left: auto;
275
  margin-right: 0;
276
  }
 
280
  display: none !important;
281
  }
282
 
283
+ /* Section 3: Input section - 25% of viewport height */
284
+ .input-section {
285
+ height: 25vh;
286
+ width: 100vw;
 
 
287
  background-color: rgb(240, 236, 230);
288
+ border-top: 2px solid rgba(28, 18, 5, 0.1);
289
+ padding: 1rem 2rem;
290
+ box-sizing: border-box;
291
+ display: flex;
292
+ flex-direction: column;
293
+ justify-content: center;
294
+ position: relative;
295
+ flex-shrink: 0;
296
  }
297
 
298
+ /* Input textbox styling - takes most of the 25vh */
299
  .input-container {
300
  width: 100% !important;
301
  max-width: none !important;
302
+ flex: 1;
303
+ display: flex;
304
+ align-items: center;
305
  }
306
 
307
  .input-container .wrap {
 
310
  border-radius: 20px !important;
311
  box-shadow: none !important;
312
  width: 100% !important;
313
+ min-height: 60px;
314
+ max-height: calc(25vh - 4rem);
315
  }
316
 
317
  .input-container textarea {
 
324
  outline: none !important;
325
  width: 100% !important;
326
  resize: none !important;
327
+ min-height: 30px;
328
+ max-height: calc(25vh - 6rem);
329
  }
330
 
331
  .input-container textarea:focus {
 
339
  display: none !important;
340
  }
341
 
342
+ /* Clear button styling - positioned in input section */
343
  .clear-btn {
344
  position: absolute;
345
  top: 1rem;
346
+ right: 2rem;
347
  background-color: rgb(28, 18, 5) !important;
348
  color: white !important;
349
  border: none !important;
 
356
  .clear-btn:hover {
357
  background-color: rgba(28, 18, 5, 0.8) !important;
358
  }
359
+
360
+ /* Override any Gradio default width/height constraints */
361
+ .gradio-container > div,
362
+ .gradio-container .block,
363
+ .gradio-container .form {
364
+ max-width: none !important;
365
+ width: 100% !important;
366
+ height: auto !important;
367
+ }
368
+
369
+ /* Ensure no unwanted scrollbars on main sections */
370
+ .title-section, .input-section {
371
+ overflow: hidden;
372
+ }
373
+
374
+ .chat-content {
375
+ overflow: hidden;
376
+ }
377
  """
378
 
379
  with gr.Blocks(css=custom_css, title="EduBot") as demo:
380
  with gr.Column(elem_classes=["main-container"]):
 
 
381
 
382
+ # Section 1: Title Box - 15% of viewport height
383
+ with gr.Column(elem_classes=["title-section"]):
 
384
  gr.HTML('<div class="model-name">🎓 EduBot</div>')
385
+
386
+ # Section 2: Chat History/Conversation Viewport - 60% of viewport height
387
+ with gr.Column(elem_classes=["chat-content"]):
388
  chatbot = gr.Chatbot(
389
  type="messages",
390
+ show_copy_button=True,
 
391
  show_share_button=False,
392
  avatar_images=None
393
  )
394
 
395
+ # Section 3: Text Box/Clear Button - 25% of viewport height
396
+ with gr.Column(elem_classes=["input-section"]):
397
+ clear = gr.Button("Clear", elem_classes=["clear-btn"])
398
  msg = gr.Textbox(
399
  placeholder="Ask me about math, research, study strategies, or any educational topic...",
400
  show_label=False,
401
  lines=1,
402
+ max_lines=6,
403
  elem_classes=["input-container"]
404
  )
405