Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -163,26 +163,46 @@ def unzip_and_process(zip_file, model_choice, openai_classifier, questions_strin
|
|
| 163 |
return excel_file # Return the path to the Excel file
|
| 164 |
|
| 165 |
def run_interface(questions_json, resumes_zip):
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
| 175 |
|
| 176 |
-
|
|
|
|
|
|
|
| 177 |
|
| 178 |
-
# Set up the Gradio interface
|
| 179 |
interface = gr.Interface(
|
| 180 |
fn=run_interface,
|
| 181 |
inputs=[
|
| 182 |
-
gr.File(label="Upload questions.json"),
|
| 183 |
-
gr.File(label="Upload ZIP of Resumes")
|
| 184 |
],
|
| 185 |
-
outputs=gr.File(label="Processed Results Excel")
|
|
|
|
|
|
|
|
|
|
| 186 |
)
|
| 187 |
|
| 188 |
-
|
|
|
|
|
|
| 163 |
return excel_file # Return the path to the Excel file
|
| 164 |
|
| 165 |
def run_interface(questions_json, resumes_zip):
|
| 166 |
+
try:
|
| 167 |
+
# Handle the questions.json file
|
| 168 |
+
if isinstance(questions_json, str):
|
| 169 |
+
# If it's a file path
|
| 170 |
+
with open(questions_json, 'r') as f:
|
| 171 |
+
questions_string = f.read()
|
| 172 |
+
else:
|
| 173 |
+
# If it's a temporary file object from Gradio
|
| 174 |
+
questions_string = questions_json.name
|
| 175 |
+
with open(questions_string, 'r') as f:
|
| 176 |
+
questions_string = f.read()
|
| 177 |
+
|
| 178 |
+
# Handle the ZIP file
|
| 179 |
+
if isinstance(resumes_zip, str):
|
| 180 |
+
zip_path = resumes_zip
|
| 181 |
+
else:
|
| 182 |
+
# If it's a temporary file object from Gradio
|
| 183 |
+
zip_path = resumes_zip.name
|
| 184 |
|
| 185 |
+
openai_classifier = OpenAIClassifier(api_key="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")
|
| 186 |
+
output_file = unzip_and_process(zip_path, "openai", openai_classifier, questions_string)
|
| 187 |
+
|
| 188 |
+
return output_file
|
| 189 |
|
| 190 |
+
except Exception as e:
|
| 191 |
+
print(f"Error in run_interface: {str(e)}")
|
| 192 |
+
raise gr.Error(f"Processing failed: {str(e)}")
|
| 193 |
|
| 194 |
+
# Set up the Gradio interface with better error handling
|
| 195 |
interface = gr.Interface(
|
| 196 |
fn=run_interface,
|
| 197 |
inputs=[
|
| 198 |
+
gr.File(label="Upload questions.json", type="file"),
|
| 199 |
+
gr.File(label="Upload ZIP of Resumes", type="file")
|
| 200 |
],
|
| 201 |
+
outputs=gr.File(label="Processed Results Excel"),
|
| 202 |
+
title="Resume Analysis System",
|
| 203 |
+
description="Upload a questions.json file and a ZIP file containing resumes to process.",
|
| 204 |
+
allow_flagging="never",
|
| 205 |
)
|
| 206 |
|
| 207 |
+
# Launch with debugging enabled
|
| 208 |
+
interface.launch(debug=True)
|