Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -402,6 +402,20 @@ def format_response(text):
|
|
| 402 |
|
| 403 |
return text
|
| 404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
|
| 406 |
def create_ui():
|
| 407 |
global analyzer
|
|
@@ -565,6 +579,30 @@ def create_ui():
|
|
| 565 |
.gr-form { flex-direction: column !important; }
|
| 566 |
.gr-group { margin: 0.5rem 0 !important; }
|
| 567 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 568 |
</style>
|
| 569 |
|
| 570 |
<script>
|
|
@@ -948,24 +986,25 @@ def create_ui():
|
|
| 948 |
""")
|
| 949 |
|
| 950 |
# Chat Interface (outside tabs)
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
| 965 |
-
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
|
|
|
| 969 |
|
| 970 |
# Event Handlers
|
| 971 |
def handle_clone(repo_url, github_token, branch):
|
|
@@ -1032,10 +1071,23 @@ def create_ui():
|
|
| 1032 |
outputs=[file_list]
|
| 1033 |
)
|
| 1034 |
|
|
|
|
|
|
|
| 1035 |
# Chat events
|
| 1036 |
clear_button.click(
|
| 1037 |
-
fn=
|
| 1038 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1039 |
)
|
| 1040 |
|
| 1041 |
send_button.click(
|
|
@@ -1084,4 +1136,4 @@ if __name__ == "__main__":
|
|
| 1084 |
""")
|
| 1085 |
|
| 1086 |
app = create_ui()
|
| 1087 |
-
app.launch(share=True, server_name="0.0.0.0", server_port=7860, debug=True)
|
|
|
|
| 402 |
|
| 403 |
return text
|
| 404 |
|
| 405 |
+
def clear_all():
|
| 406 |
+
"""Clear semua input dan status"""
|
| 407 |
+
return (
|
| 408 |
+
"", # repo_url
|
| 409 |
+
"", # github_token
|
| 410 |
+
"", # branch
|
| 411 |
+
"", # clone_status
|
| 412 |
+
[], # chat_history
|
| 413 |
+
[], # file_selector
|
| 414 |
+
"<div class='file-list'>Belum ada file yang dipilih</div>", # file_list
|
| 415 |
+
"", # xai_key
|
| 416 |
+
"", # gemini_key
|
| 417 |
+
"grok-2-latest", # model_dropdown default value
|
| 418 |
+
)
|
| 419 |
|
| 420 |
def create_ui():
|
| 421 |
global analyzer
|
|
|
|
| 579 |
.gr-form { flex-direction: column !important; }
|
| 580 |
.gr-group { margin: 0.5rem 0 !important; }
|
| 581 |
}
|
| 582 |
+
.clear-button {
|
| 583 |
+
background: #dc3545 !important;
|
| 584 |
+
color: white !important;
|
| 585 |
+
border: none !important;
|
| 586 |
+
padding: 0.5rem 1rem !important;
|
| 587 |
+
border-radius: 4px !important;
|
| 588 |
+
cursor: pointer !important;
|
| 589 |
+
transition: background-color 0.2s !important;
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
.clear-button:hover {
|
| 593 |
+
background: #c82333 !important;
|
| 594 |
+
}
|
| 595 |
+
|
| 596 |
+
/* Button Container */
|
| 597 |
+
.button-container {
|
| 598 |
+
display: flex;
|
| 599 |
+
gap: 10px;
|
| 600 |
+
margin-top: 10px;
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
.button-container button {
|
| 604 |
+
flex: 1;
|
| 605 |
+
}
|
| 606 |
</style>
|
| 607 |
|
| 608 |
<script>
|
|
|
|
| 986 |
""")
|
| 987 |
|
| 988 |
# Chat Interface (outside tabs)
|
| 989 |
+
with gr.Group():
|
| 990 |
+
chat_history = gr.Chatbot(
|
| 991 |
+
label="π Riwayat Chat",
|
| 992 |
+
height=500,
|
| 993 |
+
show_label=True,
|
| 994 |
+
type="messages",
|
| 995 |
+
elem_classes="mobile-full"
|
| 996 |
+
)
|
| 997 |
|
| 998 |
+
with gr.Row():
|
| 999 |
+
chat_input = gr.Textbox(
|
| 1000 |
+
label="π Tanyakan tentang Repository",
|
| 1001 |
+
placeholder="Ketik pertanyaan Anda di sini...",
|
| 1002 |
+
lines=3,
|
| 1003 |
+
elem_classes="mobile-full",
|
| 1004 |
+
)
|
| 1005 |
+
with gr.Column(scale=1):
|
| 1006 |
+
send_button = gr.Button("π€ Kirim", variant="primary")
|
| 1007 |
+
clear_button = gr.Button("π§Ή Bersihkan Semua", variant="secondary")
|
| 1008 |
|
| 1009 |
# Event Handlers
|
| 1010 |
def handle_clone(repo_url, github_token, branch):
|
|
|
|
| 1071 |
outputs=[file_list]
|
| 1072 |
)
|
| 1073 |
|
| 1074 |
+
clear_button = gr.Button("π§Ή Bersihkan Semua", variant="secondary")
|
| 1075 |
+
|
| 1076 |
# Chat events
|
| 1077 |
clear_button.click(
|
| 1078 |
+
fn=clear_all,
|
| 1079 |
+
outputs=[
|
| 1080 |
+
repo_url,
|
| 1081 |
+
github_token,
|
| 1082 |
+
branch,
|
| 1083 |
+
clone_status,
|
| 1084 |
+
chat_history,
|
| 1085 |
+
file_selector,
|
| 1086 |
+
file_list,
|
| 1087 |
+
xai_key,
|
| 1088 |
+
gemini_key,
|
| 1089 |
+
model_dropdown,
|
| 1090 |
+
]
|
| 1091 |
)
|
| 1092 |
|
| 1093 |
send_button.click(
|
|
|
|
| 1136 |
""")
|
| 1137 |
|
| 1138 |
app = create_ui()
|
| 1139 |
+
app.launch(share=True, server_name="0.0.0.0", server_port=7860, debug=True)
|