Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -235,7 +235,7 @@ def analyze_and_update_single_repo(repo_id: str, user_requirements: str = "") ->
|
|
| 235 |
if not repo_found_in_df:
|
| 236 |
logger.warning(f"Repo ID {repo_id} not found in CSV for updating.")
|
| 237 |
|
| 238 |
-
|
| 239 |
try:
|
| 240 |
df.to_csv(CSV_FILE, index=False)
|
| 241 |
# Force file system flush
|
|
@@ -600,8 +600,7 @@ def create_ui() -> gr.Blocks:
|
|
| 600 |
)
|
| 601 |
|
| 602 |
with gr.Row():
|
| 603 |
-
|
| 604 |
-
analyze_all_btn = gr.Button("π Analyze All Repositories", variant="secondary", size="lg", scale=1)
|
| 605 |
with gr.Column(scale=2):
|
| 606 |
status_box_analysis = gr.Textbox(label="π Analysis Status", interactive=False, lines=2)
|
| 607 |
|
|
@@ -795,26 +794,6 @@ def create_ui() -> gr.Blocks:
|
|
| 795 |
requirements = "\n".join([f"- {msg}" for msg in user_messages if msg.strip()])
|
| 796 |
return requirements
|
| 797 |
|
| 798 |
-
def handle_analyze_next(repo_ids: List[str], current_idx: int, user_requirements: str) -> Tuple[pd.DataFrame, int, str]:
|
| 799 |
-
"""Analyzes the next repository in the list."""
|
| 800 |
-
if not repo_ids:
|
| 801 |
-
return pd.DataFrame(), 0, "Status: No repositories to analyze. Please submit repo IDs first."
|
| 802 |
-
if current_idx >= len(repo_ids):
|
| 803 |
-
return format_dataframe_for_display(read_csv_to_dataframe()), current_idx, "Status: All repositories have been analyzed."
|
| 804 |
-
|
| 805 |
-
repo_id_to_analyze = repo_ids[current_idx]
|
| 806 |
-
status = f"Status: Analyzing repository {current_idx + 1}/{len(repo_ids)}: {repo_id_to_analyze}"
|
| 807 |
-
if user_requirements.strip():
|
| 808 |
-
status += f"\nUsing user requirements for relevance rating."
|
| 809 |
-
|
| 810 |
-
content, summary, df = analyze_and_update_single_repo(repo_id_to_analyze, user_requirements)
|
| 811 |
-
|
| 812 |
-
next_idx = current_idx + 1
|
| 813 |
-
if next_idx >= len(repo_ids):
|
| 814 |
-
status += "\n\nFinished all analyses."
|
| 815 |
-
|
| 816 |
-
return df, next_idx, status
|
| 817 |
-
|
| 818 |
def handle_user_message(user_message: str, history: List[Dict[str, str]]) -> Tuple[List[Dict[str, str]], str]:
|
| 819 |
"""Appends the user's message to the history, preparing for the bot's response."""
|
| 820 |
# Initialize chatbot with welcome message if empty
|
|
@@ -1126,11 +1105,6 @@ def create_ui() -> gr.Blocks:
|
|
| 1126 |
)
|
| 1127 |
|
| 1128 |
# Analysis Tab
|
| 1129 |
-
analyze_next_btn.click(
|
| 1130 |
-
fn=handle_analyze_next,
|
| 1131 |
-
inputs=[repo_ids_state, current_repo_idx_state, user_requirements_state],
|
| 1132 |
-
outputs=[df_output, current_repo_idx_state, status_box_analysis]
|
| 1133 |
-
)
|
| 1134 |
analyze_all_btn.click(
|
| 1135 |
fn=lambda: None, # No need to show progress display since it's commented out
|
| 1136 |
outputs=[]
|
|
|
|
| 235 |
if not repo_found_in_df:
|
| 236 |
logger.warning(f"Repo ID {repo_id} not found in CSV for updating.")
|
| 237 |
|
| 238 |
+
# Write CSV with better error handling and flushing
|
| 239 |
try:
|
| 240 |
df.to_csv(CSV_FILE, index=False)
|
| 241 |
# Force file system flush
|
|
|
|
| 600 |
)
|
| 601 |
|
| 602 |
with gr.Row():
|
| 603 |
+
analyze_all_btn = gr.Button("π Analyze All Repositories", variant="primary", size="lg", scale=1)
|
|
|
|
| 604 |
with gr.Column(scale=2):
|
| 605 |
status_box_analysis = gr.Textbox(label="π Analysis Status", interactive=False, lines=2)
|
| 606 |
|
|
|
|
| 794 |
requirements = "\n".join([f"- {msg}" for msg in user_messages if msg.strip()])
|
| 795 |
return requirements
|
| 796 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 797 |
def handle_user_message(user_message: str, history: List[Dict[str, str]]) -> Tuple[List[Dict[str, str]], str]:
|
| 798 |
"""Appends the user's message to the history, preparing for the bot's response."""
|
| 799 |
# Initialize chatbot with welcome message if empty
|
|
|
|
| 1105 |
)
|
| 1106 |
|
| 1107 |
# Analysis Tab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1108 |
analyze_all_btn.click(
|
| 1109 |
fn=lambda: None, # No need to show progress display since it's commented out
|
| 1110 |
outputs=[]
|