Update app.py
Browse files
app.py
CHANGED
|
@@ -186,32 +186,46 @@ def get_stats():
|
|
| 186 |
}
|
| 187 |
|
| 188 |
|
| 189 |
-
# Create a
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
-
#
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
# Set up the Gradio app
|
| 208 |
-
with gr.Blocks(theme=theme, title="Stanford Soft Raccoon Chat
|
| 209 |
conversation_id = gr.State("")
|
| 210 |
|
| 211 |
with gr.Row():
|
| 212 |
with gr.Column(scale=3):
|
| 213 |
chatbot = gr.Chatbot(
|
| 214 |
-
label="
|
| 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 |
-
|
| 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__":
|