Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,6 +83,31 @@ def create_pdf_report(report_text):
|
|
| 83 |
doc.build(Story)
|
| 84 |
return pdf_path
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# Build the Gradio UI
|
| 87 |
demo = gr.Blocks()
|
| 88 |
with demo:
|
|
@@ -93,10 +118,17 @@ with demo:
|
|
| 93 |
job_desc_input = gr.Textbox(label="Job Description", lines=5)
|
| 94 |
extracted_text = gr.Textbox(label="Extracted CV Content", lines=10, interactive=False)
|
| 95 |
analysis_output = gr.Textbox(label="Analysis Report", lines=10, interactive=False)
|
| 96 |
-
pdf_file = gr.File(label="Download Analysis Report PDF", interactive=True)
|
| 97 |
analyze_button = gr.Button("Analyze CV")
|
|
|
|
|
|
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
if __name__ == "__main__":
|
| 102 |
-
demo.queue().launch()
|
|
|
|
| 83 |
doc.build(Story)
|
| 84 |
return pdf_path
|
| 85 |
|
| 86 |
+
# Function to process and optimize resume
|
| 87 |
+
def process_resume(resume_file, job_title):
|
| 88 |
+
if resume_file is None:
|
| 89 |
+
return "Please upload a resume file."
|
| 90 |
+
try:
|
| 91 |
+
file_path = resume_file.name
|
| 92 |
+
file_ext = os.path.splitext(file_path)[1].lower()
|
| 93 |
+
if file_ext == ".pdf":
|
| 94 |
+
resume_text = extract_text_from_pdf(file_path)
|
| 95 |
+
elif file_ext == ".docx":
|
| 96 |
+
resume_text = extract_text_from_docx(file_path)
|
| 97 |
+
else:
|
| 98 |
+
return "Unsupported file format. Please upload a PDF or DOCX file."
|
| 99 |
+
if resume_text.startswith("Error"):
|
| 100 |
+
return resume_text
|
| 101 |
+
prompt = (
|
| 102 |
+
f"Optimize the following resume for the job title: {job_title}.\n"
|
| 103 |
+
f"Include relevant skills, experience, and keywords related to the job title.\n\n"
|
| 104 |
+
f"Resume:\n{resume_text}\n"
|
| 105 |
+
)
|
| 106 |
+
optimized_resume = client.text_generation(prompt, max_new_tokens=1024)
|
| 107 |
+
return optimized_resume
|
| 108 |
+
except Exception as e:
|
| 109 |
+
return f"Error processing resume: {e}"
|
| 110 |
+
|
| 111 |
# Build the Gradio UI
|
| 112 |
demo = gr.Blocks()
|
| 113 |
with demo:
|
|
|
|
| 118 |
job_desc_input = gr.Textbox(label="Job Description", lines=5)
|
| 119 |
extracted_text = gr.Textbox(label="Extracted CV Content", lines=10, interactive=False)
|
| 120 |
analysis_output = gr.Textbox(label="Analysis Report", lines=10, interactive=False)
|
|
|
|
| 121 |
analyze_button = gr.Button("Analyze CV")
|
| 122 |
+
download_pdf_button = gr.File(label="Download Analysis Report PDF", interactive=False)
|
| 123 |
+
analyze_button.click(parse_cv, [file_input, job_desc_input], [extracted_text, analysis_output, download_pdf_button])
|
| 124 |
|
| 125 |
+
with gr.Tab("CV Optimizer"):
|
| 126 |
+
gr.Markdown("### Upload your Resume and Enter Job Title")
|
| 127 |
+
resume_file = gr.File(label="Upload Resume (PDF or Word)", file_types=[".pdf", ".docx"])
|
| 128 |
+
job_title_input = gr.Textbox(label="Job Title", lines=1)
|
| 129 |
+
optimized_resume_output = gr.Textbox(label="Optimized Resume", lines=20)
|
| 130 |
+
optimize_button = gr.Button("Optimize Resume")
|
| 131 |
+
optimize_button.click(process_resume, [resume_file, job_title_input], [optimized_resume_output])
|
| 132 |
|
| 133 |
if __name__ == "__main__":
|
| 134 |
+
demo.queue().launch()
|