mbosse99 commited on
Commit
460cde1
·
1 Parent(s): a9c918b

initial commit

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