Spaces:
Sleeping
Sleeping
csv_clickable
Browse files- app.py +49 -1
- repo_explorer.py +2 -1
app.py
CHANGED
|
@@ -284,6 +284,24 @@ def create_ui() -> gr.Blocks:
|
|
| 284 |
.gr-dataframe td:nth-child(4) { width: 20%; }
|
| 285 |
.gr-dataframe th:nth-child(5),
|
| 286 |
.gr-dataframe td:nth-child(5) { width: 15%; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
"""
|
| 288 |
|
| 289 |
with gr.Blocks(
|
|
@@ -380,10 +398,11 @@ def create_ui() -> gr.Blocks:
|
|
| 380 |
)
|
| 381 |
|
| 382 |
gr.Markdown("### π Results Dashboard")
|
|
|
|
| 383 |
df_output = gr.Dataframe(
|
| 384 |
headers=["Repository", "Strengths", "Weaknesses", "Speciality", "Relevance"],
|
| 385 |
wrap=True,
|
| 386 |
-
interactive=
|
| 387 |
)
|
| 388 |
|
| 389 |
# --- Chatbot Tab ---
|
|
@@ -566,6 +585,28 @@ def create_ui() -> gr.Blocks:
|
|
| 566 |
status = "Status: Keywords extracted. User requirements saved for analysis."
|
| 567 |
return final_keywords_str, status, user_requirements
|
| 568 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
# --- Component Event Wiring ---
|
| 570 |
|
| 571 |
# Initialize chatbot with welcome message on app load
|
|
@@ -630,6 +671,13 @@ def create_ui() -> gr.Blocks:
|
|
| 630 |
# Repo Explorer Tab
|
| 631 |
setup_repo_explorer_events(repo_components, repo_states)
|
| 632 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
return app
|
| 634 |
|
| 635 |
if __name__ == "__main__":
|
|
|
|
| 284 |
.gr-dataframe td:nth-child(4) { width: 20%; }
|
| 285 |
.gr-dataframe th:nth-child(5),
|
| 286 |
.gr-dataframe td:nth-child(5) { width: 15%; }
|
| 287 |
+
|
| 288 |
+
/* Make repository names clickable */
|
| 289 |
+
.gr-dataframe td:nth-child(1) {
|
| 290 |
+
cursor: pointer;
|
| 291 |
+
color: #667eea;
|
| 292 |
+
font-weight: 600;
|
| 293 |
+
transition: all 0.3s ease;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.gr-dataframe td:nth-child(1):hover {
|
| 297 |
+
background-color: rgba(102, 126, 234, 0.1);
|
| 298 |
+
color: #764ba2;
|
| 299 |
+
transform: scale(1.02);
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.gr-dataframe tbody tr:hover {
|
| 303 |
+
background-color: rgba(102, 126, 234, 0.05);
|
| 304 |
+
}
|
| 305 |
"""
|
| 306 |
|
| 307 |
with gr.Blocks(
|
|
|
|
| 398 |
)
|
| 399 |
|
| 400 |
gr.Markdown("### π Results Dashboard")
|
| 401 |
+
gr.Markdown("π‘ **Tip:** Click on any repository name to explore it in detail!")
|
| 402 |
df_output = gr.Dataframe(
|
| 403 |
headers=["Repository", "Strengths", "Weaknesses", "Speciality", "Relevance"],
|
| 404 |
wrap=True,
|
| 405 |
+
interactive=True # Make it interactive to detect selections
|
| 406 |
)
|
| 407 |
|
| 408 |
# --- Chatbot Tab ---
|
|
|
|
| 585 |
status = "Status: Keywords extracted. User requirements saved for analysis."
|
| 586 |
return final_keywords_str, status, user_requirements
|
| 587 |
|
| 588 |
+
def handle_dataframe_select(evt: gr.SelectData, df_data) -> Tuple[str, Any]:
|
| 589 |
+
"""Handle dataframe row selection and navigate to repo explorer."""
|
| 590 |
+
if evt is None or df_data is None or len(df_data) == 0:
|
| 591 |
+
return "", gr.update()
|
| 592 |
+
|
| 593 |
+
try:
|
| 594 |
+
# Get the selected row index
|
| 595 |
+
row_index = evt.index[0] if isinstance(evt.index, (list, tuple)) else evt.index
|
| 596 |
+
|
| 597 |
+
# Get the repository ID from the first column of the selected row
|
| 598 |
+
if row_index < len(df_data):
|
| 599 |
+
repo_id = df_data[row_index][0] if len(df_data[row_index]) > 0 else ""
|
| 600 |
+
|
| 601 |
+
# Navigate to repo explorer tab and pre-fill the repository ID
|
| 602 |
+
logger.info(f"Navigating to repo explorer for repository: {repo_id}")
|
| 603 |
+
return repo_id, gr.update(selected="repo_explorer_tab")
|
| 604 |
+
|
| 605 |
+
except Exception as e:
|
| 606 |
+
logger.error(f"Error handling dataframe selection: {e}")
|
| 607 |
+
|
| 608 |
+
return "", gr.update()
|
| 609 |
+
|
| 610 |
# --- Component Event Wiring ---
|
| 611 |
|
| 612 |
# Initialize chatbot with welcome message on app load
|
|
|
|
| 671 |
# Repo Explorer Tab
|
| 672 |
setup_repo_explorer_events(repo_components, repo_states)
|
| 673 |
|
| 674 |
+
# Add dataframe selection event
|
| 675 |
+
df_output.select(
|
| 676 |
+
fn=handle_dataframe_select,
|
| 677 |
+
inputs=[df_output],
|
| 678 |
+
outputs=[repo_components["repo_explorer_input"], tabs]
|
| 679 |
+
)
|
| 680 |
+
|
| 681 |
return app
|
| 682 |
|
| 683 |
if __name__ == "__main__":
|
repo_explorer.py
CHANGED
|
@@ -161,7 +161,8 @@ def create_repo_explorer_tab() -> Tuple[Dict[str, gr.components.Component], Dict
|
|
| 161 |
"https://cdn-icons-png.flaticon.com/512/149/149071.png",
|
| 162 |
"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"
|
| 163 |
),
|
| 164 |
-
show_copy_button=True
|
|
|
|
| 165 |
)
|
| 166 |
|
| 167 |
with gr.Row():
|
|
|
|
| 161 |
"https://cdn-icons-png.flaticon.com/512/149/149071.png",
|
| 162 |
"https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png"
|
| 163 |
),
|
| 164 |
+
show_copy_button=True,
|
| 165 |
+
value=[{"role": "assistant", "content": "π Welcome to the Repository Explorer! \n\nπ **How to get started:**\n1. Enter a Hugging Face repository ID above (e.g., 'microsoft/DialoGPT-medium')\n2. Click 'π Load Repository' to download and analyze the repository\n3. Once loaded, I'll have comprehensive knowledge of all the files and can answer questions about:\n β’ What the repository does\n β’ How to install and use it\n β’ Code structure and architecture\n β’ Key features and capabilities\n β’ Examples and usage patterns\n\nπ‘ **Tip:** I analyze repositories in chunks to understand the entire codebase, not just a summary!\n\nPlease load a repository to begin exploring! π"}]
|
| 166 |
)
|
| 167 |
|
| 168 |
with gr.Row():
|