Update app.py
Browse files
app.py
CHANGED
@@ -64,14 +64,25 @@ def keyword_search_and_update(keyword):
|
|
64 |
global last_repo_ids, current_repo_idx
|
65 |
if not keyword:
|
66 |
return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
current_repo_idx = 0
|
70 |
csv_filename = "repo_ids.csv"
|
71 |
with open(csv_filename, mode="w", newline='', encoding="utf-8") as csvfile:
|
72 |
writer = csv.writer(csvfile)
|
73 |
writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
74 |
-
for repo_id in
|
75 |
writer.writerow([repo_id, "", "", "", ""])
|
76 |
df = read_csv_as_text(csv_filename)
|
77 |
return df
|
@@ -188,7 +199,7 @@ with gr.Blocks() as demo:
|
|
188 |
# --- Page 1: Input ---
|
189 |
with gr.Column(visible=False) as input_page:
|
190 |
gr.Markdown("## Enter Keyword or Repo IDs")
|
191 |
-
keyword_input = gr.Textbox(label="Enter
|
192 |
keyword_btn = gr.Button("Search and Update Repo List")
|
193 |
repo_id_box = repo_id_input.render()
|
194 |
df_box = df_output.render()
|
@@ -228,6 +239,9 @@ with gr.Blocks() as demo:
|
|
228 |
headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"],
|
229 |
datatype=["str", "str", "str", "str", "str", "str"]
|
230 |
)
|
|
|
|
|
|
|
231 |
back_to_start_btn4 = gr.Button("Back to Start")
|
232 |
|
233 |
# Navigation logic
|
@@ -273,4 +287,7 @@ with gr.Blocks() as demo:
|
|
273 |
outputs=[chatbot_page, input_page, analysis_page, results_page, results_df]
|
274 |
)
|
275 |
|
|
|
|
|
|
|
276 |
demo.launch()
|
|
|
64 |
global last_repo_ids, current_repo_idx
|
65 |
if not keyword:
|
66 |
return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
67 |
+
# Accept multiple keywords, comma or newline separated
|
68 |
+
keyword_list = [k.strip() for k in re.split(r'[\n,]+', keyword) if k.strip()]
|
69 |
+
repo_ids = []
|
70 |
+
for kw in keyword_list:
|
71 |
+
repo_ids.extend(search_top_spaces(kw, limit=5))
|
72 |
+
# Remove duplicates while preserving order
|
73 |
+
seen = set()
|
74 |
+
unique_repo_ids = []
|
75 |
+
for rid in repo_ids:
|
76 |
+
if rid not in seen:
|
77 |
+
unique_repo_ids.append(rid)
|
78 |
+
seen.add(rid)
|
79 |
+
last_repo_ids = unique_repo_ids
|
80 |
current_repo_idx = 0
|
81 |
csv_filename = "repo_ids.csv"
|
82 |
with open(csv_filename, mode="w", newline='', encoding="utf-8") as csvfile:
|
83 |
writer = csv.writer(csvfile)
|
84 |
writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
85 |
+
for repo_id in unique_repo_ids:
|
86 |
writer.writerow([repo_id, "", "", "", ""])
|
87 |
df = read_csv_as_text(csv_filename)
|
88 |
return df
|
|
|
199 |
# --- Page 1: Input ---
|
200 |
with gr.Column(visible=False) as input_page:
|
201 |
gr.Markdown("## Enter Keyword or Repo IDs")
|
202 |
+
keyword_input = gr.Textbox(label="Enter keywords to search repos (comma or newline separated)", lines=2, placeholder="e.g. audio, vision\ntext")
|
203 |
keyword_btn = gr.Button("Search and Update Repo List")
|
204 |
repo_id_box = repo_id_input.render()
|
205 |
df_box = df_output.render()
|
|
|
239 |
headers=["repo id", "strength", "weaknesses", "speciality", "relevance rating", "Usecase"],
|
240 |
datatype=["str", "str", "str", "str", "str", "str"]
|
241 |
)
|
242 |
+
analyze_next_btn = gr.Button("Download, Combine & Analyze Next Repo")
|
243 |
+
combined_txt_results = gr.Textbox(label="Combined Repo Files", lines=20)
|
244 |
+
llm_output_txt_results = gr.Textbox(label="LLM Analysis Output", lines=10)
|
245 |
back_to_start_btn4 = gr.Button("Back to Start")
|
246 |
|
247 |
# Navigation logic
|
|
|
287 |
outputs=[chatbot_page, input_page, analysis_page, results_page, results_df]
|
288 |
)
|
289 |
|
290 |
+
# Add logic for the new button on results_page
|
291 |
+
analyze_next_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt_results, llm_output_txt_results, results_df])
|
292 |
+
|
293 |
demo.launch()
|