Spaces:
Sleeping
Sleeping
# -*- coding: utf-8 -*- | |
"""Untitled27.ipynb | |
Automatically generated by Colab. | |
Original file is located at | |
https://colab.research.google.com/drive/16VnJw-SMttFaPZi8gMJTp4k7YDqL-rP0 | |
""" | |
import streamlit as st | |
import os | |
from resume_generation_gemini_pro import Gemini_pro_main # Import function from your model file | |
from similarity_score_refined import similarity_main | |
# Helper function to save uploaded files temporarily and return their paths | |
def save_uploaded_file(uploaded_file): | |
# Define the temporary file path | |
file_path = os.path.join("/tmp", uploaded_file.name) | |
# Write the uploaded file content to the path | |
with open(file_path, "wb") as f: | |
f.write(uploaded_file.getbuffer()) | |
return file_path | |
# Streamlit UI layout | |
st.title("Resume Tailoring with Google Generative AI") | |
st.write("Upload your current resume and a job description to generate a tailored resume.") | |
# File uploaders for the current resume and job description | |
uploaded_resume = st.file_uploader("Upload Current Resume (.docx or .pdf)", type=["docx", "pdf"], key="resume") | |
uploaded_job_description = st.file_uploader("Upload Job Description (.docx or .pdf)", type=["docx", "pdf"], key="job_description") | |
if uploaded_resume is not None and uploaded_job_description is not None: | |
# Save both uploaded files and get their paths | |
resume_path = save_uploaded_file(uploaded_resume) | |
job_description_path = save_uploaded_file(uploaded_job_description) | |
st.write(f"Files saved at: {resume_path} and {job_description_path}") | |
# Button to calculate similarity score | |
if st.button("Check Similarity Score"): | |
# Calculate the similarity score between resume and job description using similarity_main | |
similarity_score = similarity_main(resume_path, job_description_path) | |
if isinstance(similarity_score, str) and '%' in similarity_score: | |
similarity_score = float(similarity_score.replace('%', '')) | |
# Display the similarity score on a slider | |
st.write("Similarity Score:") | |
st.slider("Similarity", min_value=0, max_value=100, value=int(similarity_score), format="%d%%") | |
# Generate tailored resume button | |
if st.button("Generate Tailored Resume"): | |
with st.spinner("Generating resume with Google Generative AI..."): | |
# Call the model function with both file paths | |
generated_resume = Gemini_pro_main(resume_path, job_description_path) # Assuming this function returns the resume text | |
# Display the generated tailored resume | |
st.subheader("Generated Tailored Resume:") | |
st.write(generated_resume) | |
else: | |
st.warning("Please upload both the current resume and job description files.") |