Spaces:
Running
Running
update
Browse files- Animated_Logo_Video_Ready.gif +0 -3
- app.css +0 -614
- app.py +73 -135
- pyproject.toml +0 -36
Animated_Logo_Video_Ready.gif
DELETED
Git LFS Details
|
app.css
DELETED
|
@@ -1,614 +0,0 @@
|
|
| 1 |
-
/* Modern coding editor styling for AnyCoder */
|
| 2 |
-
|
| 3 |
-
:root {
|
| 4 |
-
--primary-color: #007acc;
|
| 5 |
-
--secondary-color: #1e1e1e;
|
| 6 |
-
--accent-color: #4ec9b0;
|
| 7 |
-
--text-color: #d4d4d4;
|
| 8 |
-
--bg-color: #252526;
|
| 9 |
-
--surface-color: #2d2d30;
|
| 10 |
-
--border-color: #3e3e42;
|
| 11 |
-
--success-color: #4ec9b0;
|
| 12 |
-
--error-color: #f44747;
|
| 13 |
-
--warning-color: #ce9178;
|
| 14 |
-
--html-bg: #ffffff;
|
| 15 |
-
--code-bg: #1e1e1e;
|
| 16 |
-
--sidebar-bg: #252526;
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
@media (prefers-color-scheme: light) {
|
| 20 |
-
:root {
|
| 21 |
-
--text-color: #333333;
|
| 22 |
-
--bg-color: #f3f3f3;
|
| 23 |
-
--surface-color: #ffffff;
|
| 24 |
-
--border-color: #e1e1e1;
|
| 25 |
-
--html-bg: #ffffff;
|
| 26 |
-
--code-bg: #f8f8f8;
|
| 27 |
-
--sidebar-bg: #f5f5f5;
|
| 28 |
-
}
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
/* App header */
|
| 32 |
-
.app-header {
|
| 33 |
-
display: flex;
|
| 34 |
-
align-items: center;
|
| 35 |
-
gap: 12px;
|
| 36 |
-
padding: 16px 24px;
|
| 37 |
-
background: var(--surface-color);
|
| 38 |
-
border-bottom: 1px solid var(--border-color);
|
| 39 |
-
margin-bottom: 0;
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
.app-header h1 {
|
| 43 |
-
margin: 0;
|
| 44 |
-
color: var(--text-color);
|
| 45 |
-
font-size: 24px;
|
| 46 |
-
font-weight: 600;
|
| 47 |
-
}
|
| 48 |
-
|
| 49 |
-
.app-header .subtitle {
|
| 50 |
-
color: var(--text-color);
|
| 51 |
-
opacity: 0.7;
|
| 52 |
-
font-size: 14px;
|
| 53 |
-
margin-left: auto;
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
/* Main layout */
|
| 57 |
-
.gradio-container {
|
| 58 |
-
background: var(--bg-color);
|
| 59 |
-
min-height: 100vh;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
/* Left sidebar */
|
| 63 |
-
.code-input {
|
| 64 |
-
background: var(--surface-color) !important;
|
| 65 |
-
border: 1px solid var(--border-color) !important;
|
| 66 |
-
border-radius: 8px !important;
|
| 67 |
-
color: var(--text-color) !important;
|
| 68 |
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
|
| 69 |
-
font-size: 14px !important;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
.code-input:focus {
|
| 73 |
-
border-color: var(--primary-color) !important;
|
| 74 |
-
box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2) !important;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
.model-display {
|
| 78 |
-
color: var(--text-color) !important;
|
| 79 |
-
font-size: 14px !important;
|
| 80 |
-
margin: 0 !important;
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
.icon-btn {
|
| 84 |
-
background: var(--surface-color) !important;
|
| 85 |
-
border: 1px solid var(--border-color) !important;
|
| 86 |
-
color: var(--text-color) !important;
|
| 87 |
-
border-radius: 6px !important;
|
| 88 |
-
padding: 8px 12px !important;
|
| 89 |
-
transition: all 0.2s ease !important;
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
.icon-btn:hover {
|
| 93 |
-
background: var(--primary-color) !important;
|
| 94 |
-
color: white !important;
|
| 95 |
-
transform: translateY(-1px) !important;
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
.generate-btn {
|
| 99 |
-
background: var(--primary-color) !important;
|
| 100 |
-
color: white !important;
|
| 101 |
-
border: none !important;
|
| 102 |
-
border-radius: 8px !important;
|
| 103 |
-
font-weight: 600 !important;
|
| 104 |
-
transition: all 0.2s ease !important;
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
.generate-btn:hover {
|
| 108 |
-
background: #005a9e !important;
|
| 109 |
-
transform: translateY(-1px) !important;
|
| 110 |
-
box-shadow: 0 4px 12px rgba(0, 122, 204, 0.3) !important;
|
| 111 |
-
}
|
| 112 |
-
|
| 113 |
-
.clear-btn {
|
| 114 |
-
background: var(--surface-color) !important;
|
| 115 |
-
border: 1px solid var(--border-color) !important;
|
| 116 |
-
color: var(--text-color) !important;
|
| 117 |
-
border-radius: 6px !important;
|
| 118 |
-
}
|
| 119 |
-
|
| 120 |
-
.quick-example-btn {
|
| 121 |
-
background: var(--surface-color) !important;
|
| 122 |
-
border: 1px solid var(--border-color) !important;
|
| 123 |
-
color: var(--text-color) !important;
|
| 124 |
-
border-radius: 6px !important;
|
| 125 |
-
font-size: 12px !important;
|
| 126 |
-
padding: 8px 12px !important;
|
| 127 |
-
transition: all 0.2s ease !important;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
-
.quick-example-btn:hover {
|
| 131 |
-
background: var(--primary-color) !important;
|
| 132 |
-
color: white !important;
|
| 133 |
-
border-color: var(--primary-color) !important;
|
| 134 |
-
}
|
| 135 |
-
|
| 136 |
-
/* Code editor tabs */
|
| 137 |
-
.code-tabs {
|
| 138 |
-
background: var(--code-bg) !important;
|
| 139 |
-
border: 1px solid var(--border-color) !important;
|
| 140 |
-
border-radius: 8px !important;
|
| 141 |
-
overflow: hidden !important;
|
| 142 |
-
}
|
| 143 |
-
|
| 144 |
-
.code-tab, .preview-tab {
|
| 145 |
-
background: var(--code-bg) !important;
|
| 146 |
-
color: var(--text-color) !important;
|
| 147 |
-
border: none !important;
|
| 148 |
-
padding: 12px 20px !important;
|
| 149 |
-
font-weight: 500 !important;
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
.code-tab[aria-selected="true"], .preview-tab[aria-selected="true"] {
|
| 153 |
-
background: var(--surface-color) !important;
|
| 154 |
-
color: var(--primary-color) !important;
|
| 155 |
-
border-bottom: 2px solid var(--primary-color) !important;
|
| 156 |
-
}
|
| 157 |
-
|
| 158 |
-
/* Code editor */
|
| 159 |
-
.code-editor {
|
| 160 |
-
background: var(--code-bg) !important;
|
| 161 |
-
border: none !important;
|
| 162 |
-
border-radius: 0 !important;
|
| 163 |
-
color: var(--text-color) !important;
|
| 164 |
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
|
| 165 |
-
font-size: 14px !important;
|
| 166 |
-
line-height: 1.5 !important;
|
| 167 |
-
min-height: 500px !important;
|
| 168 |
-
}
|
| 169 |
-
|
| 170 |
-
.code-editor .monaco-editor {
|
| 171 |
-
background: var(--code-bg) !important;
|
| 172 |
-
}
|
| 173 |
-
|
| 174 |
-
/* HTML content */
|
| 175 |
-
.html_content {
|
| 176 |
-
width: 100% !important;
|
| 177 |
-
height: 500px !important;
|
| 178 |
-
border: none !important;
|
| 179 |
-
border-radius: 0 !important;
|
| 180 |
-
background: var(--html-bg) !important;
|
| 181 |
-
}
|
| 182 |
-
|
| 183 |
-
/* Status bar */
|
| 184 |
-
.status-bar {
|
| 185 |
-
background: var(--surface-color) !important;
|
| 186 |
-
border-top: 1px solid var(--border-color) !important;
|
| 187 |
-
padding: 8px 16px !important;
|
| 188 |
-
font-size: 12px !important;
|
| 189 |
-
color: var(--text-color) !important;
|
| 190 |
-
}
|
| 191 |
-
|
| 192 |
-
.status-indicator {
|
| 193 |
-
display: flex;
|
| 194 |
-
align-items: center;
|
| 195 |
-
gap: 8px;
|
| 196 |
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
| 197 |
-
}
|
| 198 |
-
|
| 199 |
-
.status-indicator.generating {
|
| 200 |
-
color: var(--warning-color);
|
| 201 |
-
}
|
| 202 |
-
|
| 203 |
-
.status-indicator.success {
|
| 204 |
-
color: var(--success-color);
|
| 205 |
-
}
|
| 206 |
-
|
| 207 |
-
.status-indicator.error {
|
| 208 |
-
color: var(--error-color);
|
| 209 |
-
}
|
| 210 |
-
|
| 211 |
-
/* Modals */
|
| 212 |
-
.modal {
|
| 213 |
-
max-width: 420px;
|
| 214 |
-
padding: 16px 20px 12px 20px !important;
|
| 215 |
-
border-radius: 10px;
|
| 216 |
-
background: #23232b;
|
| 217 |
-
box-shadow: 0 2px 16px rgba(0,0,0,0.12);
|
| 218 |
-
border: 1px solid #29293a;
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
.modal h3 {
|
| 222 |
-
font-size: 1.1em;
|
| 223 |
-
margin-bottom: 8px;
|
| 224 |
-
margin-top: 0;
|
| 225 |
-
}
|
| 226 |
-
|
| 227 |
-
.modal-input {
|
| 228 |
-
font-size: 0.95em;
|
| 229 |
-
padding: 8px 10px;
|
| 230 |
-
border-radius: 6px;
|
| 231 |
-
background: #18181f;
|
| 232 |
-
border: 1px solid #29293a;
|
| 233 |
-
margin-bottom: 10px;
|
| 234 |
-
}
|
| 235 |
-
|
| 236 |
-
.modal .gr-button {
|
| 237 |
-
min-width: 80px;
|
| 238 |
-
height: 32px;
|
| 239 |
-
font-size: 0.95em;
|
| 240 |
-
margin-right: 8px;
|
| 241 |
-
border-radius: 6px;
|
| 242 |
-
padding: 0 10px;
|
| 243 |
-
}
|
| 244 |
-
|
| 245 |
-
/* Drawers */
|
| 246 |
-
.drawer {
|
| 247 |
-
max-width: 420px;
|
| 248 |
-
padding: 12px 16px 8px 16px !important;
|
| 249 |
-
border-radius: 10px;
|
| 250 |
-
background: #23232b;
|
| 251 |
-
box-shadow: 0 2px 16px rgba(0,0,0,0.12);
|
| 252 |
-
border: 1px solid #29293a;
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
-
.drawer h3 {
|
| 256 |
-
font-size: 1.1em;
|
| 257 |
-
margin-bottom: 8px;
|
| 258 |
-
margin-top: 0;
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
-
/* History chatbot */
|
| 262 |
-
.history_chatbot {
|
| 263 |
-
background: #18181f !important;
|
| 264 |
-
border-radius: 8px !important;
|
| 265 |
-
padding: 8px !important;
|
| 266 |
-
font-size: 0.97em !important;
|
| 267 |
-
min-height: 200px;
|
| 268 |
-
max-height: 320px;
|
| 269 |
-
overflow-y: auto;
|
| 270 |
-
}
|
| 271 |
-
|
| 272 |
-
.history_chatbot .message {
|
| 273 |
-
margin-bottom: 6px !important;
|
| 274 |
-
padding: 6px 10px !important;
|
| 275 |
-
border-radius: 6px !important;
|
| 276 |
-
}
|
| 277 |
-
|
| 278 |
-
/* Model cards */
|
| 279 |
-
.model-select-row {
|
| 280 |
-
display: flex;
|
| 281 |
-
gap: 8px;
|
| 282 |
-
justify-content: flex-start;
|
| 283 |
-
margin-bottom: 8px;
|
| 284 |
-
}
|
| 285 |
-
|
| 286 |
-
.model-card-btn {
|
| 287 |
-
min-width: 80px;
|
| 288 |
-
max-width: 120px;
|
| 289 |
-
height: 40px;
|
| 290 |
-
border-radius: 8px;
|
| 291 |
-
font-size: 1em;
|
| 292 |
-
font-weight: 600;
|
| 293 |
-
text-align: center;
|
| 294 |
-
padding: 0 8px;
|
| 295 |
-
white-space: nowrap;
|
| 296 |
-
overflow: hidden;
|
| 297 |
-
text-overflow: ellipsis;
|
| 298 |
-
transition: background 0.2s, box-shadow 0.2s;
|
| 299 |
-
}
|
| 300 |
-
|
| 301 |
-
.model-card-btn:hover {
|
| 302 |
-
background: #2a2a2a;
|
| 303 |
-
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
|
| 304 |
-
}
|
| 305 |
-
|
| 306 |
-
/* Image input */
|
| 307 |
-
.image-input {
|
| 308 |
-
background: var(--surface-color) !important;
|
| 309 |
-
border: 1px solid var(--border-color) !important;
|
| 310 |
-
border-radius: 8px !important;
|
| 311 |
-
}
|
| 312 |
-
|
| 313 |
-
/* Responsive design */
|
| 314 |
-
@media (max-width: 768px) {
|
| 315 |
-
.app-header {
|
| 316 |
-
flex-direction: column;
|
| 317 |
-
gap: 8px;
|
| 318 |
-
text-align: center;
|
| 319 |
-
}
|
| 320 |
-
|
| 321 |
-
.app-header .subtitle {
|
| 322 |
-
margin-left: 0;
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
.code-editor {
|
| 326 |
-
min-height: 300px !important;
|
| 327 |
-
}
|
| 328 |
-
|
| 329 |
-
.html_content {
|
| 330 |
-
height: 300px !important;
|
| 331 |
-
}
|
| 332 |
-
}
|
| 333 |
-
|
| 334 |
-
/* Loading animation */
|
| 335 |
-
@keyframes spin {
|
| 336 |
-
0% { transform: rotate(0deg); }
|
| 337 |
-
100% { transform: rotate(360deg); }
|
| 338 |
-
}
|
| 339 |
-
|
| 340 |
-
/* Scrollbar styling */
|
| 341 |
-
::-webkit-scrollbar {
|
| 342 |
-
width: 8px;
|
| 343 |
-
}
|
| 344 |
-
|
| 345 |
-
::-webkit-scrollbar-track {
|
| 346 |
-
background: var(--bg-color);
|
| 347 |
-
}
|
| 348 |
-
|
| 349 |
-
::-webkit-scrollbar-thumb {
|
| 350 |
-
background: var(--border-color);
|
| 351 |
-
border-radius: 4px;
|
| 352 |
-
}
|
| 353 |
-
|
| 354 |
-
::-webkit-scrollbar-thumb:hover {
|
| 355 |
-
background: var(--primary-color);
|
| 356 |
-
}
|
| 357 |
-
|
| 358 |
-
/* Sidebar styling */
|
| 359 |
-
.sidebar {
|
| 360 |
-
position: relative;
|
| 361 |
-
overflow: visible;
|
| 362 |
-
min-width: 320px;
|
| 363 |
-
max-width: 360px;
|
| 364 |
-
padding: 18px 12px 12px 12px;
|
| 365 |
-
background: #20202a;
|
| 366 |
-
border-right: 1px solid #23232b;
|
| 367 |
-
display: flex;
|
| 368 |
-
flex-direction: column;
|
| 369 |
-
gap: 12px;
|
| 370 |
-
}
|
| 371 |
-
.sidebar-header {
|
| 372 |
-
display: flex;
|
| 373 |
-
flex-direction: column;
|
| 374 |
-
align-items: center;
|
| 375 |
-
padding: 32px 0 16px 0;
|
| 376 |
-
background: var(--surface-color);
|
| 377 |
-
border-bottom: 1px solid var(--border-color);
|
| 378 |
-
}
|
| 379 |
-
.sidebar-header h1 {
|
| 380 |
-
margin: 8px 0 0 0;
|
| 381 |
-
font-size: 22px;
|
| 382 |
-
color: var(--primary-color);
|
| 383 |
-
font-weight: 700;
|
| 384 |
-
}
|
| 385 |
-
.sidebar-desc {
|
| 386 |
-
font-size: 13px;
|
| 387 |
-
color: var(--text-color);
|
| 388 |
-
opacity: 0.7;
|
| 389 |
-
margin-top: 4px;
|
| 390 |
-
text-align: center;
|
| 391 |
-
}
|
| 392 |
-
.sidebar-section {
|
| 393 |
-
padding: 18px 24px 0 24px;
|
| 394 |
-
}
|
| 395 |
-
.sidebar-section h3 {
|
| 396 |
-
font-size: 15px;
|
| 397 |
-
color: var(--primary-color);
|
| 398 |
-
margin-bottom: 8px;
|
| 399 |
-
}
|
| 400 |
-
.sidebar-section ul {
|
| 401 |
-
padding-left: 18px;
|
| 402 |
-
font-size: 13px;
|
| 403 |
-
color: var(--text-color);
|
| 404 |
-
opacity: 0.85;
|
| 405 |
-
}
|
| 406 |
-
.sidebar-btn {
|
| 407 |
-
width: 100%;
|
| 408 |
-
margin: 6px 0;
|
| 409 |
-
border-radius: 6px !important;
|
| 410 |
-
font-size: 14px !important;
|
| 411 |
-
font-weight: 500 !important;
|
| 412 |
-
background: var(--surface-color) !important;
|
| 413 |
-
color: var(--primary-color) !important;
|
| 414 |
-
border: 1px solid var(--border-color) !important;
|
| 415 |
-
transition: all 0.2s;
|
| 416 |
-
}
|
| 417 |
-
.sidebar-btn:hover {
|
| 418 |
-
background: var(--primary-color) !important;
|
| 419 |
-
color: #fff !important;
|
| 420 |
-
}
|
| 421 |
-
.quick-example-btn {
|
| 422 |
-
margin: 4px 0;
|
| 423 |
-
font-size: 13px !important;
|
| 424 |
-
background: var(--surface-color) !important;
|
| 425 |
-
color: var(--text-color) !important;
|
| 426 |
-
border: 1px solid var(--border-color) !important;
|
| 427 |
-
border-radius: 6px !important;
|
| 428 |
-
transition: all 0.2s;
|
| 429 |
-
}
|
| 430 |
-
.quick-example-btn:hover {
|
| 431 |
-
background: var(--primary-color) !important;
|
| 432 |
-
color: #fff !important;
|
| 433 |
-
}
|
| 434 |
-
|
| 435 |
-
/* Main area styling */
|
| 436 |
-
.main-area {
|
| 437 |
-
background: var(--bg-color);
|
| 438 |
-
min-height: 100vh;
|
| 439 |
-
padding: 32px 40px 32px 40px;
|
| 440 |
-
display: flex;
|
| 441 |
-
flex-direction: column;
|
| 442 |
-
box-shadow: 0 2px 16px rgba(0,0,0,0.04);
|
| 443 |
-
}
|
| 444 |
-
.model-display {
|
| 445 |
-
color: var(--primary-color) !important;
|
| 446 |
-
font-size: 15px !important;
|
| 447 |
-
margin-bottom: 8px !important;
|
| 448 |
-
}
|
| 449 |
-
.code-input, .image-input {
|
| 450 |
-
margin-bottom: 8px !important;
|
| 451 |
-
}
|
| 452 |
-
.generate-btn, .clear-btn {
|
| 453 |
-
min-width: 80px;
|
| 454 |
-
height: 32px;
|
| 455 |
-
font-size: 0.97em;
|
| 456 |
-
border-radius: 6px;
|
| 457 |
-
margin-right: 6px;
|
| 458 |
-
}
|
| 459 |
-
|
| 460 |
-
/* Code editor and preview */
|
| 461 |
-
.code-tabs {
|
| 462 |
-
background: var(--code-bg) !important;
|
| 463 |
-
border: 1px solid var(--border-color) !important;
|
| 464 |
-
border-radius: 8px !important;
|
| 465 |
-
margin-top: 24px !important;
|
| 466 |
-
overflow: hidden !important;
|
| 467 |
-
}
|
| 468 |
-
.code-tab, .preview-tab {
|
| 469 |
-
background: var(--code-bg) !important;
|
| 470 |
-
color: var(--text-color) !important;
|
| 471 |
-
border: none !important;
|
| 472 |
-
padding: 12px 20px !important;
|
| 473 |
-
font-weight: 500 !important;
|
| 474 |
-
}
|
| 475 |
-
.code-tab[aria-selected="true"], .preview-tab[aria-selected="true"] {
|
| 476 |
-
background: var(--surface-color) !important;
|
| 477 |
-
color: var(--primary-color) !important;
|
| 478 |
-
border-bottom: 2px solid var(--primary-color) !important;
|
| 479 |
-
}
|
| 480 |
-
.code-editor {
|
| 481 |
-
background: var(--code-bg) !important;
|
| 482 |
-
border: none !important;
|
| 483 |
-
border-radius: 0 !important;
|
| 484 |
-
color: var(--text-color) !important;
|
| 485 |
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
|
| 486 |
-
font-size: 15px !important;
|
| 487 |
-
line-height: 1.5 !important;
|
| 488 |
-
min-height: 500px !important;
|
| 489 |
-
}
|
| 490 |
-
.code-editor .monaco-editor {
|
| 491 |
-
background: var(--code-bg) !important;
|
| 492 |
-
}
|
| 493 |
-
.html_content {
|
| 494 |
-
width: 100% !important;
|
| 495 |
-
height: 500px !important;
|
| 496 |
-
border: none !important;
|
| 497 |
-
border-radius: 0 !important;
|
| 498 |
-
background: var(--html-bg) !important;
|
| 499 |
-
}
|
| 500 |
-
.status-bar {
|
| 501 |
-
background: var(--surface-color) !important;
|
| 502 |
-
border-top: 1px solid var(--border-color) !important;
|
| 503 |
-
padding: 8px 16px !important;
|
| 504 |
-
font-size: 13px !important;
|
| 505 |
-
color: var(--text-color) !important;
|
| 506 |
-
margin-top: 0 !important;
|
| 507 |
-
}
|
| 508 |
-
.status-indicator {
|
| 509 |
-
display: flex;
|
| 510 |
-
align-items: center;
|
| 511 |
-
gap: 8px;
|
| 512 |
-
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
| 513 |
-
}
|
| 514 |
-
.status-indicator.generating {
|
| 515 |
-
color: var(--warning-color);
|
| 516 |
-
}
|
| 517 |
-
.status-indicator.success {
|
| 518 |
-
color: var(--success-color);
|
| 519 |
-
}
|
| 520 |
-
.status-indicator.error {
|
| 521 |
-
color: var(--error-color);
|
| 522 |
-
}
|
| 523 |
-
|
| 524 |
-
/* Modal and drawer styling remain as before */
|
| 525 |
-
|
| 526 |
-
/* Responsive design */
|
| 527 |
-
@media (max-width: 900px) {
|
| 528 |
-
.main-area {
|
| 529 |
-
padding: 16px 4vw 16px 4vw;
|
| 530 |
-
}
|
| 531 |
-
.sidebar {
|
| 532 |
-
min-width: 180px;
|
| 533 |
-
padding: 0 0 0 0;
|
| 534 |
-
}
|
| 535 |
-
}
|
| 536 |
-
@media (max-width: 600px) {
|
| 537 |
-
.main-area {
|
| 538 |
-
padding: 8px 2vw 8px 2vw;
|
| 539 |
-
}
|
| 540 |
-
.sidebar {
|
| 541 |
-
display: none;
|
| 542 |
-
}
|
| 543 |
-
.code-editor {
|
| 544 |
-
min-height: 250px !important;
|
| 545 |
-
}
|
| 546 |
-
.html_content {
|
| 547 |
-
height: 220px !important;
|
| 548 |
-
}
|
| 549 |
-
}
|
| 550 |
-
|
| 551 |
-
.sidebar .modal,
|
| 552 |
-
.sidebar .drawer {
|
| 553 |
-
position: absolute;
|
| 554 |
-
left: 0;
|
| 555 |
-
top: 420px;
|
| 556 |
-
width: 100%;
|
| 557 |
-
z-index: 10;
|
| 558 |
-
background: #23232b;
|
| 559 |
-
box-shadow: 2px 0 16px rgba(0,0,0,0.18);
|
| 560 |
-
border-radius: 10px;
|
| 561 |
-
border: 1px solid #29293a;
|
| 562 |
-
padding: 18px 16px 12px 16px !important;
|
| 563 |
-
min-width: 320px;
|
| 564 |
-
max-width: 360px;
|
| 565 |
-
}
|
| 566 |
-
|
| 567 |
-
/* Sidebar section headings and text */
|
| 568 |
-
.sidebar-section h3,
|
| 569 |
-
.sidebar-section {
|
| 570 |
-
color: #4fc3f7 !important;
|
| 571 |
-
}
|
| 572 |
-
.sidebar-section ul,
|
| 573 |
-
.sidebar-section li {
|
| 574 |
-
color: #e0e0e0 !important;
|
| 575 |
-
}
|
| 576 |
-
|
| 577 |
-
/* Quick Examples heading */
|
| 578 |
-
.sidebar .sidebar-section h3 {
|
| 579 |
-
color: #4fc3f7 !important;
|
| 580 |
-
}
|
| 581 |
-
|
| 582 |
-
/* Tab labels */
|
| 583 |
-
.code-tabs .tab-nav .tab-nav-btn,
|
| 584 |
-
.code-tabs .tab-nav .tab-nav-btn.selected {
|
| 585 |
-
color: #f5f5f5 !important;
|
| 586 |
-
font-weight: 600;
|
| 587 |
-
}
|
| 588 |
-
.code-tabs .tab-nav .tab-nav-btn.selected {
|
| 589 |
-
border-bottom: 2px solid #ff9800 !important;
|
| 590 |
-
}
|
| 591 |
-
|
| 592 |
-
/* Live Preview tab content */
|
| 593 |
-
.preview-tab {
|
| 594 |
-
color: #f5f5f5 !important;
|
| 595 |
-
background: #18181f !important;
|
| 596 |
-
}
|
| 597 |
-
|
| 598 |
-
/* For light mode, override with a media query or a .light class if you support it */
|
| 599 |
-
body.light .sidebar-section h3,
|
| 600 |
-
body.light .sidebar-section {
|
| 601 |
-
color: #1976d2 !important;
|
| 602 |
-
}
|
| 603 |
-
body.light .sidebar-section ul,
|
| 604 |
-
body.light .sidebar-section li {
|
| 605 |
-
color: #222 !important;
|
| 606 |
-
}
|
| 607 |
-
body.light .code-tabs .tab-nav .tab-nav-btn,
|
| 608 |
-
body.light .code-tabs .tab-nav .tab-nav-btn.selected {
|
| 609 |
-
color: #222 !important;
|
| 610 |
-
}
|
| 611 |
-
body.light .preview-tab {
|
| 612 |
-
color: #222 !important;
|
| 613 |
-
background: #fff !important;
|
| 614 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -307,159 +307,97 @@ def generation_code(query: Optional[str], image: Optional[gr.Image], _setting: D
|
|
| 307 |
}
|
| 308 |
|
| 309 |
# Main application
|
| 310 |
-
with gr.Blocks(
|
| 311 |
history = gr.State([])
|
| 312 |
setting = gr.State({
|
| 313 |
"system": SystemPrompt,
|
| 314 |
})
|
| 315 |
current_model = gr.State(AVAILABLE_MODELS[0])
|
| 316 |
-
current_model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}", elem_classes="model-display")
|
| 317 |
open_panel = gr.State(None)
|
| 318 |
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
)
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
elem_classes="image-input"
|
| 340 |
)
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
fn=lambda idx=i: gr.update(value=DEMO_LIST[idx]['description']),
|
| 364 |
-
outputs=input
|
| 365 |
-
)
|
| 366 |
-
gr.HTML("<hr style='margin: 16px 0;'>")
|
| 367 |
-
with gr.Row():
|
| 368 |
-
modelBtn = gr.Button("🤖 Model", variant="secondary", size="sm", elem_classes="sidebar-btn")
|
| 369 |
-
settingPromptBtn = gr.Button("⚙️ Prompt", variant="secondary", size="sm", elem_classes="sidebar-btn")
|
| 370 |
-
historyBtn = gr.Button("📜 History", variant="secondary", size="sm", elem_classes="sidebar-btn")
|
| 371 |
-
# Place modals/drawers at the end of the sidebar so they overlay the lower part
|
| 372 |
-
with gr.Group(visible=False, elem_classes="modal") as system_prompt_modal:
|
| 373 |
-
gr.HTML("<h3>System Prompt Configuration</h3>")
|
| 374 |
-
systemPromptInput = gr.Textbox(
|
| 375 |
-
value=SystemPrompt,
|
| 376 |
-
label="System Prompt",
|
| 377 |
-
lines=10,
|
| 378 |
-
elem_classes="modal-input"
|
| 379 |
-
)
|
| 380 |
-
with gr.Row():
|
| 381 |
-
modal_ok_btn = gr.Button("Save", variant="primary")
|
| 382 |
-
modal_cancel_btn = gr.Button("Cancel", variant="secondary")
|
| 383 |
-
|
| 384 |
-
with gr.Group(visible=False, elem_classes="modal") as model_modal:
|
| 385 |
-
gr.HTML("<h3>Select AI Model</h3>")
|
| 386 |
-
with gr.Row(elem_classes="model-select-row"):
|
| 387 |
-
for i, model in enumerate(AVAILABLE_MODELS):
|
| 388 |
-
model_select_btn = gr.Button(
|
| 389 |
-
value=model['name'],
|
| 390 |
-
variant="secondary",
|
| 391 |
-
size="sm",
|
| 392 |
-
elem_classes="model-card-btn"
|
| 393 |
-
)
|
| 394 |
-
model_select_btn.click(
|
| 395 |
-
lambda m=model: (m, gr.update(visible=False), f"**Model:** {m['name']}", update_image_input_visibility(m)),
|
| 396 |
-
outputs=[current_model, model_modal, current_model_display, image_input]
|
| 397 |
-
)
|
| 398 |
-
|
| 399 |
-
with gr.Group(visible=False, elem_classes="drawer") as history_drawer:
|
| 400 |
-
gr.HTML("<h3>Generation History</h3>")
|
| 401 |
-
history_output = gr.Chatbot(show_label=False, height=400, elem_classes="history_chatbot")
|
| 402 |
-
# Main area
|
| 403 |
-
with gr.Column(scale=1, min_width=700, elem_classes="main-area"):
|
| 404 |
-
with gr.Row():
|
| 405 |
-
current_model_display
|
| 406 |
-
with gr.Tabs(elem_classes="code-tabs") as tabs:
|
| 407 |
-
with gr.Tab("Code Editor", elem_classes="code-tab"):
|
| 408 |
-
code_output = gr.Code(
|
| 409 |
-
language="html",
|
| 410 |
-
lines=25,
|
| 411 |
-
interactive=False,
|
| 412 |
-
elem_classes="code-editor"
|
| 413 |
-
)
|
| 414 |
-
with gr.Tab("Live Preview", elem_classes="preview-tab"):
|
| 415 |
-
sandbox = gr.HTML(elem_classes="html_content")
|
| 416 |
-
status_indicator = gr.HTML(
|
| 417 |
-
'<div class="status-indicator" id="status">Ready to generate code</div>',
|
| 418 |
-
elem_classes="status-bar"
|
| 419 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
|
| 421 |
# Event handlers
|
| 422 |
-
settingPromptBtn.click(
|
| 423 |
-
fn=lambda current: toggle_panel(current, "prompt"),
|
| 424 |
-
inputs=[open_panel],
|
| 425 |
-
outputs=[system_prompt_modal, model_modal, history_drawer, open_panel]
|
| 426 |
-
)
|
| 427 |
-
modelBtn.click(
|
| 428 |
-
fn=lambda current: toggle_panel(current, "model"),
|
| 429 |
-
inputs=[open_panel],
|
| 430 |
-
outputs=[system_prompt_modal, model_modal, history_drawer, open_panel]
|
| 431 |
-
)
|
| 432 |
-
historyBtn.click(
|
| 433 |
-
fn=lambda current, history: (*toggle_panel(current, "history")[:3], history, toggle_panel(current, "history")[3]),
|
| 434 |
-
inputs=[open_panel, history],
|
| 435 |
-
outputs=[system_prompt_modal, model_modal, history_drawer, history_output, open_panel]
|
| 436 |
-
)
|
| 437 |
-
modal_ok_btn.click(
|
| 438 |
-
lambda input: ({"system": input}, gr.update(visible=False)),
|
| 439 |
-
inputs=[systemPromptInput],
|
| 440 |
-
outputs=[setting, system_prompt_modal]
|
| 441 |
-
)
|
| 442 |
-
modal_cancel_btn.click(lambda: gr.update(visible=False), outputs=[system_prompt_modal])
|
| 443 |
btn.click(
|
| 444 |
generation_code,
|
| 445 |
inputs=[input, image_input, setting, history, current_model],
|
| 446 |
outputs=[code_output, history, sandbox, status_indicator]
|
| 447 |
)
|
| 448 |
clear_btn.click(clear_history, outputs=[history])
|
| 449 |
-
|
| 450 |
-
def
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
return (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), None)
|
| 454 |
-
# Otherwise, open the requested panel and close others
|
| 455 |
-
if panel == "prompt":
|
| 456 |
-
return (gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), "prompt")
|
| 457 |
-
elif panel == "model":
|
| 458 |
-
return (gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), "model")
|
| 459 |
-
elif panel == "history":
|
| 460 |
-
return (gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), "history")
|
| 461 |
-
else:
|
| 462 |
-
return (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), None)
|
| 463 |
|
| 464 |
if __name__ == "__main__":
|
| 465 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
|
|
|
| 307 |
}
|
| 308 |
|
| 309 |
# Main application
|
| 310 |
+
with gr.Blocks(theme=gr.themes.Base(), title="AnyCoder - AI Code Generator") as demo:
|
| 311 |
history = gr.State([])
|
| 312 |
setting = gr.State({
|
| 313 |
"system": SystemPrompt,
|
| 314 |
})
|
| 315 |
current_model = gr.State(AVAILABLE_MODELS[0])
|
|
|
|
| 316 |
open_panel = gr.State(None)
|
| 317 |
|
| 318 |
+
with gr.Sidebar():
|
| 319 |
+
gr.Markdown("# AnyCoder\nAI-Powered Code Generator")
|
| 320 |
+
gr.Markdown("""Describe your app or UI in plain English. Optionally upload a UI image (for ERNIE model). Click Generate to get code and preview.""")
|
| 321 |
+
input = gr.Textbox(
|
| 322 |
+
label="Describe your application",
|
| 323 |
+
placeholder="e.g., Create a todo app with add, delete, and mark as complete functionality",
|
| 324 |
+
lines=2
|
| 325 |
+
)
|
| 326 |
+
image_input = gr.Image(
|
| 327 |
+
label="Upload UI design image (ERNIE-4.5-VL only)",
|
| 328 |
+
visible=False
|
| 329 |
+
)
|
| 330 |
+
with gr.Row():
|
| 331 |
+
btn = gr.Button("Generate", variant="primary", size="sm")
|
| 332 |
+
clear_btn = gr.Button("Clear", variant="secondary", size="sm")
|
| 333 |
+
gr.Markdown("### Quick Examples")
|
| 334 |
+
for i, demo_item in enumerate(DEMO_LIST[:5]):
|
| 335 |
+
demo_card = gr.Button(
|
| 336 |
+
value=demo_item['title'],
|
| 337 |
+
variant="secondary",
|
| 338 |
+
size="sm"
|
| 339 |
)
|
| 340 |
+
demo_card.click(
|
| 341 |
+
fn=lambda idx=i: gr.update(value=DEMO_LIST[idx]['description']),
|
| 342 |
+
outputs=input
|
|
|
|
| 343 |
)
|
| 344 |
+
gr.Markdown("---")
|
| 345 |
+
model_dropdown = gr.Dropdown(
|
| 346 |
+
choices=[model['name'] for model in AVAILABLE_MODELS],
|
| 347 |
+
value=AVAILABLE_MODELS[0]['name'],
|
| 348 |
+
label="Select Model"
|
| 349 |
+
)
|
| 350 |
+
def on_model_change(model_name):
|
| 351 |
+
for m in AVAILABLE_MODELS:
|
| 352 |
+
if m['name'] == model_name:
|
| 353 |
+
return m, f"**Model:** {m['name']}", update_image_input_visibility(m)
|
| 354 |
+
return AVAILABLE_MODELS[0], f"**Model:** {AVAILABLE_MODELS[0]['name']}", update_image_input_visibility(AVAILABLE_MODELS[0])
|
| 355 |
+
model_display = gr.Markdown(f"**Model:** {AVAILABLE_MODELS[0]['name']}")
|
| 356 |
+
model_dropdown.change(
|
| 357 |
+
on_model_change,
|
| 358 |
+
inputs=model_dropdown,
|
| 359 |
+
outputs=[current_model, model_display, image_input]
|
| 360 |
+
)
|
| 361 |
+
with gr.Accordion("System Prompt", open=False):
|
| 362 |
+
systemPromptInput = gr.Textbox(
|
| 363 |
+
value=SystemPrompt,
|
| 364 |
+
label="System Prompt",
|
| 365 |
+
lines=10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
)
|
| 367 |
+
save_prompt_btn = gr.Button("Save", variant="primary")
|
| 368 |
+
def save_prompt(input):
|
| 369 |
+
return {setting: {"system": input}}
|
| 370 |
+
save_prompt_btn.click(save_prompt, inputs=systemPromptInput, outputs=setting)
|
| 371 |
+
|
| 372 |
+
with gr.Column():
|
| 373 |
+
model_display
|
| 374 |
+
with gr.Tabs():
|
| 375 |
+
with gr.Tab("Code Editor"):
|
| 376 |
+
code_output = gr.Code(
|
| 377 |
+
language="html",
|
| 378 |
+
lines=25,
|
| 379 |
+
interactive=False,
|
| 380 |
+
label="Generated Code"
|
| 381 |
+
)
|
| 382 |
+
with gr.Tab("Live Preview"):
|
| 383 |
+
sandbox = gr.HTML(label="Live Preview")
|
| 384 |
+
with gr.Tab("History"):
|
| 385 |
+
history_output = gr.Chatbot(show_label=False, height=400)
|
| 386 |
+
status_indicator = gr.Markdown(
|
| 387 |
+
'Ready to generate code',
|
| 388 |
+
)
|
| 389 |
|
| 390 |
# Event handlers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
btn.click(
|
| 392 |
generation_code,
|
| 393 |
inputs=[input, image_input, setting, history, current_model],
|
| 394 |
outputs=[code_output, history, sandbox, status_indicator]
|
| 395 |
)
|
| 396 |
clear_btn.click(clear_history, outputs=[history])
|
| 397 |
+
# History tab update
|
| 398 |
+
def update_history(history):
|
| 399 |
+
return history
|
| 400 |
+
history_output.change(update_history, inputs=history, outputs=history_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
|
| 402 |
if __name__ == "__main__":
|
| 403 |
demo.queue(default_concurrency_limit=20).launch(ssr_mode=False)
|
pyproject.toml
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
[project]
|
| 2 |
-
name = "anychat"
|
| 3 |
-
version = "0.1.0"
|
| 4 |
-
description = ""
|
| 5 |
-
readme = "README.md"
|
| 6 |
-
requires-python = ">=3.10"
|
| 7 |
-
dependencies = [
|
| 8 |
-
"gradio>=5.0.0",
|
| 9 |
-
"huggingface-hub>=0.30.0",
|
| 10 |
-
"modelscope-studio>=1.2.0",
|
| 11 |
-
]
|
| 12 |
-
|
| 13 |
-
[tool.uv.sources]
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
[tool.ruff]
|
| 17 |
-
line-length = 119
|
| 18 |
-
|
| 19 |
-
[tool.ruff.lint]
|
| 20 |
-
select = [
|
| 21 |
-
"E",
|
| 22 |
-
"F",
|
| 23 |
-
#"I",
|
| 24 |
-
"N",
|
| 25 |
-
"S",
|
| 26 |
-
"T",
|
| 27 |
-
"UP",
|
| 28 |
-
"W",
|
| 29 |
-
]
|
| 30 |
-
ignore = ["T201"]
|
| 31 |
-
unfixable = [
|
| 32 |
-
"F401", # unused-import
|
| 33 |
-
]
|
| 34 |
-
|
| 35 |
-
[tool.ruff.format]
|
| 36 |
-
docstring-code-format = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|