Update app.py
Browse files
app.py
CHANGED
@@ -66,31 +66,35 @@ def show_combined_repo_and_llm():
|
|
66 |
llm_json = parse_llm_json_response(llm_output)
|
67 |
# Update CSV for the current repo id
|
68 |
csv_filename = "repo_ids.csv"
|
|
|
|
|
|
|
69 |
try:
|
70 |
df = pd.read_csv(csv_filename)
|
71 |
-
highlight_idx = None
|
72 |
# Cast columns to string to avoid dtype issues
|
73 |
for col in ["strength", "weaknesses", "speciality", "relevance rating"]:
|
74 |
df[col] = df[col].astype(str)
|
75 |
for idx, row in df.iterrows():
|
76 |
if row["repo id"] == repo_id:
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
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 |
-
|
|
|
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,7 +112,7 @@ with gr.Blocks() as demo:
|
|
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"
|
112 |
)
|
113 |
combine_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt, llm_output_txt, df_display])
|
114 |
|
|
|
66 |
llm_json = parse_llm_json_response(llm_output)
|
67 |
# Update CSV for the current repo id
|
68 |
csv_filename = "repo_ids.csv"
|
69 |
+
extraction_status = ""
|
70 |
+
strengths = ""
|
71 |
+
weaknesses = ""
|
72 |
try:
|
73 |
df = pd.read_csv(csv_filename)
|
|
|
74 |
# Cast columns to string to avoid dtype issues
|
75 |
for col in ["strength", "weaknesses", "speciality", "relevance rating"]:
|
76 |
df[col] = df[col].astype(str)
|
77 |
for idx, row in df.iterrows():
|
78 |
if row["repo id"] == repo_id:
|
79 |
+
if isinstance(llm_json, dict) and "error" not in llm_json:
|
80 |
+
extraction_status = "JSON extraction: SUCCESS"
|
81 |
+
strengths = llm_json.get("strength", "")
|
82 |
+
weaknesses = llm_json.get("weaknesses", "")
|
83 |
+
df.at[idx, "strength"] = strengths
|
84 |
+
df.at[idx, "weaknesses"] = weaknesses
|
85 |
df.at[idx, "speciality"] = llm_json.get("speciality", "")
|
86 |
df.at[idx, "relevance rating"] = llm_json.get("relevance rating", "")
|
87 |
+
else:
|
88 |
+
extraction_status = f"JSON extraction: FAILED\nRaw: {llm_json.get('raw', '') if isinstance(llm_json, dict) else llm_json}"
|
89 |
break
|
|
|
|
|
|
|
|
|
90 |
df.to_csv(csv_filename, index=False)
|
91 |
except Exception as e:
|
92 |
df = pd.read_csv(csv_filename)
|
93 |
+
extraction_status = f"CSV update error: {e}"
|
94 |
# Move to next repo for next click
|
95 |
current_repo_idx += 1
|
96 |
+
summary = f"{extraction_status}\n\nStrengths:\n{strengths}\n\nWeaknesses:\n{weaknesses}"
|
97 |
+
return combined_content, summary, df
|
98 |
|
99 |
repo_id_input = gr.Textbox(label="Enter repo IDs (comma or newline separated)", lines=5, placeholder="repo1, repo2\nrepo3")
|
100 |
df_output = gr.Dataframe(headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"])
|
|
|
112 |
combined_txt = gr.Textbox(label="Combined Repo Files", lines=20)
|
113 |
llm_output_txt = gr.Textbox(label="LLM Analysis Output", lines=10)
|
114 |
df_display = gr.Dataframe(
|
115 |
+
headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"]
|
116 |
)
|
117 |
combine_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt, llm_output_txt, df_display])
|
118 |
|