Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from functools import lru_cache
|
|
| 9 |
# CONFIG
|
| 10 |
# ----------------------------
|
| 11 |
JSON_FILE = "form-submissions-1.json"
|
| 12 |
-
MODEL_ID = "HuggingFaceH4/sgpt-3.5-mini"
|
| 13 |
HF_API_TOKEN = os.environ.get("HF_API_TOKEN")
|
| 14 |
FILTERED_CSV = "/tmp/filtered_candidates.csv"
|
| 15 |
OUTPUT_FILE = "/tmp/outputs.csv"
|
|
@@ -92,12 +92,12 @@ def filter_by_roles(category_name):
|
|
| 92 |
|
| 93 |
df = pd.DataFrame(filtered)
|
| 94 |
df.to_csv(FILTERED_CSV, index=False)
|
| 95 |
-
return df,
|
| 96 |
|
| 97 |
# ----------------------------
|
| 98 |
-
# Step 2: LLM recommendations
|
| 99 |
# ----------------------------
|
| 100 |
-
def
|
| 101 |
job_titles = CATEGORIES[category_name]
|
| 102 |
|
| 103 |
if not os.path.exists(FILTERED_CSV):
|
|
@@ -115,7 +115,7 @@ def llm_recommendations_gr(category_name):
|
|
| 115 |
for i in range(0, len(filtered_candidates), BATCH_SIZE):
|
| 116 |
batch = filtered_candidates[i:i+BATCH_SIZE]
|
| 117 |
for person in batch:
|
| 118 |
-
# Only send necessary info
|
| 119 |
candidate_info = {
|
| 120 |
"Name": person.get("Name"),
|
| 121 |
"Roles": person.get("Roles"),
|
|
@@ -141,7 +141,7 @@ def llm_recommendations_gr(category_name):
|
|
| 141 |
df_top5 = df_rec.head(5)
|
| 142 |
df_top5.to_csv(OUTPUT_FILE, index=False)
|
| 143 |
|
| 144 |
-
return df_top5,
|
| 145 |
|
| 146 |
# ----------------------------
|
| 147 |
# Show first 5 raw JSON candidates
|
|
@@ -172,7 +172,7 @@ with gr.Blocks() as app:
|
|
| 172 |
llm_button = gr.Button("Get LLM Recommendations")
|
| 173 |
llm_df = gr.Dataframe(label="Top 5 Recommended Candidates")
|
| 174 |
download_llm = gr.File(label="Download Recommendations CSV", file_types=[".csv"])
|
| 175 |
-
llm_button.click(
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
| 178 |
app.launch()
|
|
|
|
| 9 |
# CONFIG
|
| 10 |
# ----------------------------
|
| 11 |
JSON_FILE = "form-submissions-1.json"
|
| 12 |
+
MODEL_ID = "HuggingFaceH4/sgpt-3.5-mini"
|
| 13 |
HF_API_TOKEN = os.environ.get("HF_API_TOKEN")
|
| 14 |
FILTERED_CSV = "/tmp/filtered_candidates.csv"
|
| 15 |
OUTPUT_FILE = "/tmp/outputs.csv"
|
|
|
|
| 92 |
|
| 93 |
df = pd.DataFrame(filtered)
|
| 94 |
df.to_csv(FILTERED_CSV, index=False)
|
| 95 |
+
return df, FILTERED_CSV
|
| 96 |
|
| 97 |
# ----------------------------
|
| 98 |
+
# Step 2: LLM recommendations
|
| 99 |
# ----------------------------
|
| 100 |
+
def llm_recommendations(category_name):
|
| 101 |
job_titles = CATEGORIES[category_name]
|
| 102 |
|
| 103 |
if not os.path.exists(FILTERED_CSV):
|
|
|
|
| 115 |
for i in range(0, len(filtered_candidates), BATCH_SIZE):
|
| 116 |
batch = filtered_candidates[i:i+BATCH_SIZE]
|
| 117 |
for person in batch:
|
| 118 |
+
# Only send necessary info
|
| 119 |
candidate_info = {
|
| 120 |
"Name": person.get("Name"),
|
| 121 |
"Roles": person.get("Roles"),
|
|
|
|
| 141 |
df_top5 = df_rec.head(5)
|
| 142 |
df_top5.to_csv(OUTPUT_FILE, index=False)
|
| 143 |
|
| 144 |
+
return df_top5, OUTPUT_FILE
|
| 145 |
|
| 146 |
# ----------------------------
|
| 147 |
# Show first 5 raw JSON candidates
|
|
|
|
| 172 |
llm_button = gr.Button("Get LLM Recommendations")
|
| 173 |
llm_df = gr.Dataframe(label="Top 5 Recommended Candidates")
|
| 174 |
download_llm = gr.File(label="Download Recommendations CSV", file_types=[".csv"])
|
| 175 |
+
llm_button.click(llm_recommendations, inputs=[category_dropdown], outputs=[llm_df, download_llm])
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
| 178 |
app.launch()
|