Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,7 +251,7 @@ Provide a thorough and helpful response. If suggesting code changes, provide com
|
|
| 251 |
# Initialize the copilot
|
| 252 |
copilot = CodingCopilot()
|
| 253 |
|
| 254 |
-
# Enhanced Professional CSS Theme with
|
| 255 |
professional_css = """
|
| 256 |
/* Global Styles */
|
| 257 |
* {
|
|
@@ -296,22 +296,25 @@ professional_css = """
|
|
| 296 |
font-weight: 400 !important;
|
| 297 |
}
|
| 298 |
|
| 299 |
-
/* Main Layout -
|
| 300 |
.main-layout {
|
| 301 |
display: flex !important;
|
| 302 |
gap: 1.5rem !important;
|
| 303 |
height: 100% !important;
|
| 304 |
align-items: stretch !important;
|
|
|
|
| 305 |
}
|
| 306 |
|
| 307 |
-
/* Sidebar */
|
| 308 |
.sidebar {
|
| 309 |
background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%) !important;
|
| 310 |
border: 1px solid #dc2626 !important;
|
| 311 |
border-radius: 16px !important;
|
| 312 |
padding: 2rem !important;
|
|
|
|
| 313 |
min-width: 350px !important;
|
| 314 |
max-width: 350px !important;
|
|
|
|
| 315 |
box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1) !important;
|
| 316 |
}
|
| 317 |
|
|
@@ -380,7 +383,7 @@ professional_css = """
|
|
| 380 |
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2) !important;
|
| 381 |
}
|
| 382 |
|
| 383 |
-
/* Chat Container */
|
| 384 |
.chat-container {
|
| 385 |
background: linear-gradient(180deg, #111111 0%, #0a0a0a 100%) !important;
|
| 386 |
border: 1px solid #262626 !important;
|
|
@@ -390,6 +393,7 @@ professional_css = """
|
|
| 390 |
flex-direction: column !important;
|
| 391 |
overflow: hidden !important;
|
| 392 |
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
|
|
|
| 393 |
}
|
| 394 |
|
| 395 |
/* Chat Interface */
|
|
@@ -397,7 +401,7 @@ professional_css = """
|
|
| 397 |
background: transparent !important;
|
| 398 |
border: none !important;
|
| 399 |
flex: 1 !important;
|
| 400 |
-
min-height:
|
| 401 |
max-height: 500px !important;
|
| 402 |
overflow-y: auto !important;
|
| 403 |
padding: 1rem !important;
|
|
@@ -409,32 +413,27 @@ professional_css = """
|
|
| 409 |
height: 100% !important;
|
| 410 |
}
|
| 411 |
|
| 412 |
-
/*
|
| 413 |
-
.file-upload-
|
| 414 |
background: #1a1a1a !important;
|
| 415 |
border: 1px solid #404040 !important;
|
| 416 |
border-radius: 10px !important;
|
| 417 |
-
padding:
|
| 418 |
margin: 1rem !important;
|
| 419 |
transition: all 0.3s ease !important;
|
| 420 |
}
|
| 421 |
|
| 422 |
-
.file-upload-
|
| 423 |
border-color: #dc2626 !important;
|
| 424 |
background: #262626 !important;
|
| 425 |
}
|
| 426 |
|
| 427 |
-
/* Input Section */
|
| 428 |
.input-section {
|
| 429 |
background: #1a1a1a !important;
|
| 430 |
border-top: 1px solid #262626 !important;
|
| 431 |
padding: 1rem !important;
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
.input-row {
|
| 435 |
-
display: flex !important;
|
| 436 |
-
gap: 0.75rem !important;
|
| 437 |
-
align-items: flex-end !important;
|
| 438 |
}
|
| 439 |
|
| 440 |
.message-input {
|
|
@@ -447,7 +446,8 @@ professional_css = """
|
|
| 447 |
line-height: 1.4 !important;
|
| 448 |
resize: vertical !important;
|
| 449 |
transition: all 0.3s ease !important;
|
| 450 |
-
|
|
|
|
| 451 |
}
|
| 452 |
|
| 453 |
.message-input:focus {
|
|
@@ -460,6 +460,13 @@ professional_css = """
|
|
| 460 |
color: #6b7280 !important;
|
| 461 |
}
|
| 462 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 463 |
/* Buttons */
|
| 464 |
.primary-button {
|
| 465 |
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
|
|
@@ -552,6 +559,7 @@ professional_css = """
|
|
| 552 |
}
|
| 553 |
|
| 554 |
.sidebar {
|
|
|
|
| 555 |
min-width: auto !important;
|
| 556 |
max-width: none !important;
|
| 557 |
order: 2 !important;
|
|
@@ -575,7 +583,7 @@ professional_css = """
|
|
| 575 |
padding: 1rem !important;
|
| 576 |
}
|
| 577 |
|
| 578 |
-
.
|
| 579 |
flex-direction: column !important;
|
| 580 |
gap: 0.5rem !important;
|
| 581 |
}
|
|
@@ -656,11 +664,11 @@ with gr.Blocks(css=professional_css, title="Coding Copilot Pro", theme=gr.themes
|
|
| 656 |
</div>
|
| 657 |
""")
|
| 658 |
|
| 659 |
-
# Main layout with two columns
|
| 660 |
with gr.Row(elem_classes=["main-layout"]):
|
| 661 |
|
| 662 |
-
# Sidebar
|
| 663 |
-
with gr.Column(elem_classes=["sidebar"]):
|
| 664 |
|
| 665 |
# Capabilities Section
|
| 666 |
gr.HTML('<div class="sidebar-section">')
|
|
@@ -701,12 +709,12 @@ with gr.Blocks(css=professional_css, title="Coding Copilot Pro", theme=gr.themes
|
|
| 701 |
|
| 702 |
gr.HTML('</div>')
|
| 703 |
|
| 704 |
-
# Chat
|
| 705 |
-
with gr.Column(elem_classes=["chat-container"]):
|
| 706 |
|
| 707 |
# Chat interface
|
| 708 |
chatbot = gr.Chatbot(
|
| 709 |
-
height=
|
| 710 |
show_label=False,
|
| 711 |
container=False,
|
| 712 |
bubble_full_width=False,
|
|
@@ -714,13 +722,12 @@ with gr.Blocks(css=professional_css, title="Coding Copilot Pro", theme=gr.themes
|
|
| 714 |
elem_classes=["chat-interface"]
|
| 715 |
)
|
| 716 |
|
| 717 |
-
#
|
| 718 |
-
with gr.Row(elem_classes=["file-upload-
|
| 719 |
files = gr.File(
|
| 720 |
label="📎 Upload Code Files (.py, .ipynb)",
|
| 721 |
file_count="multiple",
|
| 722 |
file_types=[".py", ".ipynb"],
|
| 723 |
-
scale=1,
|
| 724 |
show_label=True,
|
| 725 |
container=True
|
| 726 |
)
|
|
@@ -729,22 +736,20 @@ with gr.Blocks(css=professional_css, title="Coding Copilot Pro", theme=gr.themes
|
|
| 729 |
download_status = gr.HTML("", visible=True)
|
| 730 |
download_file = gr.File(label="📥 Download Generated Code", visible=False)
|
| 731 |
|
| 732 |
-
# Input section
|
| 733 |
-
with gr.
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
submit = gr.Button("SEND", variant="primary", elem_classes=["primary-button"])
|
| 747 |
-
clear = gr.Button("CLEAR", variant="secondary", elem_classes=["secondary-button"])
|
| 748 |
|
| 749 |
# Hidden state
|
| 750 |
chat_history = gr.State([])
|
|
@@ -823,7 +828,5 @@ if __name__ == "__main__":
|
|
| 823 |
server_name="0.0.0.0",
|
| 824 |
server_port=7860,
|
| 825 |
share=True,
|
| 826 |
-
show_error=True
|
| 827 |
-
show_api=False,
|
| 828 |
-
inbrowser=True
|
| 829 |
)
|
|
|
|
| 251 |
# Initialize the copilot
|
| 252 |
copilot = CodingCopilot()
|
| 253 |
|
| 254 |
+
# Enhanced Professional CSS Theme with Fixed Layout
|
| 255 |
professional_css = """
|
| 256 |
/* Global Styles */
|
| 257 |
* {
|
|
|
|
| 296 |
font-weight: 400 !important;
|
| 297 |
}
|
| 298 |
|
| 299 |
+
/* Main Layout - Side by Side */
|
| 300 |
.main-layout {
|
| 301 |
display: flex !important;
|
| 302 |
gap: 1.5rem !important;
|
| 303 |
height: 100% !important;
|
| 304 |
align-items: stretch !important;
|
| 305 |
+
flex-direction: row !important;
|
| 306 |
}
|
| 307 |
|
| 308 |
+
/* Sidebar - Fixed Width */
|
| 309 |
.sidebar {
|
| 310 |
background: linear-gradient(180deg, #1a1a1a 0%, #0f0f0f 100%) !important;
|
| 311 |
border: 1px solid #dc2626 !important;
|
| 312 |
border-radius: 16px !important;
|
| 313 |
padding: 2rem !important;
|
| 314 |
+
width: 350px !important;
|
| 315 |
min-width: 350px !important;
|
| 316 |
max-width: 350px !important;
|
| 317 |
+
flex-shrink: 0 !important;
|
| 318 |
box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1) !important;
|
| 319 |
}
|
| 320 |
|
|
|
|
| 383 |
box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2) !important;
|
| 384 |
}
|
| 385 |
|
| 386 |
+
/* Chat Container - Takes remaining space */
|
| 387 |
.chat-container {
|
| 388 |
background: linear-gradient(180deg, #111111 0%, #0a0a0a 100%) !important;
|
| 389 |
border: 1px solid #262626 !important;
|
|
|
|
| 393 |
flex-direction: column !important;
|
| 394 |
overflow: hidden !important;
|
| 395 |
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
| 396 |
+
min-height: 600px !important;
|
| 397 |
}
|
| 398 |
|
| 399 |
/* Chat Interface */
|
|
|
|
| 401 |
background: transparent !important;
|
| 402 |
border: none !important;
|
| 403 |
flex: 1 !important;
|
| 404 |
+
min-height: 400px !important;
|
| 405 |
max-height: 500px !important;
|
| 406 |
overflow-y: auto !important;
|
| 407 |
padding: 1rem !important;
|
|
|
|
| 413 |
height: 100% !important;
|
| 414 |
}
|
| 415 |
|
| 416 |
+
/* File Upload Section */
|
| 417 |
+
.file-upload-section {
|
| 418 |
background: #1a1a1a !important;
|
| 419 |
border: 1px solid #404040 !important;
|
| 420 |
border-radius: 10px !important;
|
| 421 |
+
padding: 1rem !important;
|
| 422 |
margin: 1rem !important;
|
| 423 |
transition: all 0.3s ease !important;
|
| 424 |
}
|
| 425 |
|
| 426 |
+
.file-upload-section:hover {
|
| 427 |
border-color: #dc2626 !important;
|
| 428 |
background: #262626 !important;
|
| 429 |
}
|
| 430 |
|
| 431 |
+
/* Input Section - Bottom of Chat */
|
| 432 |
.input-section {
|
| 433 |
background: #1a1a1a !important;
|
| 434 |
border-top: 1px solid #262626 !important;
|
| 435 |
padding: 1rem !important;
|
| 436 |
+
margin-top: auto !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
}
|
| 438 |
|
| 439 |
.message-input {
|
|
|
|
| 446 |
line-height: 1.4 !important;
|
| 447 |
resize: vertical !important;
|
| 448 |
transition: all 0.3s ease !important;
|
| 449 |
+
width: 100% !important;
|
| 450 |
+
margin-bottom: 1rem !important;
|
| 451 |
}
|
| 452 |
|
| 453 |
.message-input:focus {
|
|
|
|
| 460 |
color: #6b7280 !important;
|
| 461 |
}
|
| 462 |
|
| 463 |
+
.button-row {
|
| 464 |
+
display: flex !important;
|
| 465 |
+
gap: 0.75rem !important;
|
| 466 |
+
align-items: center !important;
|
| 467 |
+
justify-content: flex-end !important;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
/* Buttons */
|
| 471 |
.primary-button {
|
| 472 |
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
|
|
|
|
| 559 |
}
|
| 560 |
|
| 561 |
.sidebar {
|
| 562 |
+
width: 100% !important;
|
| 563 |
min-width: auto !important;
|
| 564 |
max-width: none !important;
|
| 565 |
order: 2 !important;
|
|
|
|
| 583 |
padding: 1rem !important;
|
| 584 |
}
|
| 585 |
|
| 586 |
+
.button-row {
|
| 587 |
flex-direction: column !important;
|
| 588 |
gap: 0.5rem !important;
|
| 589 |
}
|
|
|
|
| 664 |
</div>
|
| 665 |
""")
|
| 666 |
|
| 667 |
+
# Main layout with two columns side by side
|
| 668 |
with gr.Row(elem_classes=["main-layout"]):
|
| 669 |
|
| 670 |
+
# Left Sidebar - Fixed width
|
| 671 |
+
with gr.Column(elem_classes=["sidebar"], scale=0):
|
| 672 |
|
| 673 |
# Capabilities Section
|
| 674 |
gr.HTML('<div class="sidebar-section">')
|
|
|
|
| 709 |
|
| 710 |
gr.HTML('</div>')
|
| 711 |
|
| 712 |
+
# Right Chat Container - Takes remaining space
|
| 713 |
+
with gr.Column(elem_classes=["chat-container"], scale=1):
|
| 714 |
|
| 715 |
# Chat interface
|
| 716 |
chatbot = gr.Chatbot(
|
| 717 |
+
height=400,
|
| 718 |
show_label=False,
|
| 719 |
container=False,
|
| 720 |
bubble_full_width=False,
|
|
|
|
| 722 |
elem_classes=["chat-interface"]
|
| 723 |
)
|
| 724 |
|
| 725 |
+
# File upload section
|
| 726 |
+
with gr.Row(elem_classes=["file-upload-section"]):
|
| 727 |
files = gr.File(
|
| 728 |
label="📎 Upload Code Files (.py, .ipynb)",
|
| 729 |
file_count="multiple",
|
| 730 |
file_types=[".py", ".ipynb"],
|
|
|
|
| 731 |
show_label=True,
|
| 732 |
container=True
|
| 733 |
)
|
|
|
|
| 736 |
download_status = gr.HTML("", visible=True)
|
| 737 |
download_file = gr.File(label="📥 Download Generated Code", visible=False)
|
| 738 |
|
| 739 |
+
# Input section at bottom of chat
|
| 740 |
+
with gr.Column(elem_classes=["input-section"]):
|
| 741 |
+
msg = gr.Textbox(
|
| 742 |
+
label="",
|
| 743 |
+
placeholder="Describe what you want to build, analyze, or improve... Type 'continue' to extend previous code.",
|
| 744 |
+
show_label=False,
|
| 745 |
+
lines=3,
|
| 746 |
+
max_lines=5,
|
| 747 |
+
elem_classes=["message-input"]
|
| 748 |
+
)
|
| 749 |
+
|
| 750 |
+
with gr.Row(elem_classes=["button-row"]):
|
| 751 |
+
clear = gr.Button("CLEAR", variant="secondary", elem_classes=["secondary-button"])
|
| 752 |
+
submit = gr.Button("SEND", variant="primary", elem_classes=["primary-button"])
|
|
|
|
|
|
|
| 753 |
|
| 754 |
# Hidden state
|
| 755 |
chat_history = gr.State([])
|
|
|
|
| 828 |
server_name="0.0.0.0",
|
| 829 |
server_port=7860,
|
| 830 |
share=True,
|
| 831 |
+
show_error=True
|
|
|
|
|
|
|
| 832 |
)
|