Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,18 +251,22 @@ Provide a thorough and helpful response. If suggesting code changes, provide com
|
|
| 251 |
# Initialize the copilot
|
| 252 |
copilot = CodingCopilot()
|
| 253 |
|
| 254 |
-
# FIXED CSS - Proper
|
| 255 |
-
|
| 256 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
.gradio-container {
|
| 258 |
max-width: none !important;
|
| 259 |
-
width:
|
| 260 |
-
height: 100vh !important;
|
| 261 |
background: #0a0a0a !important;
|
| 262 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
|
| 263 |
color: #ffffff !important;
|
| 264 |
padding: 1rem !important;
|
| 265 |
-
|
| 266 |
}
|
| 267 |
|
| 268 |
/* Header */
|
|
@@ -294,32 +298,32 @@ desktop_css = """
|
|
| 294 |
font-weight: 400 !important;
|
| 295 |
}
|
| 296 |
|
| 297 |
-
/* Main layout
|
| 298 |
-
.main-
|
| 299 |
display: flex !important;
|
| 300 |
flex-direction: row !important;
|
| 301 |
gap: 1.5rem !important;
|
| 302 |
-
|
| 303 |
-
min-height:
|
| 304 |
}
|
| 305 |
|
| 306 |
-
/* Sidebar */
|
| 307 |
-
.sidebar
|
| 308 |
background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%) !important;
|
| 309 |
border: 1px solid #dc2626 !important;
|
| 310 |
border-radius: 16px !important;
|
| 311 |
padding: 1.5rem !important;
|
| 312 |
-
width:
|
| 313 |
-
min-width:
|
| 314 |
-
max-width:
|
| 315 |
flex-shrink: 0 !important;
|
| 316 |
box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1) !important;
|
| 317 |
overflow-y: auto !important;
|
| 318 |
-
height:
|
| 319 |
}
|
| 320 |
|
| 321 |
-
/* Chat
|
| 322 |
-
.chat-
|
| 323 |
background: linear-gradient(180deg, #111111 0%, #0a0a0a 100%) !important;
|
| 324 |
border: 1px solid #262626 !important;
|
| 325 |
border-radius: 16px !important;
|
|
@@ -328,19 +332,19 @@ desktop_css = """
|
|
| 328 |
flex-direction: column !important;
|
| 329 |
overflow: hidden !important;
|
| 330 |
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
| 331 |
-
height:
|
| 332 |
}
|
| 333 |
|
| 334 |
-
/* Chat
|
| 335 |
-
.chat-
|
| 336 |
flex: 1 !important;
|
| 337 |
overflow-y: auto !important;
|
| 338 |
padding: 1.5rem !important;
|
| 339 |
-
min-height:
|
| 340 |
}
|
| 341 |
|
| 342 |
-
/*
|
| 343 |
-
.
|
| 344 |
flex-shrink: 0 !important;
|
| 345 |
background: #1a1a1a !important;
|
| 346 |
border-top: 1px solid #262626 !important;
|
|
@@ -351,7 +355,7 @@ desktop_css = """
|
|
| 351 |
}
|
| 352 |
|
| 353 |
/* Quick Actions */
|
| 354 |
-
.quick-actions
|
| 355 |
margin-bottom: 2rem !important;
|
| 356 |
padding-bottom: 1.5rem !important;
|
| 357 |
border-bottom: 1px solid #dc2626 !important;
|
|
@@ -369,7 +373,7 @@ desktop_css = """
|
|
| 369 |
gap: 0.5rem !important;
|
| 370 |
}
|
| 371 |
|
| 372 |
-
.quick-
|
| 373 |
background: #1a1a1a !important;
|
| 374 |
color: #dc2626 !important;
|
| 375 |
border: 1px solid #dc2626 !important;
|
|
@@ -387,21 +391,21 @@ desktop_css = """
|
|
| 387 |
gap: 0.6rem !important;
|
| 388 |
}
|
| 389 |
|
| 390 |
-
.quick-
|
| 391 |
background: #dc2626 !important;
|
| 392 |
color: #ffffff !important;
|
| 393 |
transform: translateX(3px) !important;
|
| 394 |
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2) !important;
|
| 395 |
}
|
| 396 |
|
| 397 |
-
/* Capabilities
|
| 398 |
-
.capabilities
|
| 399 |
color: #d1d5db !important;
|
| 400 |
font-size: 0.85rem !important;
|
| 401 |
line-height: 1.5 !important;
|
| 402 |
}
|
| 403 |
|
| 404 |
-
.capabilities
|
| 405 |
color: #ffffff !important;
|
| 406 |
display: block !important;
|
| 407 |
margin-bottom: 0.3rem !important;
|
|
@@ -434,6 +438,7 @@ desktop_css = """
|
|
| 434 |
padding: 1rem !important;
|
| 435 |
margin-bottom: 1rem !important;
|
| 436 |
transition: all 0.3s ease !important;
|
|
|
|
| 437 |
}
|
| 438 |
|
| 439 |
.file-upload:hover {
|
|
@@ -441,8 +446,8 @@ desktop_css = """
|
|
| 441 |
background: #262626 !important;
|
| 442 |
}
|
| 443 |
|
| 444 |
-
/* Message input */
|
| 445 |
-
.
|
| 446 |
background: #262626 !important;
|
| 447 |
border: 1px solid #404040 !important;
|
| 448 |
border-radius: 8px !important;
|
|
@@ -457,25 +462,25 @@ desktop_css = """
|
|
| 457 |
min-height: 80px !important;
|
| 458 |
}
|
| 459 |
|
| 460 |
-
.
|
| 461 |
outline: none !important;
|
| 462 |
border-color: #dc2626 !important;
|
| 463 |
box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1) !important;
|
| 464 |
}
|
| 465 |
|
| 466 |
-
.
|
| 467 |
color: #6b7280 !important;
|
| 468 |
}
|
| 469 |
|
| 470 |
-
/* Buttons */
|
| 471 |
-
.
|
| 472 |
display: flex !important;
|
| 473 |
gap: 1rem !important;
|
| 474 |
align-items: center !important;
|
| 475 |
justify-content: flex-end !important;
|
| 476 |
}
|
| 477 |
|
| 478 |
-
.
|
| 479 |
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
|
| 480 |
color: white !important;
|
| 481 |
border: none !important;
|
|
@@ -491,13 +496,13 @@ desktop_css = """
|
|
| 491 |
min-width: 80px !important;
|
| 492 |
}
|
| 493 |
|
| 494 |
-
.
|
| 495 |
background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%) !important;
|
| 496 |
transform: translateY(-1px) !important;
|
| 497 |
box-shadow: 0 6px 20px rgba(220, 38, 38, 0.3) !important;
|
| 498 |
}
|
| 499 |
|
| 500 |
-
.
|
| 501 |
background: #262626 !important;
|
| 502 |
color: #ffffff !important;
|
| 503 |
border: 1px solid #404040 !important;
|
|
@@ -512,15 +517,15 @@ desktop_css = """
|
|
| 512 |
min-width: 80px !important;
|
| 513 |
}
|
| 514 |
|
| 515 |
-
.
|
| 516 |
background: #404040 !important;
|
| 517 |
border-color: #dc2626 !important;
|
| 518 |
}
|
| 519 |
|
| 520 |
-
/* Chatbot
|
| 521 |
-
.chatbot {
|
| 522 |
height: 100% !important;
|
| 523 |
-
min-height:
|
| 524 |
border: none !important;
|
| 525 |
background: transparent !important;
|
| 526 |
}
|
|
@@ -578,15 +583,28 @@ code {
|
|
| 578 |
color: #dc2626 !important;
|
| 579 |
}
|
| 580 |
|
| 581 |
-
/*
|
| 582 |
.gradio-container * {
|
| 583 |
visibility: visible !important;
|
| 584 |
opacity: 1 !important;
|
| 585 |
}
|
| 586 |
|
| 587 |
-
/*
|
| 588 |
-
|
| 589 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
}
|
| 591 |
"""
|
| 592 |
|
|
@@ -625,7 +643,7 @@ def quick_action(action_text):
|
|
| 625 |
return action_text
|
| 626 |
|
| 627 |
# Create the main interface with COMPLETELY FIXED layout
|
| 628 |
-
with gr.Blocks(css=
|
| 629 |
|
| 630 |
# Header
|
| 631 |
gr.HTML("""
|
|
@@ -635,29 +653,29 @@ with gr.Blocks(css=desktop_css, title="Coding Copilot Pro - Desktop", theme=gr.t
|
|
| 635 |
</div>
|
| 636 |
""")
|
| 637 |
|
| 638 |
-
# Main content container -
|
| 639 |
-
with gr.Row(elem_classes=["main-
|
| 640 |
|
| 641 |
# Left Sidebar - FIXED
|
| 642 |
-
with gr.Column(elem_classes=["sidebar
|
| 643 |
|
| 644 |
# Quick Actions Section
|
| 645 |
-
with gr.Column(elem_classes=["quick-actions
|
| 646 |
gr.HTML('<h3 class="sidebar-title"><span>β‘</span>QUICK ACTIONS</h3>')
|
| 647 |
|
| 648 |
-
quick_generate = gr.Button("π₯ Generate Code", elem_classes=["quick-
|
| 649 |
-
quick_review = gr.Button("π Code Review", elem_classes=["quick-
|
| 650 |
-
quick_debug = gr.Button("π Debug & Fix", elem_classes=["quick-
|
| 651 |
-
quick_optimize = gr.Button("β‘ Optimize Code", elem_classes=["quick-
|
| 652 |
-
quick_explain = gr.Button("π Explain Code", elem_classes=["quick-
|
| 653 |
-
quick_test = gr.Button("π§ͺ Create Tests", elem_classes=["quick-
|
| 654 |
|
| 655 |
# Capabilities Section
|
| 656 |
with gr.Column():
|
| 657 |
gr.HTML('<h3 class="sidebar-title"><span>π―</span>CAPABILITIES</h3>')
|
| 658 |
|
| 659 |
gr.HTML("""
|
| 660 |
-
<div class="capabilities
|
| 661 |
<div class="capability-item">
|
| 662 |
<strong>π» Code Generation</strong>
|
| 663 |
Complete applications, modules, algorithms & APIs
|
|
@@ -678,30 +696,30 @@ with gr.Blocks(css=desktop_css, title="Coding Copilot Pro - Desktop", theme=gr.t
|
|
| 678 |
""")
|
| 679 |
|
| 680 |
# Right Chat Container - COMPLETELY FIXED
|
| 681 |
-
with gr.Column(elem_classes=["chat-
|
| 682 |
|
| 683 |
# Chat Messages Area - FIXED
|
| 684 |
-
with gr.Column(elem_classes=["chat-
|
| 685 |
chatbot = gr.Chatbot(
|
| 686 |
-
height=
|
| 687 |
show_label=False,
|
| 688 |
container=True,
|
| 689 |
avatar_images=("π¨βπ»", "π€"),
|
| 690 |
-
elem_classes=["chatbot"]
|
| 691 |
)
|
| 692 |
|
| 693 |
-
#
|
| 694 |
-
with gr.Column(elem_classes=["
|
| 695 |
|
| 696 |
# Download section
|
| 697 |
-
download_status = gr.HTML("")
|
| 698 |
download_file = gr.File(
|
| 699 |
label="π₯ Download Generated Code",
|
| 700 |
visible=False,
|
| 701 |
elem_classes=["download-section"]
|
| 702 |
)
|
| 703 |
|
| 704 |
-
# File upload
|
| 705 |
files = gr.File(
|
| 706 |
label="π Upload Code Files (.py, .ipynb)",
|
| 707 |
file_count="multiple",
|
|
@@ -709,27 +727,27 @@ with gr.Blocks(css=desktop_css, title="Coding Copilot Pro - Desktop", theme=gr.t
|
|
| 709 |
elem_classes=["file-upload"]
|
| 710 |
)
|
| 711 |
|
| 712 |
-
# Message input
|
| 713 |
msg = gr.Textbox(
|
| 714 |
label="",
|
| 715 |
placeholder="Describe what you want to build, analyze, or improve... Type 'continue' to extend previous code.",
|
| 716 |
show_label=False,
|
| 717 |
lines=3,
|
| 718 |
max_lines=6,
|
| 719 |
-
elem_classes=["
|
| 720 |
)
|
| 721 |
|
| 722 |
-
# Button row
|
| 723 |
-
with gr.Row(elem_classes=["
|
| 724 |
clear = gr.Button(
|
| 725 |
"CLEAR",
|
| 726 |
variant="secondary",
|
| 727 |
-
elem_classes=["
|
| 728 |
)
|
| 729 |
submit = gr.Button(
|
| 730 |
"SEND",
|
| 731 |
variant="primary",
|
| 732 |
-
elem_classes=["
|
| 733 |
)
|
| 734 |
|
| 735 |
# Hidden state
|
|
@@ -795,19 +813,60 @@ with gr.Blocks(css=desktop_css, title="Coding Copilot Pro - Desktop", theme=gr.t
|
|
| 795 |
outputs=[chatbot, chat_history, download_file, download_status]
|
| 796 |
)
|
| 797 |
|
| 798 |
-
# Footer
|
| 799 |
gr.HTML("""
|
| 800 |
<div class="footer">
|
| 801 |
-
<p><strong>π CODING COPILOT PRO</strong>
|
| 802 |
-
<p>
|
|
|
|
| 803 |
</div>
|
| 804 |
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 805 |
|
| 806 |
# Launch the app
|
| 807 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
app.launch(
|
| 809 |
server_name="0.0.0.0",
|
| 810 |
server_port=7860,
|
| 811 |
-
share=
|
| 812 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 813 |
)
|
|
|
|
| 251 |
# Initialize the copilot
|
| 252 |
copilot = CodingCopilot()
|
| 253 |
|
| 254 |
+
# COMPLETELY FIXED CSS - Proper scrolling and visibility
|
| 255 |
+
fixed_css = """
|
| 256 |
+
/* Reset and base styles */
|
| 257 |
+
* {
|
| 258 |
+
box-sizing: border-box !important;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
.gradio-container {
|
| 262 |
max-width: none !important;
|
| 263 |
+
width: 100% !important;
|
| 264 |
+
min-height: 100vh !important;
|
| 265 |
background: #0a0a0a !important;
|
| 266 |
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
|
| 267 |
color: #ffffff !important;
|
| 268 |
padding: 1rem !important;
|
| 269 |
+
overflow-x: hidden !important;
|
| 270 |
}
|
| 271 |
|
| 272 |
/* Header */
|
|
|
|
| 298 |
font-weight: 400 !important;
|
| 299 |
}
|
| 300 |
|
| 301 |
+
/* Main layout - FIXED to be flexible */
|
| 302 |
+
.main-layout {
|
| 303 |
display: flex !important;
|
| 304 |
flex-direction: row !important;
|
| 305 |
gap: 1.5rem !important;
|
| 306 |
+
width: 100% !important;
|
| 307 |
+
min-height: calc(100vh - 250px) !important;
|
| 308 |
}
|
| 309 |
|
| 310 |
+
/* Sidebar - FIXED width and scrolling */
|
| 311 |
+
.sidebar {
|
| 312 |
background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%) !important;
|
| 313 |
border: 1px solid #dc2626 !important;
|
| 314 |
border-radius: 16px !important;
|
| 315 |
padding: 1.5rem !important;
|
| 316 |
+
width: 320px !important;
|
| 317 |
+
min-width: 320px !important;
|
| 318 |
+
max-width: 320px !important;
|
| 319 |
flex-shrink: 0 !important;
|
| 320 |
box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1) !important;
|
| 321 |
overflow-y: auto !important;
|
| 322 |
+
max-height: calc(100vh - 250px) !important;
|
| 323 |
}
|
| 324 |
|
| 325 |
+
/* Chat area - FIXED to be flexible and scrollable */
|
| 326 |
+
.chat-area {
|
| 327 |
background: linear-gradient(180deg, #111111 0%, #0a0a0a 100%) !important;
|
| 328 |
border: 1px solid #262626 !important;
|
| 329 |
border-radius: 16px !important;
|
|
|
|
| 332 |
flex-direction: column !important;
|
| 333 |
overflow: hidden !important;
|
| 334 |
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
| 335 |
+
min-height: calc(100vh - 250px) !important;
|
| 336 |
}
|
| 337 |
|
| 338 |
+
/* Chat content area */
|
| 339 |
+
.chat-content {
|
| 340 |
flex: 1 !important;
|
| 341 |
overflow-y: auto !important;
|
| 342 |
padding: 1.5rem !important;
|
| 343 |
+
min-height: 300px !important;
|
| 344 |
}
|
| 345 |
|
| 346 |
+
/* Input section - FIXED to be visible */
|
| 347 |
+
.input-section {
|
| 348 |
flex-shrink: 0 !important;
|
| 349 |
background: #1a1a1a !important;
|
| 350 |
border-top: 1px solid #262626 !important;
|
|
|
|
| 355 |
}
|
| 356 |
|
| 357 |
/* Quick Actions */
|
| 358 |
+
.quick-actions {
|
| 359 |
margin-bottom: 2rem !important;
|
| 360 |
padding-bottom: 1.5rem !important;
|
| 361 |
border-bottom: 1px solid #dc2626 !important;
|
|
|
|
| 373 |
gap: 0.5rem !important;
|
| 374 |
}
|
| 375 |
|
| 376 |
+
.quick-btn {
|
| 377 |
background: #1a1a1a !important;
|
| 378 |
color: #dc2626 !important;
|
| 379 |
border: 1px solid #dc2626 !important;
|
|
|
|
| 391 |
gap: 0.6rem !important;
|
| 392 |
}
|
| 393 |
|
| 394 |
+
.quick-btn:hover {
|
| 395 |
background: #dc2626 !important;
|
| 396 |
color: #ffffff !important;
|
| 397 |
transform: translateX(3px) !important;
|
| 398 |
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2) !important;
|
| 399 |
}
|
| 400 |
|
| 401 |
+
/* Capabilities */
|
| 402 |
+
.capabilities {
|
| 403 |
color: #d1d5db !important;
|
| 404 |
font-size: 0.85rem !important;
|
| 405 |
line-height: 1.5 !important;
|
| 406 |
}
|
| 407 |
|
| 408 |
+
.capabilities strong {
|
| 409 |
color: #ffffff !important;
|
| 410 |
display: block !important;
|
| 411 |
margin-bottom: 0.3rem !important;
|
|
|
|
| 438 |
padding: 1rem !important;
|
| 439 |
margin-bottom: 1rem !important;
|
| 440 |
transition: all 0.3s ease !important;
|
| 441 |
+
width: 100% !important;
|
| 442 |
}
|
| 443 |
|
| 444 |
.file-upload:hover {
|
|
|
|
| 446 |
background: #262626 !important;
|
| 447 |
}
|
| 448 |
|
| 449 |
+
/* Message input - FIXED visibility */
|
| 450 |
+
.msg-input {
|
| 451 |
background: #262626 !important;
|
| 452 |
border: 1px solid #404040 !important;
|
| 453 |
border-radius: 8px !important;
|
|
|
|
| 462 |
min-height: 80px !important;
|
| 463 |
}
|
| 464 |
|
| 465 |
+
.msg-input:focus {
|
| 466 |
outline: none !important;
|
| 467 |
border-color: #dc2626 !important;
|
| 468 |
box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.1) !important;
|
| 469 |
}
|
| 470 |
|
| 471 |
+
.msg-input::placeholder {
|
| 472 |
color: #6b7280 !important;
|
| 473 |
}
|
| 474 |
|
| 475 |
+
/* Buttons - FIXED visibility */
|
| 476 |
+
.btn-row {
|
| 477 |
display: flex !important;
|
| 478 |
gap: 1rem !important;
|
| 479 |
align-items: center !important;
|
| 480 |
justify-content: flex-end !important;
|
| 481 |
}
|
| 482 |
|
| 483 |
+
.btn-primary {
|
| 484 |
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
|
| 485 |
color: white !important;
|
| 486 |
border: none !important;
|
|
|
|
| 496 |
min-width: 80px !important;
|
| 497 |
}
|
| 498 |
|
| 499 |
+
.btn-primary:hover {
|
| 500 |
background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%) !important;
|
| 501 |
transform: translateY(-1px) !important;
|
| 502 |
box-shadow: 0 6px 20px rgba(220, 38, 38, 0.3) !important;
|
| 503 |
}
|
| 504 |
|
| 505 |
+
.btn-secondary {
|
| 506 |
background: #262626 !important;
|
| 507 |
color: #ffffff !important;
|
| 508 |
border: 1px solid #404040 !important;
|
|
|
|
| 517 |
min-width: 80px !important;
|
| 518 |
}
|
| 519 |
|
| 520 |
+
.btn-secondary:hover {
|
| 521 |
background: #404040 !important;
|
| 522 |
border-color: #dc2626 !important;
|
| 523 |
}
|
| 524 |
|
| 525 |
+
/* Chatbot */
|
| 526 |
+
.chatbot-container {
|
| 527 |
height: 100% !important;
|
| 528 |
+
min-height: 300px !important;
|
| 529 |
border: none !important;
|
| 530 |
background: transparent !important;
|
| 531 |
}
|
|
|
|
| 583 |
color: #dc2626 !important;
|
| 584 |
}
|
| 585 |
|
| 586 |
+
/* Ensure all elements are visible */
|
| 587 |
.gradio-container * {
|
| 588 |
visibility: visible !important;
|
| 589 |
opacity: 1 !important;
|
| 590 |
}
|
| 591 |
|
| 592 |
+
/* Responsive design */
|
| 593 |
+
@media (max-width: 768px) {
|
| 594 |
+
.main-layout {
|
| 595 |
+
flex-direction: column !important;
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
.sidebar {
|
| 599 |
+
width: 100% !important;
|
| 600 |
+
max-width: none !important;
|
| 601 |
+
min-width: auto !important;
|
| 602 |
+
max-height: 400px !important;
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
+
.header-title {
|
| 606 |
+
font-size: 1.8rem !important;
|
| 607 |
+
}
|
| 608 |
}
|
| 609 |
"""
|
| 610 |
|
|
|
|
| 643 |
return action_text
|
| 644 |
|
| 645 |
# Create the main interface with COMPLETELY FIXED layout
|
| 646 |
+
with gr.Blocks(css=fixed_css, title="Coding Copilot Pro - Desktop", theme=gr.themes.Base()) as app:
|
| 647 |
|
| 648 |
# Header
|
| 649 |
gr.HTML("""
|
|
|
|
| 653 |
</div>
|
| 654 |
""")
|
| 655 |
|
| 656 |
+
# Main content container - COMPLETELY FIXED
|
| 657 |
+
with gr.Row(elem_classes=["main-layout"]):
|
| 658 |
|
| 659 |
# Left Sidebar - FIXED
|
| 660 |
+
with gr.Column(elem_classes=["sidebar"], scale=0):
|
| 661 |
|
| 662 |
# Quick Actions Section
|
| 663 |
+
with gr.Column(elem_classes=["quick-actions"]):
|
| 664 |
gr.HTML('<h3 class="sidebar-title"><span>β‘</span>QUICK ACTIONS</h3>')
|
| 665 |
|
| 666 |
+
quick_generate = gr.Button("π₯ Generate Code", elem_classes=["quick-btn"])
|
| 667 |
+
quick_review = gr.Button("π Code Review", elem_classes=["quick-btn"])
|
| 668 |
+
quick_debug = gr.Button("π Debug & Fix", elem_classes=["quick-btn"])
|
| 669 |
+
quick_optimize = gr.Button("β‘ Optimize Code", elem_classes=["quick-btn"])
|
| 670 |
+
quick_explain = gr.Button("π Explain Code", elem_classes=["quick-btn"])
|
| 671 |
+
quick_test = gr.Button("π§ͺ Create Tests", elem_classes=["quick-btn"])
|
| 672 |
|
| 673 |
# Capabilities Section
|
| 674 |
with gr.Column():
|
| 675 |
gr.HTML('<h3 class="sidebar-title"><span>π―</span>CAPABILITIES</h3>')
|
| 676 |
|
| 677 |
gr.HTML("""
|
| 678 |
+
<div class="capabilities">
|
| 679 |
<div class="capability-item">
|
| 680 |
<strong>π» Code Generation</strong>
|
| 681 |
Complete applications, modules, algorithms & APIs
|
|
|
|
| 696 |
""")
|
| 697 |
|
| 698 |
# Right Chat Container - COMPLETELY FIXED
|
| 699 |
+
with gr.Column(elem_classes=["chat-area"], scale=1):
|
| 700 |
|
| 701 |
# Chat Messages Area - FIXED
|
| 702 |
+
with gr.Column(elem_classes=["chat-content"]):
|
| 703 |
chatbot = gr.Chatbot(
|
| 704 |
+
height=400,
|
| 705 |
show_label=False,
|
| 706 |
container=True,
|
| 707 |
avatar_images=("π¨βπ»", "π€"),
|
| 708 |
+
elem_classes=["chatbot-container"]
|
| 709 |
)
|
| 710 |
|
| 711 |
+
# Input Section - COMPLETELY FIXED AND VISIBLE
|
| 712 |
+
with gr.Column(elem_classes=["input-section"]):
|
| 713 |
|
| 714 |
# Download section
|
| 715 |
+
download_status = gr.HTML("", elem_classes=["download-section"])
|
| 716 |
download_file = gr.File(
|
| 717 |
label="π₯ Download Generated Code",
|
| 718 |
visible=False,
|
| 719 |
elem_classes=["download-section"]
|
| 720 |
)
|
| 721 |
|
| 722 |
+
# File upload - FIXED
|
| 723 |
files = gr.File(
|
| 724 |
label="π Upload Code Files (.py, .ipynb)",
|
| 725 |
file_count="multiple",
|
|
|
|
| 727 |
elem_classes=["file-upload"]
|
| 728 |
)
|
| 729 |
|
| 730 |
+
# Message input - FIXED
|
| 731 |
msg = gr.Textbox(
|
| 732 |
label="",
|
| 733 |
placeholder="Describe what you want to build, analyze, or improve... Type 'continue' to extend previous code.",
|
| 734 |
show_label=False,
|
| 735 |
lines=3,
|
| 736 |
max_lines=6,
|
| 737 |
+
elem_classes=["msg-input"]
|
| 738 |
)
|
| 739 |
|
| 740 |
+
# Button row - FIXED
|
| 741 |
+
with gr.Row(elem_classes=["btn-row"]):
|
| 742 |
clear = gr.Button(
|
| 743 |
"CLEAR",
|
| 744 |
variant="secondary",
|
| 745 |
+
elem_classes=["btn-secondary"]
|
| 746 |
)
|
| 747 |
submit = gr.Button(
|
| 748 |
"SEND",
|
| 749 |
variant="primary",
|
| 750 |
+
elem_classes=["btn-primary"]
|
| 751 |
)
|
| 752 |
|
| 753 |
# Hidden state
|
|
|
|
| 813 |
outputs=[chatbot, chat_history, download_file, download_status]
|
| 814 |
)
|
| 815 |
|
| 816 |
+
# Footer - Completing from where it ended
|
| 817 |
gr.HTML("""
|
| 818 |
<div class="footer">
|
| 819 |
+
<p><strong>π CODING COPILOT PRO</strong> - Advanced AI Development Assistant</p>
|
| 820 |
+
<p>Powered by <strong>Claude 3 Haiku</strong> via AWS Bedrock β’ Built with Gradio</p>
|
| 821 |
+
<p>π‘ Upload your code files and describe what you want to build, analyze, or improve!</p>
|
| 822 |
</div>
|
| 823 |
""")
|
| 824 |
+
|
| 825 |
+
# Show download file when available
|
| 826 |
+
def update_download_visibility(file_path, status):
|
| 827 |
+
if file_path:
|
| 828 |
+
return gr.File.update(visible=True, value=file_path), status
|
| 829 |
+
return gr.File.update(visible=False), status
|
| 830 |
+
|
| 831 |
+
# Update download file visibility when status changes
|
| 832 |
+
download_status.change(
|
| 833 |
+
update_download_visibility,
|
| 834 |
+
inputs=[download_file, download_status],
|
| 835 |
+
outputs=[download_file, download_status]
|
| 836 |
+
)
|
| 837 |
|
| 838 |
# Launch the app
|
| 839 |
if __name__ == "__main__":
|
| 840 |
+
print("π Starting Coding Copilot Pro...")
|
| 841 |
+
print("π Features:")
|
| 842 |
+
print(" β’ Complete code generation with continuation support")
|
| 843 |
+
print(" β’ File upload support for .py and .ipynb files")
|
| 844 |
+
print(" β’ Comprehensive code analysis and debugging")
|
| 845 |
+
print(" β’ Download generated code as files")
|
| 846 |
+
print(" β’ Quick action buttons for common tasks")
|
| 847 |
+
print(" β’ Dark theme with responsive design")
|
| 848 |
+
print()
|
| 849 |
+
print("π§ Requirements:")
|
| 850 |
+
print(" β’ Set AWS_ACCESS_KEY_ID environment variable")
|
| 851 |
+
print(" β’ Set AWS_SECRET_ACCESS_KEY environment variable")
|
| 852 |
+
print(" β’ Ensure AWS Bedrock access to Claude 3 Haiku")
|
| 853 |
+
print()
|
| 854 |
+
|
| 855 |
+
# Launch with optimized settings
|
| 856 |
app.launch(
|
| 857 |
server_name="0.0.0.0",
|
| 858 |
server_port=7860,
|
| 859 |
+
share=False,
|
| 860 |
+
debug=False,
|
| 861 |
+
show_error=True,
|
| 862 |
+
quiet=False,
|
| 863 |
+
inbrowser=True,
|
| 864 |
+
show_tips=False,
|
| 865 |
+
height=800,
|
| 866 |
+
favicon_path=None,
|
| 867 |
+
ssl_verify=False,
|
| 868 |
+
app_kwargs={
|
| 869 |
+
"docs_url": None,
|
| 870 |
+
"redoc_url": None,
|
| 871 |
+
}
|
| 872 |
)
|