Spaces:
Runtime error
Runtime error
Caitlin Blackmore commited on
Commit ·
c8742c4
1
Parent(s): 7a72283
package version bug fix
Browse files- main.py +14 -15
- match_utils.py +10 -17
- requirements.txt +2 -5
main.py
CHANGED
|
@@ -12,7 +12,6 @@ from fastapi.templating import Jinja2Templates
|
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
from fastapi.responses import HTMLResponse
|
| 14 |
import pandas as pd
|
| 15 |
-
import time
|
| 16 |
from uuid import uuid1
|
| 17 |
from mangum import Mangum
|
| 18 |
from localStoragePy import localStoragePy
|
|
@@ -171,24 +170,24 @@ async def post_matches(request: Request, bt: BackgroundTasks, resume: UploadFile
|
|
| 171 |
|
| 172 |
username = localStorage.getItem('username')
|
| 173 |
|
| 174 |
-
def add_data_to_db(
|
| 175 |
db = pd.read_csv('static/res_embeddings.csv')
|
| 176 |
-
embeds = format(skillEmbed(
|
| 177 |
db.iloc[db['username']== username,5:] = embeds
|
| 178 |
db.to_csv('static/res_embeddings.csv', index=False)
|
| 179 |
|
| 180 |
-
def get_jobs_from_db(
|
| 181 |
-
job_matches = sim_result_loop_jobFinder(
|
| 182 |
print(job_matches)
|
| 183 |
|
| 184 |
resume = get_resume(resume)
|
| 185 |
skills = skill_extractor(resume)
|
| 186 |
-
simResults = await sim_result_loop(
|
| 187 |
links = get_links(simResults[0])
|
| 188 |
|
| 189 |
if username is not None:
|
| 190 |
-
bt.add_task(add_data_to_db,
|
| 191 |
-
bt.add_task(get_jobs_from_db,
|
| 192 |
|
| 193 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links, 'statelist': statelist})
|
| 194 |
|
|
@@ -212,24 +211,24 @@ async def post_matches(request: Request, bt: BackgroundTasks, jobdesc: UploadFil
|
|
| 212 |
|
| 213 |
username = localStorage.getItem('username')
|
| 214 |
|
| 215 |
-
def add_data_to_db(
|
| 216 |
db = pd.read_csv('static/jd_embeddings.csv')
|
| 217 |
-
embeds = format(skillEmbed(
|
| 218 |
db.iloc[db['username']== username,5:] = embeds
|
| 219 |
db.to_csv('static/jd_embeddings.csv', index=False)
|
| 220 |
|
| 221 |
-
def get_cand_from_db(
|
| 222 |
-
cand_matches = sim_result_loop_candFinder(
|
| 223 |
print(cand_matches)
|
| 224 |
|
| 225 |
jobdesc = get_resume(jobdesc)
|
| 226 |
skills = skill_extractor(jobdesc)
|
| 227 |
-
simResults = await sim_result_loop(
|
| 228 |
links = get_links(simResults[0])
|
| 229 |
|
| 230 |
if username is not None:
|
| 231 |
-
bt.add_task(add_data_to_db,
|
| 232 |
-
bt.add_task(get_cand_from_db,
|
| 233 |
|
| 234 |
return templates.TemplateResponse('candidate_matcher.html', context={'request': request, 'jobdesc': jobdesc, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
| 235 |
|
|
|
|
| 12 |
from fastapi.staticfiles import StaticFiles
|
| 13 |
from fastapi.responses import HTMLResponse
|
| 14 |
import pandas as pd
|
|
|
|
| 15 |
from uuid import uuid1
|
| 16 |
from mangum import Mangum
|
| 17 |
from localStoragePy import localStoragePy
|
|
|
|
| 170 |
|
| 171 |
username = localStorage.getItem('username')
|
| 172 |
|
| 173 |
+
def add_data_to_db(resume):
|
| 174 |
db = pd.read_csv('static/res_embeddings.csv')
|
| 175 |
+
embeds = format(skillEmbed(resume)).replace('[[','').replace(']]','').replace('[','').replace(']','').split(',')
|
| 176 |
db.iloc[db['username']== username,5:] = embeds
|
| 177 |
db.to_csv('static/res_embeddings.csv', index=False)
|
| 178 |
|
| 179 |
+
def get_jobs_from_db(resume):
|
| 180 |
+
job_matches = sim_result_loop_jobFinder(resume)
|
| 181 |
print(job_matches)
|
| 182 |
|
| 183 |
resume = get_resume(resume)
|
| 184 |
skills = skill_extractor(resume)
|
| 185 |
+
simResults = await sim_result_loop(resume)
|
| 186 |
links = get_links(simResults[0])
|
| 187 |
|
| 188 |
if username is not None:
|
| 189 |
+
bt.add_task(add_data_to_db, resume)
|
| 190 |
+
bt.add_task(get_jobs_from_db, resume)
|
| 191 |
|
| 192 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults[0], 'links': links, 'statelist': statelist})
|
| 193 |
|
|
|
|
| 211 |
|
| 212 |
username = localStorage.getItem('username')
|
| 213 |
|
| 214 |
+
def add_data_to_db(jobdesc):
|
| 215 |
db = pd.read_csv('static/jd_embeddings.csv')
|
| 216 |
+
embeds = format(skillEmbed(jobdesc)).replace('[[','').replace(']]','').split(',')
|
| 217 |
db.iloc[db['username']== username,5:] = embeds
|
| 218 |
db.to_csv('static/jd_embeddings.csv', index=False)
|
| 219 |
|
| 220 |
+
def get_cand_from_db(jobdesc):
|
| 221 |
+
cand_matches = sim_result_loop_candFinder(jobdesc)
|
| 222 |
print(cand_matches)
|
| 223 |
|
| 224 |
jobdesc = get_resume(jobdesc)
|
| 225 |
skills = skill_extractor(jobdesc)
|
| 226 |
+
simResults = await sim_result_loop(jobdesc)
|
| 227 |
links = get_links(simResults[0])
|
| 228 |
|
| 229 |
if username is not None:
|
| 230 |
+
bt.add_task(add_data_to_db, jobdesc)
|
| 231 |
+
bt.add_task(get_cand_from_db, jobdesc)
|
| 232 |
|
| 233 |
return templates.TemplateResponse('candidate_matcher.html', context={'request': request, 'jobdesc': jobdesc, 'skills': skills, 'simResults': simResults[0], 'links': links})
|
| 234 |
|
match_utils.py
CHANGED
|
@@ -24,8 +24,8 @@ simdat = pd.read_csv('static/embeddings/cohere_embeddings.csv')
|
|
| 24 |
coheredat = pd.read_csv('static/cohere_tSNE_dat.csv')
|
| 25 |
|
| 26 |
# LOAD LLM MODELS:
|
| 27 |
-
model = Ollama(model="mistral")
|
| 28 |
-
embedding_model = OllamaEmbeddings(model="mistral")
|
| 29 |
parser = CommaSeparatedListOutputParser()
|
| 30 |
|
| 31 |
# UTILITY FUNCTIONS
|
|
@@ -81,20 +81,13 @@ def skill_extractor(resume):
|
|
| 81 |
return parser.parse(result)
|
| 82 |
|
| 83 |
|
| 84 |
-
def skillEmbed(
|
| 85 |
-
embeddings = embedding_model.embed_query(
|
| 86 |
return embeddings
|
| 87 |
|
| 88 |
|
| 89 |
-
async def sim_result_loop(
|
| 90 |
-
|
| 91 |
-
skills = skilltext
|
| 92 |
-
if type(skilltext) == dict:
|
| 93 |
-
skills = [key for key, value in skilltext.items() if value == "Skill"]
|
| 94 |
-
skills = str(skills).replace("'", "").replace(",", "")
|
| 95 |
-
if type(skilltext) == list:
|
| 96 |
-
skills = ', '.join(skilltext)
|
| 97 |
-
embeds = skillEmbed(skills)
|
| 98 |
def cosine(A, B):
|
| 99 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 100 |
def format_sim(sim):
|
|
@@ -125,8 +118,8 @@ def get_links(simResults):
|
|
| 125 |
return links
|
| 126 |
|
| 127 |
|
| 128 |
-
def sim_result_loop_jobFinder(
|
| 129 |
-
embeds = skillEmbed(
|
| 130 |
def cosine(A, B):
|
| 131 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 132 |
def format_sim(sim):
|
|
@@ -147,8 +140,8 @@ def sim_result_loop_jobFinder(skills):
|
|
| 147 |
return simResults
|
| 148 |
|
| 149 |
|
| 150 |
-
def sim_result_loop_candFinder(
|
| 151 |
-
embeds = skillEmbed(
|
| 152 |
def cosine(A, B):
|
| 153 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 154 |
def format_sim(sim):
|
|
|
|
| 24 |
coheredat = pd.read_csv('static/cohere_tSNE_dat.csv')
|
| 25 |
|
| 26 |
# LOAD LLM MODELS:
|
| 27 |
+
model = Ollama(model="mistral", temperature=0)
|
| 28 |
+
embedding_model = OllamaEmbeddings(model="mistral", temperature=0)
|
| 29 |
parser = CommaSeparatedListOutputParser()
|
| 30 |
|
| 31 |
# UTILITY FUNCTIONS
|
|
|
|
| 81 |
return parser.parse(result)
|
| 82 |
|
| 83 |
|
| 84 |
+
def skillEmbed(resume):
|
| 85 |
+
embeddings = embedding_model.embed_query(resume)
|
| 86 |
return embeddings
|
| 87 |
|
| 88 |
|
| 89 |
+
async def sim_result_loop(resume):
|
| 90 |
+
embeds = skillEmbed(resume)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def cosine(A, B):
|
| 92 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 93 |
def format_sim(sim):
|
|
|
|
| 118 |
return links
|
| 119 |
|
| 120 |
|
| 121 |
+
def sim_result_loop_jobFinder(jobdesc):
|
| 122 |
+
embeds = skillEmbed(jobdesc)
|
| 123 |
def cosine(A, B):
|
| 124 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 125 |
def format_sim(sim):
|
|
|
|
| 140 |
return simResults
|
| 141 |
|
| 142 |
|
| 143 |
+
def sim_result_loop_candFinder(resume):
|
| 144 |
+
embeds = skillEmbed(resume)
|
| 145 |
def cosine(A, B):
|
| 146 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 147 |
def format_sim(sim):
|
requirements.txt
CHANGED
|
@@ -11,16 +11,13 @@ python-docx==0.8.11
|
|
| 11 |
aiofiles==22.1.0
|
| 12 |
nltk==3.8.1
|
| 13 |
unidecode==1.3.6
|
| 14 |
-
|
| 15 |
-
python-dotenv==0.21.1
|
| 16 |
-
transformers==4.25.1
|
| 17 |
torch==1.13.1
|
| 18 |
-
accelerate==0.
|
| 19 |
plotly-express==0.4.1
|
| 20 |
bcrypt==4.0.1
|
| 21 |
passlib==1.7.4
|
| 22 |
localStoragePy==0.2.3
|
| 23 |
-
sentence-transformers==2.2.2
|
| 24 |
mangum==0.17.0
|
| 25 |
certifi==2023.7.22
|
| 26 |
langchain==0.1.4
|
|
|
|
| 11 |
aiofiles==22.1.0
|
| 12 |
nltk==3.8.1
|
| 13 |
unidecode==1.3.6
|
| 14 |
+
transformers==4.37.2
|
|
|
|
|
|
|
| 15 |
torch==1.13.1
|
| 16 |
+
accelerate==0.26.1
|
| 17 |
plotly-express==0.4.1
|
| 18 |
bcrypt==4.0.1
|
| 19 |
passlib==1.7.4
|
| 20 |
localStoragePy==0.2.3
|
|
|
|
| 21 |
mangum==0.17.0
|
| 22 |
certifi==2023.7.22
|
| 23 |
langchain==0.1.4
|