Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import regex as re
|
|
3 |
import csv
|
4 |
import pandas as pd
|
5 |
from analyzer import combine_repo_files_for_llm, analyze_combined_file, parse_llm_json_response
|
6 |
-
from hf_utils import download_space_repo
|
7 |
|
8 |
# from hf_utils import download_space_repo
|
9 |
|
@@ -48,6 +48,22 @@ def process_repo_input_and_store(text):
|
|
48 |
df = read_csv_as_text(csv_filename)
|
49 |
return df
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
def show_combined_repo_and_llm():
|
52 |
global current_repo_idx
|
53 |
if not last_repo_ids:
|
@@ -108,6 +124,12 @@ with gr.Blocks() as demo:
|
|
108 |
submit_btn = gr.Button("Submit Repo IDs")
|
109 |
submit_btn.click(process_repo_input_and_store, inputs=repo_id_box, outputs=df_box)
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
gr.Markdown("---")
|
112 |
gr.Markdown("## Combine and Display Repo Files")
|
113 |
combine_btn = gr.Button("Download, Combine & Show .py/.md Files from Next Repo and Analyze")
|
|
|
3 |
import csv
|
4 |
import pandas as pd
|
5 |
from analyzer import combine_repo_files_for_llm, analyze_combined_file, parse_llm_json_response
|
6 |
+
from hf_utils import download_space_repo, search_top_spaces
|
7 |
|
8 |
# from hf_utils import download_space_repo
|
9 |
|
|
|
48 |
df = read_csv_as_text(csv_filename)
|
49 |
return df
|
50 |
|
51 |
+
def keyword_search_and_update(keyword):
|
52 |
+
global last_repo_ids, current_repo_idx
|
53 |
+
if not keyword:
|
54 |
+
return pd.DataFrame(columns=["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
55 |
+
repo_ids = search_top_spaces(keyword, limit=5)
|
56 |
+
last_repo_ids = repo_ids
|
57 |
+
current_repo_idx = 0
|
58 |
+
csv_filename = "repo_ids.csv"
|
59 |
+
with open(csv_filename, mode="w", newline='', encoding="utf-8") as csvfile:
|
60 |
+
writer = csv.writer(csvfile)
|
61 |
+
writer.writerow(["repo id", "strength", "weaknesses", "speciality", "relevance rating"])
|
62 |
+
for repo_id in repo_ids:
|
63 |
+
writer.writerow([repo_id, "", "", "", ""])
|
64 |
+
df = read_csv_as_text(csv_filename)
|
65 |
+
return df
|
66 |
+
|
67 |
def show_combined_repo_and_llm():
|
68 |
global current_repo_idx
|
69 |
if not last_repo_ids:
|
|
|
124 |
submit_btn = gr.Button("Submit Repo IDs")
|
125 |
submit_btn.click(process_repo_input_and_store, inputs=repo_id_box, outputs=df_box)
|
126 |
|
127 |
+
gr.Markdown("---")
|
128 |
+
gr.Markdown("## Keyword Search for Repos")
|
129 |
+
keyword_input = gr.Textbox(label="Enter keyword to search repos", lines=1, placeholder="e.g. audio")
|
130 |
+
keyword_btn = gr.Button("Search and Update Repo List")
|
131 |
+
keyword_btn.click(keyword_search_and_update, inputs=keyword_input, outputs=df_box)
|
132 |
+
|
133 |
gr.Markdown("---")
|
134 |
gr.Markdown("## Combine and Display Repo Files")
|
135 |
combine_btn = gr.Button("Download, Combine & Show .py/.md Files from Next Repo and Analyze")
|