Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,14 +11,13 @@ JSON_URL = "https://file.notion.so/f/f/f86ed84d-b33c-4dfb-b0e0-97c5661516a3/3ed5
|
|
| 11 |
|
| 12 |
MODEL_ID = "HuggingFaceH4/zephyr-7b-beta"
|
| 13 |
|
| 14 |
-
# Access Hugging Face secret in Spaces
|
| 15 |
import os
|
| 16 |
HF_API_TOKEN = os.environ.get("HF_API_TOKEN")
|
| 17 |
if not HF_API_TOKEN:
|
| 18 |
raise ValueError("HF_API_TOKEN not found in environment. Add it in Space Secrets.")
|
| 19 |
|
| 20 |
# ----------------------------
|
| 21 |
-
# CATEGORIES
|
| 22 |
# ----------------------------
|
| 23 |
CATEGORIES = {
|
| 24 |
"AI": [
|
|
@@ -98,14 +97,16 @@ Respond only 'Yes' or 'No'.
|
|
| 98 |
"Skills": ", ".join(person.get("skills", [])),
|
| 99 |
"Salary": person.get("annual_salary_expectation", {}).get("full-time", "N/A")
|
| 100 |
})
|
|
|
|
| 101 |
if len(candidates) == 0:
|
| 102 |
return pd.DataFrame(), None
|
|
|
|
| 103 |
df = pd.DataFrame(candidates)
|
| 104 |
-
# Convert to CSV for
|
| 105 |
-
csv_buffer = io.
|
| 106 |
df.to_csv(csv_buffer, index=False)
|
| 107 |
-
|
| 108 |
-
return df,
|
| 109 |
|
| 110 |
# ----------------------------
|
| 111 |
# GRADIO INTERFACE
|
|
@@ -113,10 +114,10 @@ Respond only 'Yes' or 'No'.
|
|
| 113 |
def run_dashboard(category):
|
| 114 |
if category not in CATEGORIES:
|
| 115 |
return f"Category {category} not found.", None
|
| 116 |
-
df,
|
| 117 |
if df.empty:
|
| 118 |
return f"No suitable candidates found for {category}.", None
|
| 119 |
-
return df,
|
| 120 |
|
| 121 |
category_options = list(CATEGORIES.keys())
|
| 122 |
|
|
|
|
| 11 |
|
| 12 |
MODEL_ID = "HuggingFaceH4/zephyr-7b-beta"
|
| 13 |
|
|
|
|
| 14 |
import os
|
| 15 |
HF_API_TOKEN = os.environ.get("HF_API_TOKEN")
|
| 16 |
if not HF_API_TOKEN:
|
| 17 |
raise ValueError("HF_API_TOKEN not found in environment. Add it in Space Secrets.")
|
| 18 |
|
| 19 |
# ----------------------------
|
| 20 |
+
# CATEGORIES
|
| 21 |
# ----------------------------
|
| 22 |
CATEGORIES = {
|
| 23 |
"AI": [
|
|
|
|
| 97 |
"Skills": ", ".join(person.get("skills", [])),
|
| 98 |
"Salary": person.get("annual_salary_expectation", {}).get("full-time", "N/A")
|
| 99 |
})
|
| 100 |
+
|
| 101 |
if len(candidates) == 0:
|
| 102 |
return pd.DataFrame(), None
|
| 103 |
+
|
| 104 |
df = pd.DataFrame(candidates)
|
| 105 |
+
# Convert to CSV as BytesIO for Gradio
|
| 106 |
+
csv_buffer = io.BytesIO()
|
| 107 |
df.to_csv(csv_buffer, index=False)
|
| 108 |
+
csv_buffer.seek(0)
|
| 109 |
+
return df, csv_buffer
|
| 110 |
|
| 111 |
# ----------------------------
|
| 112 |
# GRADIO INTERFACE
|
|
|
|
| 114 |
def run_dashboard(category):
|
| 115 |
if category not in CATEGORIES:
|
| 116 |
return f"Category {category} not found.", None
|
| 117 |
+
df, csv_file = get_candidates_by_category(category, CATEGORIES[category])
|
| 118 |
if df.empty:
|
| 119 |
return f"No suitable candidates found for {category}.", None
|
| 120 |
+
return df, csv_file
|
| 121 |
|
| 122 |
category_options = list(CATEGORIES.keys())
|
| 123 |
|