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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
custom_theme = gr.themes.Default(
|
| 4 |
primary_hue="blue", # This changes the primary color to blue
|
| 5 |
secondary_hue="blue",
|
|
@@ -16,6 +375,6 @@ custom_theme = gr.themes.Default(
|
|
| 16 |
token = os.environ["TOKEN"]
|
| 17 |
model=os.environ["MODEL"]
|
| 18 |
loaded_demo = gr.load(model, src="spaces", token=token)
|
| 19 |
-
with gr.Blocks(fill_height=True,theme=custom_theme) as demo:
|
| 20 |
loaded_demo.render()
|
| 21 |
demo.launch(show_api=False, show_error=False, quiet=True, debug=False)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
+
# Define the CSS once to avoid duplication (rest of CSS remains the same)
|
| 4 |
+
CSS_STYLES = """
|
| 5 |
+
.gradio-container footer { display: none !important; }
|
| 6 |
+
.logo-container{ display: inline-flex; justify-content: center; align-items: center; column-gap: 12px;}
|
| 7 |
+
.logo-container .cyphertech { max-width:8rem; width:100%; height: auto; object-fit: contain; }
|
| 8 |
+
.logo-container .seperator:after{ font-size: 3.5em; content: "|"; color: #fff; font-weight: 500; font-family: auto; }
|
| 9 |
+
.logo-container .askcyph { max-width: 13rem; width:100%; height: auto; object-fit: contain; }
|
| 10 |
+
|
| 11 |
+
/* Fix for keeping focus on input */
|
| 12 |
+
.chat-interface textarea {
|
| 13 |
+
caret-color: auto !important;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/* Loader Styles */
|
| 17 |
+
#page-loader {
|
| 18 |
+
position: fixed;
|
| 19 |
+
top: 0;
|
| 20 |
+
left: 0;
|
| 21 |
+
width: 100%;
|
| 22 |
+
height: 100%;
|
| 23 |
+
background: linear-gradient(135deg, #001a2d 0%, #002a4d 100%);
|
| 24 |
+
z-index: 3147483647;
|
| 25 |
+
display: flex;
|
| 26 |
+
justify-content: center;
|
| 27 |
+
align-items: center;
|
| 28 |
+
transition: opacity 0.5s ease-out;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
#page-loader.hide {
|
| 32 |
+
opacity: 0 !important;
|
| 33 |
+
pointer-events: none !important;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
#page-loader.remove {
|
| 37 |
+
display: none !important;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
.loader-content {
|
| 41 |
+
text-align: center;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.loader-logo {
|
| 45 |
+
max-width: 200px;
|
| 46 |
+
opacity: 0;
|
| 47 |
+
animation: fadeInLogo 1s ease-in-out forwards;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.spinner-container {
|
| 51 |
+
margin-top: 30px;
|
| 52 |
+
position: relative;
|
| 53 |
+
width: 80px;
|
| 54 |
+
height: 80px;
|
| 55 |
+
margin-left: auto;
|
| 56 |
+
margin-right: auto;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.spinner {
|
| 60 |
+
width: 80px;
|
| 61 |
+
height: 80px;
|
| 62 |
+
border: 4px solid rgba(255, 255, 255, 0.1);
|
| 63 |
+
border-top-color: #0071bb;
|
| 64 |
+
border-radius: 50%;
|
| 65 |
+
animation: spin 1s linear infinite;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.spinner-inner {
|
| 69 |
+
position: absolute;
|
| 70 |
+
top: 10px;
|
| 71 |
+
left: 10px;
|
| 72 |
+
width: 60px;
|
| 73 |
+
height: 60px;
|
| 74 |
+
border: 3px solid transparent;
|
| 75 |
+
border-top-color: #00a8ff;
|
| 76 |
+
border-radius: 50%;
|
| 77 |
+
animation: spin 0.7s linear infinite reverse;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.loading-text {
|
| 81 |
+
margin-top: 20px;
|
| 82 |
+
color: #fff;
|
| 83 |
+
font-size: 18px;
|
| 84 |
+
font-weight: 300;
|
| 85 |
+
opacity: 0;
|
| 86 |
+
animation: fadeInText 1s ease-in-out 0.5s forwards;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.loading-dots {
|
| 90 |
+
display: inline-block;
|
| 91 |
+
width: 20px;
|
| 92 |
+
text-align: left;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
.loading-dots::after {
|
| 96 |
+
content: '.';
|
| 97 |
+
animation: dots 1.5s steps(4, end) infinite;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
@keyframes spin {
|
| 101 |
+
0% { transform: rotate(0deg); }
|
| 102 |
+
100% { transform: rotate(360deg); }
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
@keyframes fadeInLogo {
|
| 106 |
+
0% {
|
| 107 |
+
opacity: 0;
|
| 108 |
+
transform: translateY(-20px);
|
| 109 |
+
}
|
| 110 |
+
100% {
|
| 111 |
+
opacity: 1;
|
| 112 |
+
transform: translateY(0);
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
@keyframes fadeInText {
|
| 117 |
+
0% { opacity: 0; }
|
| 118 |
+
100% { opacity: 1; }
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
@keyframes dots {
|
| 122 |
+
0%, 20% { content: '.'; }
|
| 123 |
+
40% { content: '..'; }
|
| 124 |
+
60% { content: '...'; }
|
| 125 |
+
80%, 100% { content: ''; }
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.progress-bar {
|
| 129 |
+
width: 200px;
|
| 130 |
+
height: 4px;
|
| 131 |
+
background: rgba(255, 255, 255, 0.1);
|
| 132 |
+
border-radius: 2px;
|
| 133 |
+
margin: 20px auto;
|
| 134 |
+
overflow: hidden;
|
| 135 |
+
opacity: 0;
|
| 136 |
+
animation: fadeInText 1s ease-in-out 0.8s forwards;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.progress-fill {
|
| 140 |
+
height: 100%;
|
| 141 |
+
background: linear-gradient(90deg, #0071bb 0%, #00a8ff 100%);
|
| 142 |
+
border-radius: 2px;
|
| 143 |
+
width: 0%;
|
| 144 |
+
animation: progressAnimation 4.5s ease-out forwards;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
@keyframes progressAnimation {
|
| 148 |
+
0% { width: 0%; }
|
| 149 |
+
20% { width: 25%; }
|
| 150 |
+
40% { width: 45%; }
|
| 151 |
+
60% { width: 65%; }
|
| 152 |
+
80% { width: 85%; }
|
| 153 |
+
100% { width: 100%; }
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
#welcome-banner-overlay {
|
| 158 |
+
display: none;
|
| 159 |
+
position: fixed;
|
| 160 |
+
top: 0;
|
| 161 |
+
left: 0;
|
| 162 |
+
width: 100%;
|
| 163 |
+
height: 100%;
|
| 164 |
+
background-color: rgba(0,0,0,0.5);
|
| 165 |
+
z-index: 1999;
|
| 166 |
+
}
|
| 167 |
+
#welcome-banner-text {
|
| 168 |
+
display: none;
|
| 169 |
+
position: fixed;
|
| 170 |
+
top: 50%;
|
| 171 |
+
left: 50%;
|
| 172 |
+
transform: translate(-50%, -50%);
|
| 173 |
+
max-width: 800px;
|
| 174 |
+
width: 80%;
|
| 175 |
+
height: 73vh;
|
| 176 |
+
z-index: 2000;
|
| 177 |
+
background-color: rgba(0,113,187,0.6);
|
| 178 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 179 |
+
border-radius: 8px;
|
| 180 |
+
border-left: 4px solid #0071bb;
|
| 181 |
+
flex-direction: column;
|
| 182 |
+
padding: 15px;
|
| 183 |
+
}
|
| 184 |
+
#welcome-banner-header {
|
| 185 |
+
padding-bottom: 10px;
|
| 186 |
+
border-bottom: 1px solid rgba(255,255,255,0.2);
|
| 187 |
+
}
|
| 188 |
+
#welcome-banner-content {
|
| 189 |
+
overflow-y: auto;
|
| 190 |
+
padding: 0 15px;
|
| 191 |
+
flex-grow: 1;
|
| 192 |
+
max-height: calc(70vh - 100px);
|
| 193 |
+
}
|
| 194 |
+
#welcome-banner-footer {
|
| 195 |
+
padding-top: 10px;
|
| 196 |
+
margin-top: 10px;
|
| 197 |
+
border-top: 1px solid rgba(255,255,255,0.2);
|
| 198 |
+
text-align: right;
|
| 199 |
+
}
|
| 200 |
+
#ok-banner {
|
| 201 |
+
padding: 8px 20px;
|
| 202 |
+
background-color: transparent;
|
| 203 |
+
color: white;
|
| 204 |
+
border: 1px solid white;
|
| 205 |
+
border-radius: 4px;
|
| 206 |
+
cursor: pointer;
|
| 207 |
+
font-weight: bold;
|
| 208 |
+
transition: all 0.2s ease;
|
| 209 |
+
}
|
| 210 |
+
#ok-banner:hover {
|
| 211 |
+
background-color: rgba(255,255,255,0.1);
|
| 212 |
+
}
|
| 213 |
+
#close-banner {
|
| 214 |
+
position: absolute;
|
| 215 |
+
top: 10px;
|
| 216 |
+
right: 10px;
|
| 217 |
+
cursor: pointer;
|
| 218 |
+
font-weight: bold;
|
| 219 |
+
font-size: 20px;
|
| 220 |
+
color: #666;
|
| 221 |
+
z-index: 10;
|
| 222 |
+
width: 30px;
|
| 223 |
+
height: 30px;
|
| 224 |
+
display: flex;
|
| 225 |
+
align-items: center;
|
| 226 |
+
justify-content: center;
|
| 227 |
+
border-radius: 50%;
|
| 228 |
+
background-color: #f0f0f0;
|
| 229 |
+
transition: all 0.2s ease;
|
| 230 |
+
}
|
| 231 |
+
#close-banner:hover {
|
| 232 |
+
background-color: #ddd;
|
| 233 |
+
color: #333;
|
| 234 |
+
}
|
| 235 |
+
/* Help button styling */
|
| 236 |
+
.help-button-container {
|
| 237 |
+
position: fixed;
|
| 238 |
+
bottom: 50px;
|
| 239 |
+
left: 20px;
|
| 240 |
+
z-index: 1000;
|
| 241 |
+
}
|
| 242 |
+
.help-button {
|
| 243 |
+
background-color: #0071bb !important;
|
| 244 |
+
color: white !important;
|
| 245 |
+
border: none;
|
| 246 |
+
border-radius: 50%;
|
| 247 |
+
width: 50px;
|
| 248 |
+
height: 50px;
|
| 249 |
+
font-size: 24px !important;
|
| 250 |
+
cursor: pointer;
|
| 251 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
|
| 252 |
+
display: flex !important;
|
| 253 |
+
align-items: center !important;
|
| 254 |
+
justify-content: center !important;
|
| 255 |
+
transition: all 0.3s ease;
|
| 256 |
+
}
|
| 257 |
+
.help-button:hover {
|
| 258 |
+
background-color: #005a94;
|
| 259 |
+
transform: scale(1.05);
|
| 260 |
+
box-shadow: 0 6px 12px rgba(0,0,0,0.3);
|
| 261 |
+
}
|
| 262 |
+
.footer{ width:100%; margin: 10px 0; background-color: initial; color: #fff; text-align: center; font-size: 1rem; font-style=bold; }
|
| 263 |
+
.footer a{ color: #fff !important }
|
| 264 |
+
.footer {
|
| 265 |
+
text-align: center;
|
| 266 |
+
padding: 3rem 0 2rem;
|
| 267 |
+
margin-top: 4rem;
|
| 268 |
+
border-top: 1px solid #2a2a2a;
|
| 269 |
+
color: #a0a0a0;
|
| 270 |
+
}
|
| 271 |
+
.footer a {
|
| 272 |
+
color: #a0a0a0 !important;
|
| 273 |
+
text-decoration: none;
|
| 274 |
+
}
|
| 275 |
+
.footer a:hover {
|
| 276 |
+
color: #ffffff !important;
|
| 277 |
+
}
|
| 278 |
+
/* Change orange button and slider color to #0071bb */
|
| 279 |
+
.primary-button { background-color: #0071bb !important; }
|
| 280 |
+
button.primary { background-color: #0071bb !important; }
|
| 281 |
+
.gradio-button.primary { background-color: #0071bb !important; }
|
| 282 |
+
/* Improved slider styling */
|
| 283 |
+
.slider_input_container {
|
| 284 |
+
--slider-color: #0071bb !important;
|
| 285 |
+
}
|
| 286 |
+
/* Target all slider thumbs */
|
| 287 |
+
input[type=range]::-webkit-slider-thumb {
|
| 288 |
+
background: #0071bb !important;
|
| 289 |
+
border-color: #0071bb !important;
|
| 290 |
+
}
|
| 291 |
+
input[type=range]::-moz-range-thumb {
|
| 292 |
+
background: #0071bb !important;
|
| 293 |
+
border-color: #0071bb !important;
|
| 294 |
+
}
|
| 295 |
+
input[type=range]::-ms-thumb {
|
| 296 |
+
background: #0071bb !important;
|
| 297 |
+
border-color: #0071bb !important;
|
| 298 |
+
}
|
| 299 |
+
/* Fix for slider track fill */
|
| 300 |
+
.gradio-slider .svelte-1cl284s {
|
| 301 |
+
background-color: #0071bb !important;
|
| 302 |
+
}
|
| 303 |
+
/* Target Gradio's slider elements more specifically */
|
| 304 |
+
.gradio-slider [data-testid="slider-handle"] {
|
| 305 |
+
background-color: #0071bb !important;
|
| 306 |
+
}
|
| 307 |
+
.gradio-slider [data-testid="slider-track-filled"],
|
| 308 |
+
.gradio-slider .track-fill,
|
| 309 |
+
.gradio-slider .track-progress {
|
| 310 |
+
background-color: #0071bb !important;
|
| 311 |
+
}
|
| 312 |
+
/* Target the slider track */
|
| 313 |
+
.gradio-slider [data-testid="slider-track"] {
|
| 314 |
+
background-color: #ddd !important;
|
| 315 |
+
}
|
| 316 |
+
/* Target any element with slider-related class names */
|
| 317 |
+
div[class*="slider"] div[class*="filled"],
|
| 318 |
+
div[class*="slider"] div[class*="progress"],
|
| 319 |
+
div[class*="slider"] div[class*="track-fill"],
|
| 320 |
+
div[class*="slider"] div[class*="track-progress"] {
|
| 321 |
+
background-color: #0071bb !important;
|
| 322 |
+
}
|
| 323 |
+
/* Change focus outline color */
|
| 324 |
+
*:focus-visible { outline-color: #0071bb !important; }
|
| 325 |
+
/* Change checkbox and radio button colors */
|
| 326 |
+
input[type="checkbox"]:checked, input[type="radio"]:checked {
|
| 327 |
+
background-color: #0071bb !important;
|
| 328 |
+
border-color: #0071bb !important;
|
| 329 |
+
}
|
| 330 |
+
/* Change progress bar color */
|
| 331 |
+
progress::-webkit-progress-value { background-color: #0071bb !important; }
|
| 332 |
+
progress::-moz-progress-bar { background-color: #0071bb !important; }
|
| 333 |
+
progress { color: #0071bb !important; }
|
| 334 |
+
/* Change link color */
|
| 335 |
+
a { color: #0071bb !important; }
|
| 336 |
+
/* Change selection color */
|
| 337 |
+
::selection { background-color: #0071bb33 !important; }
|
| 338 |
+
@media(max-width: 500px){
|
| 339 |
+
#welcome-banner-text {
|
| 340 |
+
max-width: 90%;
|
| 341 |
+
}
|
| 342 |
+
}
|
| 343 |
+
#huggingface-space-header{
|
| 344 |
+
display: none !important;
|
| 345 |
+
}
|
| 346 |
+
/* Scrollbar styling for welcome dialog */
|
| 347 |
+
#welcome-banner-text > div:nth-child(2)::-webkit-scrollbar {
|
| 348 |
+
width: 8px;
|
| 349 |
+
}
|
| 350 |
+
#welcome-banner-text > div:nth-child(2)::-webkit-scrollbar-track {
|
| 351 |
+
background: rgba(255,255,255,0.1);
|
| 352 |
+
border-radius: 4px;
|
| 353 |
+
}
|
| 354 |
+
#welcome-banner-text > div:nth-child(2)::-webkit-scrollbar-thumb {
|
| 355 |
+
background: rgba(255,255,255,0.3);
|
| 356 |
+
border-radius: 4px;
|
| 357 |
+
}
|
| 358 |
+
#welcome-banner-text > div:nth-child(2)::-webkit-scrollbar-thumb:hover {
|
| 359 |
+
background: rgba(255,255,255,0.5);
|
| 360 |
+
}
|
| 361 |
+
"""
|
| 362 |
custom_theme = gr.themes.Default(
|
| 363 |
primary_hue="blue", # This changes the primary color to blue
|
| 364 |
secondary_hue="blue",
|
|
|
|
| 375 |
token = os.environ["TOKEN"]
|
| 376 |
model=os.environ["MODEL"]
|
| 377 |
loaded_demo = gr.load(model, src="spaces", token=token)
|
| 378 |
+
with gr.Blocks(fill_height=True,css=CSS_STYLES,theme=custom_theme) as demo:
|
| 379 |
loaded_demo.render()
|
| 380 |
demo.launch(show_api=False, show_error=False, quiet=True, debug=False)
|