WillHeld commited on
Commit
a328054
·
verified ·
1 Parent(s): 6956a00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -26
app.py CHANGED
@@ -186,32 +186,46 @@ def get_stats():
186
  }
187
 
188
 
189
- # Create a custom Stanford theme
190
- class StanfordTheme(gr.Theme):
191
- def __init__(self):
192
- super().__init__(
193
- primary_hue={"name": "cardinal", "c50": "#F9E8E8", "c100": "#F0C9C9", "c200": "#E39B9B",
194
- "c300": "#D66E6E", "c400": "#C94A4A", "c500": "#B82C2C", "c600": "#8C1515",
195
- "c700": "#771212", "c800": "#620E0E", "c900": "#4D0A0A", "c950": "#380707"},
196
- secondary_hue={"name": "cool_gray", "c50": "#F5F5F6", "c100": "#E6E7E8", "c200": "#CDCED0",
197
- "c300": "#B3B5B8", "c400": "#9A9CA0", "c500": "#818388", "c600": "#4D4F53",
198
- "c700": "#424448", "c800": "#36383A", "c900": "#2E2D29", "c950": "#1D1D1B"},
199
- neutral_hue="gray",
200
- radius_size=gr.themes.sizes.radius_sm,
201
- font=[gr.themes.GoogleFont("Source Sans Pro"), "ui-sans-serif", "system-ui"]
202
- )
 
 
 
 
 
 
203
 
204
- # Use the Stanford theme
205
- theme = StanfordTheme()
 
 
 
 
 
 
 
 
206
 
207
  # Set up the Gradio app
208
- with gr.Blocks(theme=theme, title="Stanford Soft Raccoon Chat with Dataset Collection") as demo:
209
  conversation_id = gr.State("")
210
 
211
  with gr.Row():
212
  with gr.Column(scale=3):
213
  chatbot = gr.Chatbot(
214
- label="Stanford Soft Raccoon Chat",
215
  avatar_images=(None, "🌲"), # Stanford tree emoji
216
  height=600
217
  )
@@ -292,8 +306,7 @@ with gr.Blocks(theme=theme, title="Stanford Soft Raccoon Chat with Dataset Colle
292
  )
293
 
294
  # Auto-update stats every 30 seconds
295
- gr.on(
296
- [demo.load, gr.Timeout(30)],
297
  update_stats,
298
  [],
299
  [convo_count, next_save, last_save_time_display, dataset_name_display]
@@ -302,12 +315,6 @@ with gr.Blocks(theme=theme, title="Stanford Soft Raccoon Chat with Dataset Colle
302
  # Ensure we save on shutdown using atexit
303
  import atexit
304
  atexit.register(save_to_dataset)
305
-
306
- # Set up a function that will be called when the demo loads
307
- def on_startup():
308
- return update_stats()
309
-
310
- demo.load(on_startup, [], [convo_count, next_save, last_save_time_display, dataset_name_display])
311
 
312
  # Launch the app
313
  if __name__ == "__main__":
 
186
  }
187
 
188
 
189
+ # Create a Stanford theme using the simpler approach from Gradio examples
190
+ theme = gr.themes.Default(
191
+ primary_hue=gr.themes.utils.colors.red,
192
+ secondary_hue=gr.themes.utils.colors.gray,
193
+ neutral_hue=gr.themes.utils.colors.gray,
194
+ font=[gr.themes.GoogleFont("Source Sans Pro"), "ui-sans-serif", "system-ui"]
195
+ ).set(
196
+ button_primary_background_fill="#8C1515",
197
+ button_primary_background_fill_hover="#771212",
198
+ button_primary_text_color="white",
199
+ slider_color="#8C1515",
200
+ block_title_text_color="#8C1515",
201
+ block_label_text_color="#4D4F53",
202
+ input_border_color_focus="#8C1515",
203
+ checkbox_background_color_selected="#8C1515",
204
+ checkbox_border_color_selected="#8C1515",
205
+ button_secondary_border_color="#4D4F53",
206
+ block_title_background_fill="#f5f5f5",
207
+ block_label_background_fill="#f9f9f9"
208
+ )
209
 
210
+ # Custom CSS for additional Stanford styling
211
+ css = """
212
+ .gradio-container {
213
+ font-family: 'Source Sans Pro', sans-serif !important;
214
+ }
215
+ .footer {
216
+ color: #4D4F53 !important;
217
+ font-size: 0.85em !important;
218
+ }
219
+ """
220
 
221
  # Set up the Gradio app
222
+ with gr.Blocks(theme=theme, title="Stanford Soft Raccoon Chat", css=css) as demo:
223
  conversation_id = gr.State("")
224
 
225
  with gr.Row():
226
  with gr.Column(scale=3):
227
  chatbot = gr.Chatbot(
228
+ label="Soft Raccoon Chat",
229
  avatar_images=(None, "🌲"), # Stanford tree emoji
230
  height=600
231
  )
 
306
  )
307
 
308
  # Auto-update stats every 30 seconds
309
+ demo.load(
 
310
  update_stats,
311
  [],
312
  [convo_count, next_save, last_save_time_display, dataset_name_display]
 
315
  # Ensure we save on shutdown using atexit
316
  import atexit
317
  atexit.register(save_to_dataset)
 
 
 
 
 
 
318
 
319
  # Launch the app
320
  if __name__ == "__main__":