Spaces:
Runtime error
Runtime error
File size: 5,454 Bytes
460cde1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
import streamlit as st
from azure.storage.blob import BlobServiceClient
from azure.cosmos import CosmosClient, exceptions
import os
st.set_page_config(layout="wide")
st.markdown(
"""
<style>
[data-testid=column]{
text-align: left;
display: flex;
align-items: center;
justify-content: center;
}
</style>
""",
unsafe_allow_html=True,
)
col1, col2 = st.columns([2, 1])
col1.title("Interview chatbot evaluations")
col2.image("https://www.workgenius.com/wp-content/uploads/2023/03/WorkGenius_navy-1.svg")
if "selected_item" not in st.session_state:
st.session_state["selected_item"] = None
if "top_number" not in st.session_state:
st.session_state["top_number"] = 10
endpoint = "https://wg-candidate-data.documents.azure.com:443/"
key = os.getenv("CONNECTION_DB")
client = CosmosClient(endpoint, key)
database = client.get_database_client("ToDoList")
container = database.get_container_client("JobData")
candidate_container = database.get_container_client("Items")
def get_candidates(id, candidate_container):
candidate_query = f"""
SELECT *
FROM c
WHERE c.job_description_id = '{id}'
"""
query_result = list(candidate_container.query_items(query=candidate_query, enable_cross_partition_query=True))
return query_result
def get_open_and_closed_candidates(id, nr_of_candidates, candidate_container):
candidate_query = f"""
SELECT *
FROM c
WHERE c.job_description_id = '{id}' AND c.interview_conducted = true
"""
query_result = list(candidate_container.query_items(query=candidate_query, enable_cross_partition_query=True))
return nr_of_candidates-len(query_result),len(query_result)
# endpoint = "https://wg-candidate-data.documents.azure.com:443/"
# key = os.getenv("CONNECTION_DB")
# client = CosmosClient(endpoint, key)
# database = client.get_database_client("ToDoList")
# container = database.get_container_client("JobData")
# candidate_container = database.get_container_client("Items")
if not st.session_state["selected_item"]:
txt_input_cols = st.columns(3)
with txt_input_cols[0]:
st.text_input("Search for job titles", key="title_search")
query = f"""
SELECT TOP {st.session_state["top_number"]} *
FROM c
WHERE CONTAINS(c.title, '{st.session_state["title_search"]}')
ORDER BY c.timestamp DESC
"""
items = list(container.query_items(query=query, enable_cross_partition_query=True))
with st.container():
col1, col2, col3, col4, col5 = st.columns([2,1,1,1,1])
col1.subheader("Job title")
col2.subheader("Applicants")
col3.subheader("Open")
col4.subheader("Completed")
col5.subheader("Overview")
for i, item in enumerate(items):
cols = st.columns([2,1,1,1,1])
open, closed = get_open_and_closed_candidates(item["id"], item["number_of_applicants"], candidate_container)
with st.container():
for j in range(5):
with cols[j]:
if(j == 0):
st.text(item["title"])
elif(j == 1):
st.text(item["number_of_applicants"])
elif(j == 2):
st.text(open)
elif(j == 3):
st.text(closed)
elif(j == 4):
if st.button("Go to overview",use_container_width=True,key="btn_row_"+str(i)):
st.session_state["selected_item"] = item
st.rerun()
if st.button("Load more"):
st.session_state["top_number"] = len(items)+10
st.rerun()
else:
job_detail_cols_title = st.columns([1,1,1])
with job_detail_cols_title[0]:
if st.button("Go back to list view"):
st.session_state["selected_item"] = None
st.session_state["top_number"] = 10
st.rerun()
with job_detail_cols_title[1]:
st.subheader("Job: " + st.session_state["selected_item"]["title"])
candidate_db_items = get_candidates(st.session_state["selected_item"]["id"], candidate_container)
job_detail_cols_content = st.columns([1,5,1])
with job_detail_cols_content[1]:
st.subheader("Recruiter Email: " + st.session_state["selected_item"]["evaluation_email"])
if len(st.session_state["selected_item"]["question_one"])>0:
st.subheader("First question: " + st.session_state["selected_item"]["question_one"])
if len(st.session_state["selected_item"]["question_two"])>0:
st.subheader("Second question: " + st.session_state["selected_item"]["question_two"])
if len(st.session_state["selected_item"]["question_three"])>0:
st.subheader("Thrid question: " + st.session_state["selected_item"]["question_three"])
for i, can_item in enumerate(candidate_db_items):
st.subheader("Candidate: "+can_item["name"])
if can_item["interview_conducted"]:
st.text("The candidate "+can_item["name"]+ " has already completed the interview and this is the AI summary:")
st.text(can_item["ai_summary"])
else:
st.text("The candidate "+can_item["name"]+ " has not yet completed the interview.")
st.text("Link for the interview chatbot:")
st.text("https://tensora.ai/workgenius/cv-evaluation2/?job="+can_item["id"]) |