Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,20 +48,20 @@ def process_repo_input_and_store(text):
|
|
| 48 |
def show_combined_repo_and_llm():
|
| 49 |
global current_repo_idx
|
| 50 |
if not last_repo_ids:
|
| 51 |
-
return "No repo ID available. Please submit repo IDs first.", "", pd.DataFrame()
|
| 52 |
if current_repo_idx >= len(last_repo_ids):
|
| 53 |
-
return "All repo IDs have been processed.", "", pd.read_csv("repo_ids.csv")
|
| 54 |
repo_id = last_repo_ids[current_repo_idx]
|
| 55 |
try:
|
| 56 |
download_space_repo(repo_id, local_dir="repo_files")
|
| 57 |
except Exception as e:
|
| 58 |
-
return f"Error downloading repo: {e}", "", pd.read_csv("repo_ids.csv")
|
| 59 |
txt_path = combine_repo_files_for_llm()
|
| 60 |
try:
|
| 61 |
with open(txt_path, "r", encoding="utf-8") as f:
|
| 62 |
combined_content = f.read()
|
| 63 |
except Exception as e:
|
| 64 |
-
return f"Error reading {txt_path}: {e}", "", pd.read_csv("repo_ids.csv")
|
| 65 |
llm_output = analyze_combined_file(txt_path)
|
| 66 |
llm_json = parse_llm_json_response(llm_output)
|
| 67 |
# Update CSV for the current repo id
|
|
@@ -81,13 +81,16 @@ def show_combined_repo_and_llm():
|
|
| 81 |
df.at[idx, "speciality"] = llm_json.get("speciality", "")
|
| 82 |
df.at[idx, "relevance rating"] = llm_json.get("relevance rating", "")
|
| 83 |
break
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
df.to_csv(csv_filename, index=False)
|
| 85 |
except Exception as e:
|
| 86 |
df = pd.read_csv(csv_filename)
|
| 87 |
-
highlight_idx = None
|
| 88 |
# Move to next repo for next click
|
| 89 |
current_repo_idx += 1
|
| 90 |
-
return combined_content, llm_output,
|
| 91 |
|
| 92 |
repo_id_input = gr.Textbox(label="Enter repo IDs (comma or newline separated)", lines=5, placeholder="repo1, repo2\nrepo3")
|
| 93 |
df_output = gr.Dataframe(headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"])
|
|
@@ -105,8 +108,7 @@ with gr.Blocks() as demo:
|
|
| 105 |
combined_txt = gr.Textbox(label="Combined Repo Files", lines=20)
|
| 106 |
llm_output_txt = gr.Textbox(label="LLM Analysis Output", lines=10)
|
| 107 |
df_display = gr.Dataframe(
|
| 108 |
-
headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"]
|
| 109 |
-
highlight_row=True
|
| 110 |
)
|
| 111 |
combine_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt, llm_output_txt, df_display])
|
| 112 |
|
|
|
|
| 48 |
def show_combined_repo_and_llm():
|
| 49 |
global current_repo_idx
|
| 50 |
if not last_repo_ids:
|
| 51 |
+
return "No repo ID available. Please submit repo IDs first.", "", pd.DataFrame()
|
| 52 |
if current_repo_idx >= len(last_repo_ids):
|
| 53 |
+
return "All repo IDs have been processed.", "", pd.read_csv("repo_ids.csv")
|
| 54 |
repo_id = last_repo_ids[current_repo_idx]
|
| 55 |
try:
|
| 56 |
download_space_repo(repo_id, local_dir="repo_files")
|
| 57 |
except Exception as e:
|
| 58 |
+
return f"Error downloading repo: {e}", "", pd.read_csv("repo_ids.csv")
|
| 59 |
txt_path = combine_repo_files_for_llm()
|
| 60 |
try:
|
| 61 |
with open(txt_path, "r", encoding="utf-8") as f:
|
| 62 |
combined_content = f.read()
|
| 63 |
except Exception as e:
|
| 64 |
+
return f"Error reading {txt_path}: {e}", "", pd.read_csv("repo_ids.csv")
|
| 65 |
llm_output = analyze_combined_file(txt_path)
|
| 66 |
llm_json = parse_llm_json_response(llm_output)
|
| 67 |
# Update CSV for the current repo id
|
|
|
|
| 81 |
df.at[idx, "speciality"] = llm_json.get("speciality", "")
|
| 82 |
df.at[idx, "relevance rating"] = llm_json.get("relevance rating", "")
|
| 83 |
break
|
| 84 |
+
# Add Selected column for highlighting
|
| 85 |
+
df["Selected"] = ""
|
| 86 |
+
if highlight_idx is not None:
|
| 87 |
+
df.at[highlight_idx, "Selected"] = "✅"
|
| 88 |
df.to_csv(csv_filename, index=False)
|
| 89 |
except Exception as e:
|
| 90 |
df = pd.read_csv(csv_filename)
|
|
|
|
| 91 |
# Move to next repo for next click
|
| 92 |
current_repo_idx += 1
|
| 93 |
+
return combined_content, llm_output, df
|
| 94 |
|
| 95 |
repo_id_input = gr.Textbox(label="Enter repo IDs (comma or newline separated)", lines=5, placeholder="repo1, repo2\nrepo3")
|
| 96 |
df_output = gr.Dataframe(headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"])
|
|
|
|
| 108 |
combined_txt = gr.Textbox(label="Combined Repo Files", lines=20)
|
| 109 |
llm_output_txt = gr.Textbox(label="LLM Analysis Output", lines=10)
|
| 110 |
df_display = gr.Dataframe(
|
| 111 |
+
headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase", "Selected"]
|
|
|
|
| 112 |
)
|
| 113 |
combine_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt, llm_output_txt, df_display])
|
| 114 |
|