Spaces:
Runtime error
Runtime error
start building out specific job-candidate match functionality
Browse files- main.py +10 -6
- match_utils.py +11 -2
- static/res_embeddings.csv +0 -0
main.py
CHANGED
@@ -143,8 +143,9 @@ def get_matches(request: Request):
|
|
143 |
@app.post('/find-my-match/', response_class=HTMLResponse)
|
144 |
async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile = File(...)):
|
145 |
|
|
|
|
|
146 |
def add_data_to_db(resume):
|
147 |
-
username = localStorage.getItem('username')
|
148 |
db = pd.read_csv('static/res_embeddings.csv')
|
149 |
embeds = format(coSkillEmbed(resume)).replace('[[','').replace(']]','').split(',')
|
150 |
db.iloc[db['username']== username,5:] = embeds
|
@@ -159,8 +160,9 @@ async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile
|
|
159 |
simResults = await sim_result_loop(resume)
|
160 |
links = get_links(simResults[0])
|
161 |
|
162 |
-
|
163 |
-
|
|
|
164 |
|
165 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
166 |
|
@@ -178,8 +180,9 @@ def get_hires(request: Request):
|
|
178 |
@app.post('/find-my-hire/', response_class=HTMLResponse)
|
179 |
async def post_matches(request: Request, bt: BackgroundTasks, jobdesc: UploadFile = File(...)):
|
180 |
|
|
|
|
|
181 |
def add_data_to_db(jobdesc):
|
182 |
-
username = localStorage.getItem('username')
|
183 |
db = pd.read_csv('static/jd_embeddings.csv')
|
184 |
embeds = format(coSkillEmbed(jobdesc)).replace('[[','').replace(']]','').split(',')
|
185 |
db.iloc[db['username']== username,5:] = embeds
|
@@ -194,8 +197,9 @@ async def post_matches(request: Request, bt: BackgroundTasks, jobdesc: UploadFil
|
|
194 |
simResults = await sim_result_loop(jobdesc)
|
195 |
links = get_links(simResults[0])
|
196 |
|
197 |
-
|
198 |
-
|
|
|
199 |
|
200 |
return templates.TemplateResponse('candidate_matcher.html', context={'request': request, 'jobdesc': jobdesc, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
201 |
|
|
|
143 |
@app.post('/find-my-match/', response_class=HTMLResponse)
|
144 |
async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile = File(...)):
|
145 |
|
146 |
+
username = localStorage.getItem('username')
|
147 |
+
|
148 |
def add_data_to_db(resume):
|
|
|
149 |
db = pd.read_csv('static/res_embeddings.csv')
|
150 |
embeds = format(coSkillEmbed(resume)).replace('[[','').replace(']]','').split(',')
|
151 |
db.iloc[db['username']== username,5:] = embeds
|
|
|
160 |
simResults = await sim_result_loop(resume)
|
161 |
links = get_links(simResults[0])
|
162 |
|
163 |
+
if username is not None:
|
164 |
+
bt.add_task(add_data_to_db, resume)
|
165 |
+
bt.add_task(get_jobs_from_db, resume)
|
166 |
|
167 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
168 |
|
|
|
180 |
@app.post('/find-my-hire/', response_class=HTMLResponse)
|
181 |
async def post_matches(request: Request, bt: BackgroundTasks, jobdesc: UploadFile = File(...)):
|
182 |
|
183 |
+
username = localStorage.getItem('username')
|
184 |
+
|
185 |
def add_data_to_db(jobdesc):
|
|
|
186 |
db = pd.read_csv('static/jd_embeddings.csv')
|
187 |
embeds = format(coSkillEmbed(jobdesc)).replace('[[','').replace(']]','').split(',')
|
188 |
db.iloc[db['username']== username,5:] = embeds
|
|
|
197 |
simResults = await sim_result_loop(jobdesc)
|
198 |
links = get_links(simResults[0])
|
199 |
|
200 |
+
if username is not None:
|
201 |
+
bt.add_task(add_data_to_db, jobdesc)
|
202 |
+
bt.add_task(get_cand_from_db, jobdesc)
|
203 |
|
204 |
return templates.TemplateResponse('candidate_matcher.html', context={'request': request, 'jobdesc': jobdesc, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
205 |
|
match_utils.py
CHANGED
@@ -73,8 +73,13 @@ def coSkillEmbed(text):
|
|
73 |
except CohereError as e:
|
74 |
return e
|
75 |
|
76 |
-
async def sim_result_loop(
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
78 |
def cosine(A, B):
|
79 |
return np.dot(A,B)/(norm(A)*norm(B))
|
80 |
def format_sim(sim):
|
@@ -89,6 +94,10 @@ async def sim_result_loop(resume):
|
|
89 |
simResults = simResults.iloc[:13,:]
|
90 |
simResults = simResults.iloc[1:,:]
|
91 |
simResults.reset_index(drop=True, inplace=True)
|
|
|
|
|
|
|
|
|
92 |
for x in range(len(simResults)):
|
93 |
simResults.iloc[x,1] = format_sim(simResults.iloc[x,1])
|
94 |
return simResults, embeds
|
|
|
73 |
except CohereError as e:
|
74 |
return e
|
75 |
|
76 |
+
async def sim_result_loop(skilltext):
|
77 |
+
if type(skilltext) == str:
|
78 |
+
skills = skilltext
|
79 |
+
if type(skilltext) == dict:
|
80 |
+
skills = [key for key, value in skilltext.items() if value == "Skill"]
|
81 |
+
skills = str(skills).replace("'", "").replace(",", "")
|
82 |
+
embeds = coSkillEmbed(skills)
|
83 |
def cosine(A, B):
|
84 |
return np.dot(A,B)/(norm(A)*norm(B))
|
85 |
def format_sim(sim):
|
|
|
94 |
simResults = simResults.iloc[:13,:]
|
95 |
simResults = simResults.iloc[1:,:]
|
96 |
simResults.reset_index(drop=True, inplace=True)
|
97 |
+
if simResults['Similarity'].min() < 0.5:
|
98 |
+
simResults['Similarity'] = simResults['Similarity'] + (0.5 - simResults['Similarity'].min())
|
99 |
+
if simResults['Similarity'].max() > 1.0:
|
100 |
+
simResults['Similarity'] = simResults['Similarity'] - (simResults['Similarity'].max() - 1.0)
|
101 |
for x in range(len(simResults)):
|
102 |
simResults.iloc[x,1] = format_sim(simResults.iloc[x,1])
|
103 |
return simResults, embeds
|
static/res_embeddings.csv
CHANGED
The diff for this file is too large to render.
See raw diff
|
|