Spaces:
Sleeping
Sleeping
init commit
Browse files- ParamClasses.py +63 -0
- app.py +106 -0
- requirements.txt +3 -0
ParamClasses.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel, validator
|
2 |
+
from datetime import datetime, timezone
|
3 |
+
|
4 |
+
|
5 |
+
# ------------------------------------------------------------------------------
|
6 |
+
class Attendee(BaseModel, extra="forbid"):
|
7 |
+
email: str
|
8 |
+
name: str
|
9 |
+
|
10 |
+
|
11 |
+
# ------------------------------------------------------------------------------
|
12 |
+
class Appointment(BaseModel, extra="forbid"):
|
13 |
+
start_time: datetime
|
14 |
+
end_time: datetime
|
15 |
+
|
16 |
+
# To compare two Appointment objects
|
17 |
+
def __hash__(self):
|
18 |
+
return hash((self.start_time, self.end_time))
|
19 |
+
|
20 |
+
|
21 |
+
# ------------------------------------------------------------------------------
|
22 |
+
class CreateParams(BaseModel, extra="forbid"):
|
23 |
+
appointment: Appointment
|
24 |
+
subject: str
|
25 |
+
recruiter: Attendee
|
26 |
+
client: Attendee
|
27 |
+
candidate: Attendee
|
28 |
+
|
29 |
+
|
30 |
+
# ------------------------------------------------------------------------------
|
31 |
+
class SendClientParams(BaseModel, extra="forbid"):
|
32 |
+
client_email: str
|
33 |
+
candidate_name: str
|
34 |
+
job_title: str
|
35 |
+
|
36 |
+
|
37 |
+
# ------------------------------------------------------------------------------
|
38 |
+
class SendCandidateParams(BaseModel, extra="forbid"):
|
39 |
+
appointment_suggestions: list[Appointment]
|
40 |
+
candidate_email: str
|
41 |
+
job_title: str
|
42 |
+
|
43 |
+
@validator("appointment_suggestions")
|
44 |
+
def check_length(cls, appointment_list):
|
45 |
+
if len(appointment_list) < 3:
|
46 |
+
raise ValueError(
|
47 |
+
"appointment_suggestions must contain at least 3 items"
|
48 |
+
)
|
49 |
+
|
50 |
+
if len(appointment_list) != len(set(appointment_list)):
|
51 |
+
raise ValueError("All suggestions must be unique.")
|
52 |
+
|
53 |
+
current_datetime = datetime.now(timezone.utc)
|
54 |
+
if not all(
|
55 |
+
appointment.start_time > current_datetime
|
56 |
+
and appointment.end_time > current_datetime
|
57 |
+
for appointment in appointment_list
|
58 |
+
):
|
59 |
+
raise ValueError(
|
60 |
+
"All suggestions must refer to appointments in the future."
|
61 |
+
)
|
62 |
+
|
63 |
+
return list
|
app.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
import os
|
4 |
+
import streamlit as st
|
5 |
+
from datetime import datetime, timedelta
|
6 |
+
from ParamClasses import CreateParams
|
7 |
+
from dotenv import load_dotenv
|
8 |
+
|
9 |
+
load_dotenv()
|
10 |
+
|
11 |
+
def create_meeting(input_params: CreateParams) -> dict:
|
12 |
+
try:
|
13 |
+
url = f"{os.environ.get('BASE_API')}/api/create-appointment"
|
14 |
+
response = requests.post(url=url,data=input_params)
|
15 |
+
response.raise_for_status()
|
16 |
+
return response.json()
|
17 |
+
except Exception as e:
|
18 |
+
print(f"Fehler beim erstellen des Termins: {str(e)}")
|
19 |
+
st.error("Something went wrong, please contact the site admin.", icon="🚨")
|
20 |
+
|
21 |
+
def get_summary(input_params) -> dict:
|
22 |
+
try:
|
23 |
+
url = f"{os.environ.get('BASE_API')}/api/create-interview-summary"
|
24 |
+
response = requests.post(url=url,data=input_params)
|
25 |
+
response.raise_for_status()
|
26 |
+
return response.json()
|
27 |
+
except Exception as e:
|
28 |
+
print(f"Fehler beim erstellen des Termins: {str(e)}")
|
29 |
+
st.error(f"Something went wrong: {str(e)}", icon="🚨")
|
30 |
+
|
31 |
+
if "appointment_response" not in st.session_state:
|
32 |
+
st.session_state["appointment_response"] = None
|
33 |
+
if "subject_input" not in st.session_state:
|
34 |
+
st.session_state["subject_input"] = None
|
35 |
+
|
36 |
+
col1, col2 = st.columns([2, 1])
|
37 |
+
|
38 |
+
col1.title("Appointment Tool")
|
39 |
+
col2.image("https://www.workgenius.com/wp-content/uploads/2023/03/WorkGenius_navy-1.svg")
|
40 |
+
|
41 |
+
st.write("Please enter the date, time and duration for the appointment to be created.")
|
42 |
+
|
43 |
+
selected_date = st.date_input("Date of the appointment",format="DD/MM/YYYY")
|
44 |
+
now = datetime.now()
|
45 |
+
rounded_now = now + timedelta(minutes=30 - now.minute % 30)
|
46 |
+
selected_time = st.time_input("Starting time of the appointment", value=rounded_now)
|
47 |
+
selected_duration = st.select_slider("Duration of the appointment in minutes",[15,30,45,60],value=30)
|
48 |
+
subject_input = st.text_input("Enter the subject of the meeting")
|
49 |
+
recruiter_mail = st.text_input("Please enter the mail of the recruiter", key="recruiter_mail")
|
50 |
+
client_mail = st.text_input("Please enter the mail of the client", key="client_mail")
|
51 |
+
candidate_mail = st.text_input("Please enter the mail of the candidate", key="candidate_mail")
|
52 |
+
|
53 |
+
if not st.session_state["appointment_response"]:
|
54 |
+
if st.button("Create appointment") or st.session_state["appointment_response"]:
|
55 |
+
print("nach button appointment")
|
56 |
+
if subject_input:
|
57 |
+
start_date_str = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S.%fZ")
|
58 |
+
end_date = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S") + timedelta(minutes=selected_duration)
|
59 |
+
end_date_str = end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
|
60 |
+
with st.spinner("Creating the appointment..."):
|
61 |
+
request_params = json.dumps({
|
62 |
+
"appointment": {
|
63 |
+
"start_time": start_date_str,
|
64 |
+
"end_time": end_date_str
|
65 |
+
},
|
66 |
+
"subject": subject_input,
|
67 |
+
"recruiter": {
|
68 |
+
"email": st.session_state["recruiter_mail"],
|
69 |
+
"name": st.session_state["recruiter_mail"]
|
70 |
+
},
|
71 |
+
"client": {
|
72 |
+
"email": st.session_state["client_mail"],
|
73 |
+
"name": st.session_state["client_mail"]
|
74 |
+
},
|
75 |
+
"candidate": {
|
76 |
+
"email": st.session_state["candidate_mail"],
|
77 |
+
"name": st.session_state["candidate_mail"]
|
78 |
+
}
|
79 |
+
})
|
80 |
+
appointment_response = create_meeting(request_params)
|
81 |
+
# st.write(appointment_response)
|
82 |
+
if appointment_response:
|
83 |
+
|
84 |
+
st.success("The appointment was created correctly.")
|
85 |
+
st.write(appointment_response["calendar_event"]["onlineMeeting"]["joinUrl"])
|
86 |
+
st.info("Once you have attended the meeting and it has ended, please wait about 5 minutes before requesting the meeting recording as it will take time to become available ", icon="ℹ️")
|
87 |
+
st.session_state["appointment_response"] = appointment_response
|
88 |
+
st.session_state["subject_input"] = subject_input
|
89 |
+
if st.button("Create Interview Summary"):
|
90 |
+
print("please")
|
91 |
+
st.rerun()
|
92 |
+
# print("nach btn summary")
|
93 |
+
# with st.spinner("Creating the summary..."):
|
94 |
+
# summary_response = get_summary({"interview_subject": subject_input})
|
95 |
+
# if summary_response:
|
96 |
+
# st.write(summary_response)
|
97 |
+
|
98 |
+
else:
|
99 |
+
st.warning("Please enter the subject of the meeting")
|
100 |
+
else:
|
101 |
+
with st.spinner("Creating the summary..."):
|
102 |
+
print(st.session_state["subject_input"])
|
103 |
+
print(isinstance(st.session_state["subject_input"],str))
|
104 |
+
print("bis hierhin gekommen")
|
105 |
+
summary_response = get_summary(json.dumps({"join_url": st.session_state["appointment_response"]["calendar_event"]["onlineMeeting"]["joinUrl"]}))
|
106 |
+
st.write(summary_response)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
openai==0.28.1
|
2 |
+
streamlit
|
3 |
+
python-dotenv
|