Spaces:
Running
Running
Arjun Singh
commited on
Commit
·
5513f4b
1
Parent(s):
1e17a38
Change to analyze candidates
Browse files
app.py
CHANGED
|
@@ -98,23 +98,24 @@ def store_resumes(resume_files: List[tempfile._TemporaryFileWrapper]) -> str:
|
|
| 98 |
return f"Successfully stored {len(all_docs)} resume chunks"
|
| 99 |
|
| 100 |
def analyze_candidates(job_description: str) -> str:
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
skills_chain = LLMChain(
|
| 113 |
llm=llm,
|
| 114 |
prompt=skills_prompt
|
| 115 |
)
|
| 116 |
|
| 117 |
-
skills = skills_chain.run(job_description
|
| 118 |
|
| 119 |
# Query vector store for matching resumes
|
| 120 |
results = vector_store.similarity_search(
|
|
@@ -130,43 +131,47 @@ def analyze_candidates(job_description: str) -> str:
|
|
| 130 |
collection_name="culture_docs"
|
| 131 |
)
|
| 132 |
|
| 133 |
-
# Analysis prompt
|
| 134 |
-
analysis_prompt =
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
analysis_chain = LLMChain(
|
| 157 |
llm=llm,
|
| 158 |
prompt=analysis_prompt
|
| 159 |
)
|
| 160 |
|
| 161 |
-
analysis = analysis_chain.run(
|
| 162 |
-
job_description
|
| 163 |
-
skills
|
| 164 |
-
culture_docs
|
| 165 |
-
resumes
|
| 166 |
-
)
|
| 167 |
|
| 168 |
return analysis
|
| 169 |
|
|
|
|
| 170 |
def create_interface():
|
| 171 |
with gr.Blocks() as app:
|
| 172 |
gr.Markdown("# AI Recruiter Assistant")
|
|
|
|
| 98 |
return f"Successfully stored {len(all_docs)} resume chunks"
|
| 99 |
|
| 100 |
def analyze_candidates(job_description: str) -> str:
|
| 101 |
+
# Extract skills prompt template
|
| 102 |
+
skills_prompt = PromptTemplate(
|
| 103 |
+
input_variables=["job_description"],
|
| 104 |
+
template="""
|
| 105 |
+
Extract the key technical skills and requirements from this job description:
|
| 106 |
+
|
| 107 |
+
{job_description}
|
| 108 |
+
|
| 109 |
+
Return the skills as a comma-separated list.
|
| 110 |
+
"""
|
| 111 |
+
)
|
| 112 |
|
| 113 |
skills_chain = LLMChain(
|
| 114 |
llm=llm,
|
| 115 |
prompt=skills_prompt
|
| 116 |
)
|
| 117 |
|
| 118 |
+
skills = skills_chain.run({"job_description": job_description})
|
| 119 |
|
| 120 |
# Query vector store for matching resumes
|
| 121 |
results = vector_store.similarity_search(
|
|
|
|
| 131 |
collection_name="culture_docs"
|
| 132 |
)
|
| 133 |
|
| 134 |
+
# Analysis prompt template
|
| 135 |
+
analysis_prompt = PromptTemplate(
|
| 136 |
+
input_variables=["job_description", "skills", "culture_docs", "resumes"],
|
| 137 |
+
template="""
|
| 138 |
+
Analyze these candidates for the job position and culture fit.
|
| 139 |
+
|
| 140 |
+
Job Description:
|
| 141 |
+
{job_description}
|
| 142 |
+
|
| 143 |
+
Required Skills:
|
| 144 |
+
{skills}
|
| 145 |
+
|
| 146 |
+
Company Culture Context:
|
| 147 |
+
{culture_docs}
|
| 148 |
+
|
| 149 |
+
Candidate Resumes:
|
| 150 |
+
{resumes}
|
| 151 |
+
|
| 152 |
+
For each candidate, provide:
|
| 153 |
+
1. Skills match (percentage)
|
| 154 |
+
2. Culture fit assessment
|
| 155 |
+
3. Recommendation (move forward/reject)
|
| 156 |
+
4. Brief explanation
|
| 157 |
+
"""
|
| 158 |
+
)
|
| 159 |
|
| 160 |
analysis_chain = LLMChain(
|
| 161 |
llm=llm,
|
| 162 |
prompt=analysis_prompt
|
| 163 |
)
|
| 164 |
|
| 165 |
+
analysis = analysis_chain.run({
|
| 166 |
+
"job_description": job_description,
|
| 167 |
+
"skills": skills,
|
| 168 |
+
"culture_docs": "\n".join([doc.page_content for doc in culture_docs]),
|
| 169 |
+
"resumes": "\n".join([doc.page_content for doc in results])
|
| 170 |
+
})
|
| 171 |
|
| 172 |
return analysis
|
| 173 |
|
| 174 |
+
|
| 175 |
def create_interface():
|
| 176 |
with gr.Blocks() as app:
|
| 177 |
gr.Markdown("# AI Recruiter Assistant")
|