File size: 6,643 Bytes
d015b2a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
import streamlit as st
import groq
from prompts import analyze_job_fit, optimize_latex_resume,evaluate_resume,generate_cover_letter
import json
def main():
st.set_page_config(
layout="wide",
page_title="Resume Enhancer",
initial_sidebar_state="collapsed"
)
file_path = 'latex.txt'
with open(file_path, 'r') as f:
latex_template = f.read()
MODELS = [
"deepseek-r1-distill-llama-70b",
"gemma2-9b-it",
"llama-3.2-1b-preview",
"llama-3.2-3b-preview",
"llama-3.3-70b-versatile",
"llama-guard-3-8b",
"llama3-70b-8192",
"mixtral-8x7b-32768"]
# Custom CSS with reduced text sizes
st.markdown("""
<style>
.block-container {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
max-width: 1200px;
}
.stButton>button {
background-color: #2563eb;
color: white;
border-radius: 0.375rem;
padding: 0.75rem 1.5rem;
border: none;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
margin: 0.5rem;
min-width: 200px;
font-size: 0.875rem;
}
[data-testid="stFileUploader"] {
border: 2px dashed #e5e7eb;
border-radius: 0.5rem;
padding: 0.875rem;
min-height: 220px;
font-size: 0.875rem;
}
.stTextArea>div>div {
border-radius: 0.5rem;
min-height: 220px !important;
font-size: 0.875rem;
}
.stTextInput>div>div>input {
border-radius: 0.5rem;
font-size: 0.875rem;
}
.resume-html {
padding: 1.5rem;
max-width: 800px;
margin: 0 auto;
background: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
font-size: 0.875rem;
}
h1 {font-size: 3rem !important; /* Adjust this value to increase the font size */
} h2 {font-size: 1.5rem !important; /* Adjust this value to increase the font size */
h3, h4, h5, h6 {
font-size: 80% !important;
}
p, li {
font-size: 0.875rem !important;
}
</style>
""", unsafe_allow_html=True)
# Header with smaller text
st.markdown("""
<h1 style='text-align: center; font-size: 2.5rem; font-weight: 800; margin-bottom: 0.875rem;'>
Resume Easz
</h1>
""", unsafe_allow_html=True)
st.markdown("""
<h2 style='text-align: center; font-size: 1.5rem; font-weight: 400; margin-bottom: 0.875rem;'>
Analyze and Enhance Your Resume with AI
</h2>
""", unsafe_allow_html=True)
st.markdown("---")
# Initialize variables
resume_text = None
job_description = None
original_file = None
# Side-by-side inputs with equal width
col1, col2 = st.columns(2)
with col1:
st.markdown("##### Upload your biodata as JSON file")
resume = st.file_uploader(
"Drop your resume file here",
type=['json']
)
if resume is not None:
resume_text = json.load(resume)
with col2:
st.markdown("##### Job Description")
job_description = st.text_area(
"Paste job description",
placeholder="Paste the job description here...",
height=220,
label_visibility="collapsed"
)
# Centered API key input first
key = st.text_input(
"GROQ API Key",
type="password",
placeholder="Enter your GROQ API key...",
help="Your API key will not be stored"
)
selected_model =st.selectbox("Select Model", MODELS)
st.markdown("The selected model will be used for the major tasks such as latex code generation for resume and cover letter")
if key:
client = groq.Client(api_key=key)
# Centered action buttons
col_buttons, _, _ = st.columns([200,1,1])
with col_buttons:
col_b1, col_b2, col_b3 = st.columns(3)
process_quick = col_b1.button("Quick Analysis")
generate_reusme = col_b2.button("Generate Latex code for Resume")
geenrate_coverletter = col_b3.button("Generate latex code Cover Letter")
#to check if any of the buttons are clicked
if any([process_quick, generate_reusme, generate_cover_letter]):
if not resume_text:
st.error("Please upload your resume data in JSON format.")
elif not job_description:
st.error("Please paste provide the job description.")
else:
try:
with st.spinner("Processing your resume..."):
if process_quick:
analysis = analyze_job_fit(client, resume_text, job_description)
st.markdown("### Quick Analysis Results")
st.markdown(analysis)
elif generate_reusme:
with st.spinner(f"Optimizing LaTeX Resume using {selected_model}..."):
analysis = analyze_job_fit(client, resume_text, job_description)
optimized_latex = optimize_latex_resume(
client, analysis, latex_template, resume_text, selected_model)
st.subheader("Optimized LaTeX Resume")
st.code(optimized_latex, language="latex")
resume_evalaution = evaluate_resume(client, latex_template, optimized_latex, job_description, selected_model)
st.subheader("Resume Evaluation")
st.markdown(resume_evalaution)
else: # generate cover letter
cv_latex = generate_cover_letter(client, resume_text, job_description, selected_model)
st.subheader("latex code for Cover Letter")
st.code(cv_latex, language="latex")
except groq.RateLimitError as e:
st.error("API rate limit exceeded. Please try again later or use a different API key.")
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.info("👆 Please enter your GROQ API key to get started.")
if __name__ == "__main__":
main() |