Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import os
|
|
@@ -119,12 +120,23 @@ custom_css = f"""
|
|
| 119 |
}}
|
| 120 |
|
| 121 |
/* Description text */
|
| 122 |
-
|
| 123 |
-
color:
|
| 124 |
font-size: 16px !important;
|
| 125 |
margin-bottom: 20px !important;
|
| 126 |
}}
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
/* User messages */
|
| 129 |
#chatbot-window .message.user {{
|
| 130 |
background-color: {SECONDARY_COLOR} !important;
|
|
@@ -148,10 +160,30 @@ custom_css = f"""
|
|
| 148 |
#chatbot-window .message.bot p{{
|
| 149 |
color: white !important;
|
| 150 |
}}
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
/* Input textbox */
|
| 153 |
-
|
| 154 |
background-color: {BACKGROUND_COLOR} !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
}}
|
| 156 |
|
| 157 |
#input-textbox textarea{{
|
|
@@ -171,6 +203,7 @@ custom_css = f"""
|
|
| 171 |
button {{
|
| 172 |
border-radius: 8px !important;
|
| 173 |
font-weight: 600 !important;
|
|
|
|
| 174 |
}}
|
| 175 |
|
| 176 |
|
|
@@ -179,6 +212,7 @@ custom_css = f"""
|
|
| 179 |
background-color: {PRIMARY_COLOR} !important;
|
| 180 |
color: white !important;
|
| 181 |
border: none !important;
|
|
|
|
| 182 |
}}
|
| 183 |
|
| 184 |
#send-button:hover {{
|
|
@@ -223,9 +257,14 @@ with gr.Blocks(css=custom_css, analytics_enabled=False) as chatui:
|
|
| 223 |
# Description
|
| 224 |
gr.Markdown(
|
| 225 |
"Ask Cosmo the cougar questions related to Crown Pointe Academy policies.",
|
| 226 |
-
elem_classes="description"
|
|
|
|
| 227 |
)
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
# Chatbot component - MUST use type='messages'
|
| 230 |
chatbot = gr.Chatbot(
|
| 231 |
type='messages',
|
|
@@ -238,7 +277,7 @@ with gr.Blocks(css=custom_css, analytics_enabled=False) as chatui:
|
|
| 238 |
with gr.Row():
|
| 239 |
msg = gr.Textbox(
|
| 240 |
label="",
|
| 241 |
-
placeholder="Type your
|
| 242 |
scale=4,
|
| 243 |
show_label=False,
|
| 244 |
elem_id="input-textbox"
|
|
@@ -253,8 +292,9 @@ with gr.Blocks(css=custom_css, analytics_enabled=False) as chatui:
|
|
| 253 |
# Example buttons
|
| 254 |
gr.Examples(
|
| 255 |
examples=[
|
| 256 |
-
"
|
| 257 |
-
"
|
|
|
|
| 258 |
],
|
| 259 |
inputs=msg,
|
| 260 |
label="Try these examples:",
|
|
|
|
| 1 |
+
from turtle import color
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import os
|
|
|
|
| 120 |
}}
|
| 121 |
|
| 122 |
/* Description text */
|
| 123 |
+
#descr p{{
|
| 124 |
+
color: black !important;
|
| 125 |
font-size: 16px !important;
|
| 126 |
margin-bottom: 20px !important;
|
| 127 |
}}
|
| 128 |
|
| 129 |
+
#disclaimer {{
|
| 130 |
+
background-color: {PRIMARY_COLOR} !important;
|
| 131 |
+
color: white !important;
|
| 132 |
+
font-size: 16px !important;
|
| 133 |
+
border: 2px solid {SECONDARY_COLOR} !important;
|
| 134 |
+
border-radius: 8px !important;
|
| 135 |
+
}}
|
| 136 |
+
#disclaimer p {{
|
| 137 |
+
color: white !important;
|
| 138 |
+
}}
|
| 139 |
+
|
| 140 |
/* User messages */
|
| 141 |
#chatbot-window .message.user {{
|
| 142 |
background-color: {SECONDARY_COLOR} !important;
|
|
|
|
| 160 |
#chatbot-window .message.bot p{{
|
| 161 |
color: white !important;
|
| 162 |
}}
|
| 163 |
+
/* All text inside bot messages, avoids changes from browser theme */
|
| 164 |
+
#chatbot-window .message.bot *,
|
| 165 |
+
#chatbot-window .message.bot li {{
|
| 166 |
+
color: white !important;
|
| 167 |
+
}}
|
| 168 |
/* Input textbox */
|
| 169 |
+
#input-textbox {{
|
| 170 |
background-color: {BACKGROUND_COLOR} !important;
|
| 171 |
+
|
| 172 |
+
}}
|
| 173 |
+
|
| 174 |
+
/* this gets the text box and send button to align */
|
| 175 |
+
#component-4 {{
|
| 176 |
+
display: flex; /* ensure it's a flex container */
|
| 177 |
+
align-items: center; /* vertically centers children */
|
| 178 |
+
gap: 10px; /* optional spacing between textbox & button */
|
| 179 |
+
}}
|
| 180 |
+
|
| 181 |
+
/* this removes the text box border that was unnecessary */
|
| 182 |
+
div.form {{
|
| 183 |
+
--block-border-width: 0px !important;
|
| 184 |
+
--block-shadow: none !important;
|
| 185 |
+
--block-radius: 0px !important;
|
| 186 |
+
padding: 0 !important;
|
| 187 |
}}
|
| 188 |
|
| 189 |
#input-textbox textarea{{
|
|
|
|
| 203 |
button {{
|
| 204 |
border-radius: 8px !important;
|
| 205 |
font-weight: 600 !important;
|
| 206 |
+
|
| 207 |
}}
|
| 208 |
|
| 209 |
|
|
|
|
| 212 |
background-color: {PRIMARY_COLOR} !important;
|
| 213 |
color: white !important;
|
| 214 |
border: none !important;
|
| 215 |
+
|
| 216 |
}}
|
| 217 |
|
| 218 |
#send-button:hover {{
|
|
|
|
| 257 |
# Description
|
| 258 |
gr.Markdown(
|
| 259 |
"Ask Cosmo the cougar questions related to Crown Pointe Academy policies.",
|
| 260 |
+
elem_classes="description",
|
| 261 |
+
elem_id="descr"
|
| 262 |
)
|
| 263 |
|
| 264 |
+
#Diclaimer
|
| 265 |
+
gr.HTML("<p> I am an AI guide on school policies, not the official source. I may " \
|
| 266 |
+
"generate misinformation. Verify all results with official school documents. </p>", elem_id="disclaimer")
|
| 267 |
+
|
| 268 |
# Chatbot component - MUST use type='messages'
|
| 269 |
chatbot = gr.Chatbot(
|
| 270 |
type='messages',
|
|
|
|
| 277 |
with gr.Row():
|
| 278 |
msg = gr.Textbox(
|
| 279 |
label="",
|
| 280 |
+
placeholder="Type your question here...",
|
| 281 |
scale=4,
|
| 282 |
show_label=False,
|
| 283 |
elem_id="input-textbox"
|
|
|
|
| 292 |
# Example buttons
|
| 293 |
gr.Examples(
|
| 294 |
examples=[
|
| 295 |
+
"What is the dress code for students?",
|
| 296 |
+
"How do I report an absence?",
|
| 297 |
+
"What is the policy on cell phones?"
|
| 298 |
],
|
| 299 |
inputs=msg,
|
| 300 |
label="Try these examples:",
|