Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,17 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from docx import Document
|
| 3 |
import PyPDF2
|
|
|
|
| 4 |
|
| 5 |
# Title of the app
|
| 6 |
st.title("JD-Resume Fit Check App")
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
# Create two columns
|
| 9 |
col1, col2 = st.columns(2)
|
| 10 |
|
|
@@ -38,29 +45,43 @@ st.subheader("Fit Check Results")
|
|
| 38 |
|
| 39 |
# Ensure both resume and JD are provided before proceeding
|
| 40 |
if resume_text and job_description:
|
| 41 |
-
st.write("Your resume and job description are being processed...")
|
| 42 |
-
|
| 43 |
-
# Call the generative AI API or process the match logic here (e.g., calling the Gemini API)
|
| 44 |
-
# For now, we simulate the match process and display the output
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
else:
|
| 66 |
st.write("Please upload both a resume and a job description.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from docx import Document
|
| 3 |
import PyPDF2
|
| 4 |
+
import genai # Assuming the Gemini client is available as 'genai'
|
| 5 |
|
| 6 |
# Title of the app
|
| 7 |
st.title("JD-Resume Fit Check App")
|
| 8 |
|
| 9 |
+
# Retrieve the API key from Streamlit secrets
|
| 10 |
+
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]
|
| 11 |
+
|
| 12 |
+
# Configure the Google Generative AI API with your API key
|
| 13 |
+
genai.configure(api_key=GOOGLE_API_KEY)
|
| 14 |
+
|
| 15 |
# Create two columns
|
| 16 |
col1, col2 = st.columns(2)
|
| 17 |
|
|
|
|
| 45 |
|
| 46 |
# Ensure both resume and JD are provided before proceeding
|
| 47 |
if resume_text and job_description:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
# Display a "Generate" button
|
| 50 |
+
if st.button("Generate Match Score"):
|
| 51 |
+
|
| 52 |
+
st.write("Your resume and job description are being processed...")
|
| 53 |
+
|
| 54 |
+
# Construct the prompt for analysis
|
| 55 |
+
prompt = f"""
|
| 56 |
+
You are an expert recruiter and hiring manager assistant. Analyze the following details and provide a match score (0-10) for how well the resume matches the job description:
|
| 57 |
|
| 58 |
+
1. Analyze this Resume: {resume_text}
|
| 59 |
+
2. Analyze this Job Description: {job_description}
|
| 60 |
+
3. Identify the key skills, experience, and qualifications mentioned in the job description.
|
| 61 |
+
4. Compare the above with the details provided in the resume.
|
| 62 |
+
5. Provide a match score based on how well the resume aligns with the job description. Include a brief justification for the score.
|
| 63 |
+
"""
|
| 64 |
|
| 65 |
+
# Call the Gemini API (ensure you're using the right method for Gemini)
|
| 66 |
+
try:
|
| 67 |
+
# Generate content using the Gemini API (adjust the model name as needed)
|
| 68 |
+
response = genai.GenerativeModel('gemini-pro').generate_content(prompt)
|
| 69 |
+
|
| 70 |
+
# Parse the response (assuming it's a simple text-based response)
|
| 71 |
+
match_score = response.text.strip().split('\n')[0] # Get the match score (adjust if response format is different)
|
| 72 |
+
justification = '\n'.join(response.text.strip().split('\n')[1:]) # Get justification (adjust if needed)
|
| 73 |
|
| 74 |
+
# Display results
|
| 75 |
+
st.write(f"**Match Score:** {match_score}/10")
|
| 76 |
+
st.write(f"**Justification:** {justification}")
|
| 77 |
+
|
| 78 |
+
except Exception as e:
|
| 79 |
+
st.error(f"Error generating match score: {str(e)}")
|
| 80 |
else:
|
| 81 |
st.write("Please upload both a resume and a job description.")
|
| 82 |
+
|
| 83 |
+
# Add space or content at the bottom
|
| 84 |
+
st.write("\n" * 20) # Adds space to push the content down
|
| 85 |
+
|
| 86 |
+
# Footer
|
| 87 |
+
st.markdown("Built with 🧠 by Hruday & Google Gemini")
|