Update app.py
Browse files
app.py
CHANGED
@@ -553,6 +553,7 @@ def create_ui() -> gr.Blocks:
|
|
553 |
user_requirements_state = gr.State("") # Store user requirements from chatbot
|
554 |
loaded_repo_content_state = gr.State("") # Store loaded repository content
|
555 |
current_repo_id_state = gr.State("") # Store current repository ID
|
|
|
556 |
|
557 |
gr.Markdown(
|
558 |
"""
|
@@ -868,14 +869,14 @@ def create_ui() -> gr.Blocks:
|
|
868 |
status = "Status: Keywords extracted. User requirements saved for analysis."
|
869 |
return final_keywords_str, status, user_requirements
|
870 |
|
871 |
-
def handle_dataframe_select(evt: gr.SelectData, df_data) -> Tuple[str, Any, Any, str, str, Any]:
|
872 |
"""Handle dataframe row selection - only repo ID (column 0) shows modal since full text is now displayed directly."""
|
873 |
print(f"DEBUG: Selection event triggered!")
|
874 |
print(f"DEBUG: evt = {evt}")
|
875 |
print(f"DEBUG: df_data type = {type(df_data)}")
|
876 |
|
877 |
if evt is None:
|
878 |
-
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False)
|
879 |
|
880 |
try:
|
881 |
# Get the selected row and column from the event
|
@@ -893,12 +894,12 @@ def create_ui() -> gr.Blocks:
|
|
893 |
if repo_id and str(repo_id).strip() and str(repo_id).strip() != 'nan':
|
894 |
clean_repo_id = str(repo_id).strip()
|
895 |
logger.info(f"Showing modal for repository: {clean_repo_id}")
|
896 |
-
return clean_repo_id, gr.update(visible=True), gr.update(), "", "", gr.update(visible=False)
|
897 |
|
898 |
# For content columns (1,2,3) and relevance (4), do nothing since full text is shown directly
|
899 |
else:
|
900 |
print(f"DEBUG: Clicked on column {col_idx}, full text already shown in table")
|
901 |
-
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False)
|
902 |
else:
|
903 |
print(f"DEBUG: df_data is not a DataFrame or row_idx {row_idx} out of range")
|
904 |
|
@@ -906,7 +907,7 @@ def create_ui() -> gr.Blocks:
|
|
906 |
print(f"DEBUG: Exception occurred: {e}")
|
907 |
logger.error(f"Error handling dataframe selection: {e}")
|
908 |
|
909 |
-
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False)
|
910 |
|
911 |
def handle_analyze_all_repos(repo_ids: List[str], user_requirements: str, progress=gr.Progress()) -> Tuple[pd.DataFrame, str, pd.DataFrame, Any]:
|
912 |
"""Analyzes all repositories in the CSV file with progress tracking."""
|
@@ -1036,14 +1037,14 @@ def create_ui() -> gr.Blocks:
|
|
1036 |
return gr.update(visible=False), hf_url
|
1037 |
return gr.update(visible=False), ""
|
1038 |
|
1039 |
-
def handle_explore_repo(
|
1040 |
"""Handle navigating to the repo explorer and populate the repo ID."""
|
1041 |
-
logger.info(f"DEBUG: handle_explore_repo called with
|
1042 |
-
logger.info(f"DEBUG:
|
1043 |
-
logger.info(f"DEBUG:
|
1044 |
|
1045 |
-
if
|
1046 |
-
clean_repo_id =
|
1047 |
return (
|
1048 |
gr.update(visible=False), # close modal
|
1049 |
gr.update(selected="repo_explorer_tab"), # switch tab
|
@@ -1201,7 +1202,7 @@ def create_ui() -> gr.Blocks:
|
|
1201 |
)
|
1202 |
explore_repo_btn.click(
|
1203 |
fn=handle_explore_repo,
|
1204 |
-
inputs=[
|
1205 |
outputs=[
|
1206 |
repo_action_modal,
|
1207 |
tabs,
|
@@ -1229,14 +1230,14 @@ def create_ui() -> gr.Blocks:
|
|
1229 |
df_output.select(
|
1230 |
fn=handle_dataframe_select,
|
1231 |
inputs=[df_output],
|
1232 |
-
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal]
|
1233 |
)
|
1234 |
|
1235 |
# Add selection event for top repositories dataframe too
|
1236 |
top_repos_df.select(
|
1237 |
fn=handle_dataframe_select,
|
1238 |
inputs=[top_repos_df],
|
1239 |
-
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal]
|
1240 |
)
|
1241 |
|
1242 |
# Reset button event
|
|
|
553 |
user_requirements_state = gr.State("") # Store user requirements from chatbot
|
554 |
loaded_repo_content_state = gr.State("") # Store loaded repository content
|
555 |
current_repo_id_state = gr.State("") # Store current repository ID
|
556 |
+
selected_repo_id_state = gr.State("") # Store selected repository ID for modal actions
|
557 |
|
558 |
gr.Markdown(
|
559 |
"""
|
|
|
869 |
status = "Status: Keywords extracted. User requirements saved for analysis."
|
870 |
return final_keywords_str, status, user_requirements
|
871 |
|
872 |
+
def handle_dataframe_select(evt: gr.SelectData, df_data) -> Tuple[str, Any, Any, str, str, Any, str]:
|
873 |
"""Handle dataframe row selection - only repo ID (column 0) shows modal since full text is now displayed directly."""
|
874 |
print(f"DEBUG: Selection event triggered!")
|
875 |
print(f"DEBUG: evt = {evt}")
|
876 |
print(f"DEBUG: df_data type = {type(df_data)}")
|
877 |
|
878 |
if evt is None:
|
879 |
+
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False), ""
|
880 |
|
881 |
try:
|
882 |
# Get the selected row and column from the event
|
|
|
894 |
if repo_id and str(repo_id).strip() and str(repo_id).strip() != 'nan':
|
895 |
clean_repo_id = str(repo_id).strip()
|
896 |
logger.info(f"Showing modal for repository: {clean_repo_id}")
|
897 |
+
return clean_repo_id, gr.update(visible=True), gr.update(), "", "", gr.update(visible=False), clean_repo_id
|
898 |
|
899 |
# For content columns (1,2,3) and relevance (4), do nothing since full text is shown directly
|
900 |
else:
|
901 |
print(f"DEBUG: Clicked on column {col_idx}, full text already shown in table")
|
902 |
+
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False), ""
|
903 |
else:
|
904 |
print(f"DEBUG: df_data is not a DataFrame or row_idx {row_idx} out of range")
|
905 |
|
|
|
907 |
print(f"DEBUG: Exception occurred: {e}")
|
908 |
logger.error(f"Error handling dataframe selection: {e}")
|
909 |
|
910 |
+
return "", gr.update(visible=False), gr.update(), "", "", gr.update(visible=False), ""
|
911 |
|
912 |
def handle_analyze_all_repos(repo_ids: List[str], user_requirements: str, progress=gr.Progress()) -> Tuple[pd.DataFrame, str, pd.DataFrame, Any]:
|
913 |
"""Analyzes all repositories in the CSV file with progress tracking."""
|
|
|
1037 |
return gr.update(visible=False), hf_url
|
1038 |
return gr.update(visible=False), ""
|
1039 |
|
1040 |
+
def handle_explore_repo(selected_repo_id: str) -> Tuple[Any, Any, Any]:
|
1041 |
"""Handle navigating to the repo explorer and populate the repo ID."""
|
1042 |
+
logger.info(f"DEBUG: handle_explore_repo called with selected_repo_id: '{selected_repo_id}'")
|
1043 |
+
logger.info(f"DEBUG: selected_repo_id type: {type(selected_repo_id)}")
|
1044 |
+
logger.info(f"DEBUG: selected_repo_id length: {len(selected_repo_id) if selected_repo_id else 'None'}")
|
1045 |
|
1046 |
+
if selected_repo_id and selected_repo_id.strip() and selected_repo_id.strip() != 'nan':
|
1047 |
+
clean_repo_id = selected_repo_id.strip()
|
1048 |
return (
|
1049 |
gr.update(visible=False), # close modal
|
1050 |
gr.update(selected="repo_explorer_tab"), # switch tab
|
|
|
1202 |
)
|
1203 |
explore_repo_btn.click(
|
1204 |
fn=handle_explore_repo,
|
1205 |
+
inputs=[selected_repo_id_state],
|
1206 |
outputs=[
|
1207 |
repo_action_modal,
|
1208 |
tabs,
|
|
|
1230 |
df_output.select(
|
1231 |
fn=handle_dataframe_select,
|
1232 |
inputs=[df_output],
|
1233 |
+
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal, selected_repo_id_state]
|
1234 |
)
|
1235 |
|
1236 |
# Add selection event for top repositories dataframe too
|
1237 |
top_repos_df.select(
|
1238 |
fn=handle_dataframe_select,
|
1239 |
inputs=[top_repos_df],
|
1240 |
+
outputs=[selected_repo_display, repo_action_modal, tabs, expanded_content_title, expanded_content_text, text_expansion_modal, selected_repo_id_state]
|
1241 |
)
|
1242 |
|
1243 |
# Reset button event
|