Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,15 +45,24 @@ st.subheader("Fit Check Results")
|
|
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 |
-
|
57 |
You are an expert recruiter and hiring manager assistant. Analyze the following details and provide a structured response in the specified format:
|
58 |
|
59 |
1. Resume: {resume_text}
|
@@ -74,29 +83,25 @@ if resume_text and job_description:
|
|
74 |
4. Interview Preparation Topics: [List relevant topics for interview preparation]
|
75 |
"""
|
76 |
|
77 |
-
# Call the Gemini API (using google-generativeai)
|
78 |
try:
|
79 |
-
# Generate content using the Gemini API
|
80 |
-
response = genai.
|
81 |
model='gemini-pro',
|
82 |
prompt=prompt,
|
83 |
temperature=0.3, # Lower temperature for deterministic results
|
84 |
-
top_p=0.9, # Nucleus sampling
|
85 |
-
max_output_tokens=500 # Limit response length
|
86 |
)
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
# Display results
|
94 |
-
#st.write(f"**Match Score:** {match_score}/10")
|
95 |
-
#st.write(f"**Justification:** {justification}")
|
96 |
-
st.write(response.text) # Display the generated response
|
97 |
|
98 |
except Exception as e:
|
99 |
-
st.error(f"Error
|
|
|
100 |
else:
|
101 |
st.write("Please upload both a resume and a job description.")
|
102 |
|
|
|
45 |
|
46 |
# Ensure both resume and JD are provided before proceeding
|
47 |
if resume_text and job_description:
|
48 |
+
# Check for minimum content length
|
49 |
+
if len(resume_text.strip()) < 100 or len(job_description.strip()) < 100:
|
50 |
+
st.error("Please provide more detailed Resume and Job Description.")
|
51 |
+
st.stop()
|
52 |
+
|
53 |
+
# Truncate input if too large
|
54 |
+
max_input_tokens = 4000 # Example limit
|
55 |
+
combined_input = f"{resume_text}\n{job_description}"
|
56 |
+
if len(combined_input.split()) > max_input_tokens:
|
57 |
+
combined_input = ' '.join(combined_input.split()[:max_input_tokens])
|
58 |
+
st.warning("Input text truncated to fit the model's token limit.")
|
59 |
+
|
60 |
# Display a "Generate" button
|
61 |
if st.button("Generate Match Score"):
|
|
|
62 |
st.write("Your resume and job description are being processed...")
|
63 |
|
64 |
# Construct the prompt for analysis
|
65 |
prompt = f"""
|
|
|
66 |
You are an expert recruiter and hiring manager assistant. Analyze the following details and provide a structured response in the specified format:
|
67 |
|
68 |
1. Resume: {resume_text}
|
|
|
83 |
4. Interview Preparation Topics: [List relevant topics for interview preparation]
|
84 |
"""
|
85 |
|
|
|
86 |
try:
|
87 |
+
# Generate content using the Gemini API
|
88 |
+
response = genai.generate_text(
|
89 |
model='gemini-pro',
|
90 |
prompt=prompt,
|
91 |
temperature=0.3, # Lower temperature for deterministic results
|
92 |
+
top_p=0.9, # Nucleus sampling
|
93 |
+
max_output_tokens=500 # Limit response length
|
94 |
)
|
95 |
|
96 |
+
# Ensure response contains text
|
97 |
+
if response and hasattr(response, "text"):
|
98 |
+
st.write(response.text) # Display the generated response
|
99 |
+
else:
|
100 |
+
st.error("No response received from the API.")
|
|
|
|
|
|
|
|
|
101 |
|
102 |
except Exception as e:
|
103 |
+
st.error(f"API Error: {str(e)}")
|
104 |
+
|
105 |
else:
|
106 |
st.write("Please upload both a resume and a job description.")
|
107 |
|