|
import gradio as gr |
|
import os |
|
from groq import Groq |
|
from PyPDF2 import PdfReader |
|
from docx import Document |
|
|
|
GROQ_API_KEY = os.environ.get("GROQ_API") |
|
client = Groq(api_key=GROQ_API_KEY) |
|
|
|
CSS = """ |
|
.duplicate-button { |
|
margin: auto !important; |
|
color: white !important; |
|
background: black !important; |
|
border-radius: 100vh !important; |
|
transition: transform 0.3s ease-in-out, background 0.3s ease-in-out; |
|
} |
|
.duplicate-button:hover { |
|
transform: scale(1.1); |
|
background: linear-gradient(135deg, #6e8efb, #a777e3) !important; |
|
box-shadow: 0px 4px 10px rgba(110, 142, 251, 0.6); |
|
} |
|
|
|
h3, p, h1 { |
|
text-align: center; |
|
color: white; |
|
transition: color 0.3s ease-in-out; |
|
} |
|
h3:hover, p:hover, h1:hover { |
|
color: #6e8efb; |
|
} |
|
|
|
footer { |
|
text-align: center; |
|
padding: 10px; |
|
width: 100%; |
|
background-color: black !important; |
|
z-index: 1000; |
|
position: relative; |
|
margin-top: 10px; |
|
color: white !important; |
|
font-weight: bold; |
|
transition: transform 0.3s ease-in-out; |
|
} |
|
footer:hover { |
|
transform: scale(1.02); |
|
} |
|
|
|
.container { |
|
background: rgba(255, 255, 255, 0.1); |
|
border-radius: 15px; |
|
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2); |
|
backdrop-filter: blur(10px); |
|
border: 1px solid rgba(255, 255, 255, 0.3); |
|
padding: 15px; |
|
transition: transform 0.3s ease-in-out; |
|
} |
|
.container:hover { |
|
transform: scale(1.02); |
|
} |
|
|
|
.navbar-toggle { |
|
background: black; |
|
color: white; |
|
padding: 10px; |
|
border-radius: 5px; |
|
cursor: pointer; |
|
text-align: center; |
|
margin-bottom: 10px; |
|
transition: transform 0.3s ease-in-out, background 0.3s ease-in-out; |
|
} |
|
.navbar-toggle:hover { |
|
background: linear-gradient(135deg, #6e8efb, #a777e3); |
|
transform: scale(1.05); |
|
} |
|
""" |
|
|
|
|
|
RESUME_ANALYZER_INSTRUCTIONS = """ |
|
<div class="container"> |
|
<p>π <strong>Instructions:</strong></p> |
|
<ul> |
|
<li>π Upload your resume (PDF or DOCX) in the file upload area.</li> |
|
<li>π If you want to analyze your resume against a specific job description, keep the checkbox checked and enter the job description in the text box.</li> |
|
<li>π‘ If you want a general resume analysis without a job description, uncheck the "Analyze with Job Description" box.</li> |
|
<li>π Click "Analyze Resume" to get your results.</li> |
|
</ul> |
|
</div> |
|
""" |
|
|
|
COVER_LETTER_INSTRUCTIONS = """ |
|
<div class="container"> |
|
<p>π <strong>Instructions for Cover Letter Generation:</strong></p> |
|
<ol> |
|
<li>π First, go to the "Resume Analyzer" tab.</li> |
|
<li>π Upload your resume and enter the job description there.</li> |
|
<li>π Then, come back to this tab and click "Generate Cover Letter".</li> |
|
</ol> |
|
</div> |
|
""" |
|
FOOTER_TEXT = """ |
|
<footer> |
|
<p>If you enjoyed the functionality of the app, please leave a like!<br> |
|
Check out more on <a href="https://www.linkedin.com/in/chowdam-jagan" target="_blank">LinkedIn</a> | |
|
</footer>""" |
|
|
|
INTERVIEW_QUESTIONS_INSTRUCTIONS = """ |
|
<div class="container"> |
|
<p>π§ <strong>Instructions for Interview Questions Generation:</strong></p> |
|
<p>π Enter the job description in the text box below and click "Generate Interview Questions".</p> |
|
</div> |
|
""" |
|
|
|
COVER_LETTER_DISCLAIMER = """ |
|
<p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;"> |
|
π’ Disclaimer: This cover letter is generated based on the provided job description and resume. |
|
It should be carefully reviewed and tailored to your specific needs and the company's requirements before use. |
|
</p> |
|
""" |
|
|
|
INTERVIEW_QUESTIONS_DISCLAIMER = """ |
|
<p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;"> |
|
π’ Disclaimer: These interview questions are generated based on the provided job description. |
|
They should be reviewed and adjusted to better fit the specific role, company culture, and interview process. |
|
</p> |
|
""" |
|
|
|
TITLE = "<h1>π ATS Resume Analyzer π</h1>" |
|
|
|
PLACEHOLDER = "π Chat with AI about your resume and job descriptions..." |
|
|
|
|
|
with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo: |
|
gr.HTML(TITLE) |
|
|
|
with gr.Tab("Resume Analyzer"): |
|
gr.HTML(RESUME_ANALYZER_INSTRUCTIONS) |
|
with gr.Row(): |
|
with gr.Column(): |
|
with_job_description = gr.Checkbox( |
|
label="Analyze with Job Description", |
|
value=True, |
|
info="Uncheck this box for a general resume analysis without a specific job description." |
|
) |
|
job_description = gr.Textbox(label="π Job Description", lines=5) |
|
resume_file = gr.File(label="π Upload Resume (PDF or DOCX)") |
|
with gr.Column(): |
|
resume_content = gr.Textbox(label="Parsed Resume Content", lines=10) |
|
analyze_btn = gr.Button("Analyze Resume", elem_classes="duplicate-button") |
|
output = gr.Markdown() |
|
|
|
with gr.Tab("Content Rephraser"): |
|
text_to_rephrase = gr.Textbox(label="π Text to Rephrase", lines=5) |
|
rephrase_btn = gr.Button("Rephrase", elem_classes="duplicate-button") |
|
rephrased_output = gr.Markdown() |
|
|
|
with gr.Tab("Cover Letter Generator"): |
|
gr.HTML(COVER_LETTER_INSTRUCTIONS) |
|
gr.HTML(COVER_LETTER_DISCLAIMER) |
|
generate_cl_btn = gr.Button("Generate Cover Letter", elem_classes="duplicate-button") |
|
cover_letter_output = gr.Markdown() |
|
|
|
with gr.Tab("Interview Questions Generator"): |
|
gr.HTML(INTERVIEW_QUESTIONS_INSTRUCTIONS) |
|
gr.HTML(INTERVIEW_QUESTIONS_DISCLAIMER) |
|
interview_job_description = gr.Textbox(label="π Job Description for Interview Questions", lines=5) |
|
generate_iq_btn = gr.Button("Generate Interview Questions", elem_classes="duplicate-button") |
|
interview_questions_output = gr.Markdown() |
|
|
|
with gr.Accordion("βοΈ Parameters", open=False): |
|
temperature = gr.Slider( |
|
minimum=0, maximum=1, step=0.1, value=0.5, label="π‘οΈ Temperature", |
|
) |
|
max_tokens = gr.Slider( |
|
minimum=50, maximum=1024, step=1, value=1024, label="π Max tokens", |
|
) |
|
|
|
gr.HTML(FOOTER_TEXT) |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |
|
|