Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
import json
|
|
|
|
| 5 |
|
| 6 |
# ----------------------------
|
| 7 |
# CONFIG
|
|
@@ -98,26 +99,34 @@ Respond only 'Yes' or 'No'.
|
|
| 98 |
"Salary": person.get("annual_salary_expectation", {}).get("full-time", "N/A")
|
| 99 |
})
|
| 100 |
if len(candidates) == 0:
|
| 101 |
-
return
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
# ----------------------------
|
| 105 |
# GRADIO INTERFACE
|
| 106 |
# ----------------------------
|
| 107 |
def run_dashboard(category):
|
| 108 |
if category not in CATEGORIES:
|
| 109 |
-
return f"Category {category} not found."
|
| 110 |
-
df = get_candidates_by_category(category, CATEGORIES[category])
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
|
| 113 |
category_options = list(CATEGORIES.keys())
|
| 114 |
|
| 115 |
demo = gr.Interface(
|
| 116 |
fn=run_dashboard,
|
| 117 |
inputs=gr.Dropdown(category_options, label="Select Category"),
|
| 118 |
-
outputs=gr.Dataframe(label="Suitable Candidates"),
|
| 119 |
live=False,
|
| 120 |
-
title="Startup Candidate Dashboard - Zephyr-7B-Beta"
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
if __name__ == "__main__":
|
|
|
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
import json
|
| 5 |
+
import io
|
| 6 |
|
| 7 |
# ----------------------------
|
| 8 |
# CONFIG
|
|
|
|
| 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 download
|
| 105 |
+
csv_buffer = io.StringIO()
|
| 106 |
+
df.to_csv(csv_buffer, index=False)
|
| 107 |
+
csv_data = csv_buffer.getvalue()
|
| 108 |
+
return df, csv_data
|
| 109 |
|
| 110 |
# ----------------------------
|
| 111 |
# GRADIO INTERFACE
|
| 112 |
# ----------------------------
|
| 113 |
def run_dashboard(category):
|
| 114 |
if category not in CATEGORIES:
|
| 115 |
+
return f"Category {category} not found.", None
|
| 116 |
+
df, csv_data = get_candidates_by_category(category, CATEGORIES[category])
|
| 117 |
+
if df.empty:
|
| 118 |
+
return f"No suitable candidates found for {category}.", None
|
| 119 |
+
return df, csv_data
|
| 120 |
|
| 121 |
category_options = list(CATEGORIES.keys())
|
| 122 |
|
| 123 |
demo = gr.Interface(
|
| 124 |
fn=run_dashboard,
|
| 125 |
inputs=gr.Dropdown(category_options, label="Select Category"),
|
| 126 |
+
outputs=[gr.Dataframe(label="Suitable Candidates"), gr.File(label="Download CSV")],
|
| 127 |
live=False,
|
| 128 |
+
title="Startup Candidate Dashboard - Zephyr-7B-Beta",
|
| 129 |
+
description="Select a category to view suitable candidates. You can also download the results as CSV."
|
| 130 |
)
|
| 131 |
|
| 132 |
if __name__ == "__main__":
|