Spaces:
Sleeping
Sleeping
Update with reranking
Browse files
app.py
CHANGED
@@ -232,7 +232,7 @@ def generate_candidate_mail(candidate, chat_link)-> str:
|
|
232 |
time.sleep(1)
|
233 |
|
234 |
output_string = f"""{res.choices[0]["message"]["content"]}
|
235 |
-
|
236 |
We have added the job description to the mail attachment.
|
237 |
If you are interested in the position, please click on the following link, answer a few questions from our chatbot for about 10-15 minutes and we will get back to you.
|
238 |
|
@@ -320,16 +320,31 @@ def load_candidates(fillup):
|
|
320 |
# print(filter_string)
|
321 |
if not fillup:
|
322 |
while len(checked_candidates) < target_candidates_count:
|
323 |
-
# Führe eine similarity search durch und erhalte 100 Kandidaten
|
324 |
-
if st.session_state["search_type"]:
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
else:
|
|
|
|
|
|
|
|
|
|
|
329 |
print("similarity")
|
330 |
# raw_candidates = st.session_state["db"].similarity_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
331 |
raw_candidates = st.session_state["db"].similarity_search_with_relevance_scores(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
for candidate in raw_candidates[current_offset:]:
|
334 |
candidates_id = candidate[0].metadata["source"].split("/")[-1]
|
335 |
keyword_bool = check_keywords_in_content(db_path, table_name, candidates_id, text_area_params.split(','))
|
@@ -358,14 +373,21 @@ def load_candidates(fillup):
|
|
358 |
# Solange die Anzahl der überprüften Kandidaten kleiner als die Zielanzahl ist
|
359 |
while len(st.session_state["docs_res"]) < target_candidates_count:
|
360 |
# Führe eine similarity search durch und erhalte 100 Kandidaten
|
361 |
-
if st.session_state["
|
362 |
-
print("hybrid")
|
363 |
-
# raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
364 |
-
raw_candidates = st.session_state["db"].hybrid_search_with_score(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
365 |
-
else:
|
366 |
print("similarity")
|
367 |
# raw_candidates = st.session_state["db"].similarity_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
368 |
raw_candidates = st.session_state["db"].similarity_search_with_relevance_scores(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
temp_offset_add = 0
|
370 |
for candidate in raw_candidates[current_offset:]:
|
371 |
candidates_id = candidate[0].metadata["source"].split("/")[-1]
|
@@ -471,8 +493,10 @@ if st.session_state["job"]:
|
|
471 |
st.session_state["job_string"] = st.session_state["optimized_job_edited"]
|
472 |
st.rerun()
|
473 |
|
474 |
-
st.write("Switch from a similarity search (default) to a hybrid search (activated)")
|
475 |
-
st.toggle("Switch Search", key="search_type")
|
|
|
|
|
476 |
|
477 |
st.write("Activate the following toggles to filter according to the respective properties:")
|
478 |
col_screening, col_handoff, col_placed = st.columns([1,1,1])
|
@@ -515,7 +539,7 @@ if (st.session_state["job_string"] and submit) or st.session_state["docs_res"]:
|
|
515 |
st.rerun()
|
516 |
with cols_final[0]:
|
517 |
# st.subheader(doc.metadata["source"])
|
518 |
-
with st.expander(doc[0].metadata["name"]+" with a search score of: "+str(round(doc[1] * 100, 3))+"%"):
|
519 |
st.write(doc[0].page_content)
|
520 |
if len(st.session_state["docs_res"])>=10:
|
521 |
if st.button("Accept candidates", key="accept_candidates_btn"):
|
@@ -699,7 +723,7 @@ Your Candidate-Search-Tool
|
|
699 |
try:
|
700 |
bullets = generate_job_bullets(st.session_state["job_string"])
|
701 |
client = Client(os.getenv("TWILIO_SID"), os.getenv("TWILIO_API"))
|
702 |
-
message_body = f"Dear candidate,\n\nare you interested in the following position: \n
|
703 |
message = client.messages.create(
|
704 |
to=st.session_state["recruiter_phone"],
|
705 |
from_="+1 857 214 8753",
|
|
|
232 |
time.sleep(1)
|
233 |
|
234 |
output_string = f"""{res.choices[0]["message"]["content"]}
|
235 |
+
|
236 |
We have added the job description to the mail attachment.
|
237 |
If you are interested in the position, please click on the following link, answer a few questions from our chatbot for about 10-15 minutes and we will get back to you.
|
238 |
|
|
|
320 |
# print(filter_string)
|
321 |
if not fillup:
|
322 |
while len(checked_candidates) < target_candidates_count:
|
323 |
+
# # Führe eine similarity search durch und erhalte 100 Kandidaten
|
324 |
+
# if st.session_state["search_type"]:
|
325 |
+
# print("hybrid")
|
326 |
+
# # raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
327 |
+
# raw_candidates = st.session_state["db"].hybrid_search_with_score(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
328 |
+
# else:
|
329 |
+
# print("similarity")
|
330 |
+
# # raw_candidates = st.session_state["db"].similarity_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
331 |
+
# raw_candidates = st.session_state["db"].similarity_search_with_relevance_scores(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
332 |
+
#"Similarity", "Hybrid", "Semantic ranking"
|
333 |
+
if st.session_state["search_radio"] == "Similarity":
|
334 |
print("similarity")
|
335 |
# raw_candidates = st.session_state["db"].similarity_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
336 |
raw_candidates = st.session_state["db"].similarity_search_with_relevance_scores(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
337 |
+
elif st.session_state["search_radio"] == "Hybrid":
|
338 |
+
print("hybrid")
|
339 |
+
# raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
340 |
+
raw_candidates = st.session_state["db"].hybrid_search_with_score(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
341 |
+
elif st.session_state["search_radio"] == "Semantic ranking":
|
342 |
+
print("Semantic ranking")
|
343 |
+
print("Filter string"+filter_string)
|
344 |
+
print("query"+query_string)
|
345 |
+
print("offset: "+str(candidates_per_search+current_offset))
|
346 |
+
# raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
347 |
+
raw_candidates = st.session_state["db"].semantic_hybrid_search_with_score_and_rerank(query_string, k=50, filters=filter_string)
|
348 |
for candidate in raw_candidates[current_offset:]:
|
349 |
candidates_id = candidate[0].metadata["source"].split("/")[-1]
|
350 |
keyword_bool = check_keywords_in_content(db_path, table_name, candidates_id, text_area_params.split(','))
|
|
|
373 |
# Solange die Anzahl der überprüften Kandidaten kleiner als die Zielanzahl ist
|
374 |
while len(st.session_state["docs_res"]) < target_candidates_count:
|
375 |
# Führe eine similarity search durch und erhalte 100 Kandidaten
|
376 |
+
if st.session_state["search_radio"] == "Similarity":
|
|
|
|
|
|
|
|
|
377 |
print("similarity")
|
378 |
# raw_candidates = st.session_state["db"].similarity_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
379 |
raw_candidates = st.session_state["db"].similarity_search_with_relevance_scores(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
380 |
+
elif st.session_state["search_radio"] == "Hybrid":
|
381 |
+
print("hybrid")
|
382 |
+
# raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
383 |
+
raw_candidates = st.session_state["db"].hybrid_search_with_score(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
384 |
+
elif st.session_state["search_radio"] == "Semantic ranking":
|
385 |
+
print("Semantic ranking")
|
386 |
+
print("Filter string"+filter_string)
|
387 |
+
print("query"+query_string)
|
388 |
+
print("offset: "+str(candidates_per_search+current_offset))
|
389 |
+
# raw_candidates = st.session_state["db"].hybrid_search(query_string, k=candidates_per_search+current_offset, filters=filter_string)
|
390 |
+
raw_candidates = st.session_state["db"].semantic_hybrid_search_with_score_and_rerank(query_string, k=50, filters=filter_string)
|
391 |
temp_offset_add = 0
|
392 |
for candidate in raw_candidates[current_offset:]:
|
393 |
candidates_id = candidate[0].metadata["source"].split("/")[-1]
|
|
|
493 |
st.session_state["job_string"] = st.session_state["optimized_job_edited"]
|
494 |
st.rerun()
|
495 |
|
496 |
+
# st.write("Switch from a similarity search (default) to a hybrid search (activated)")
|
497 |
+
# st.toggle("Switch Search", key="search_type")
|
498 |
+
|
499 |
+
st.radio("Select a search variant",options=["Similarity", "Hybrid", "Semantic ranking"], key="search_radio")
|
500 |
|
501 |
st.write("Activate the following toggles to filter according to the respective properties:")
|
502 |
col_screening, col_handoff, col_placed = st.columns([1,1,1])
|
|
|
539 |
st.rerun()
|
540 |
with cols_final[0]:
|
541 |
# st.subheader(doc.metadata["source"])
|
542 |
+
with st.expander(doc[0].metadata["name"]+" with a search score of: "+str(round(doc[1] * 100, 3))+ ("%"if st.session_state["search_radio"] == "Similarity" else "")):
|
543 |
st.write(doc[0].page_content)
|
544 |
if len(st.session_state["docs_res"])>=10:
|
545 |
if st.button("Accept candidates", key="accept_candidates_btn"):
|
|
|
723 |
try:
|
724 |
bullets = generate_job_bullets(st.session_state["job_string"])
|
725 |
client = Client(os.getenv("TWILIO_SID"), os.getenv("TWILIO_API"))
|
726 |
+
message_body = f"Dear candidate,\n\nare you interested in the following position: \n"+st.session_state["job_title"]+"\n\n"+bullets+"\n\nThen please answer with 'yes'\n\nSincerely,\n"+"WorkGenius"
|
727 |
message = client.messages.create(
|
728 |
to=st.session_state["recruiter_phone"],
|
729 |
from_="+1 857 214 8753",
|