Spaces:
Sleeping
Sleeping
File size: 5,245 Bytes
abd17e2 |
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 |
import requests
import json
import os
import streamlit as st
from datetime import datetime, timedelta
from ParamClasses import CreateParams
from dotenv import load_dotenv
load_dotenv()
def create_meeting(input_params: CreateParams) -> dict:
try:
url = f"{os.environ.get('BASE_API')}/api/create-appointment"
response = requests.post(url=url,data=input_params)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fehler beim erstellen des Termins: {str(e)}")
st.error("Something went wrong, please contact the site admin.", icon="🚨")
def get_summary(input_params) -> dict:
try:
url = f"{os.environ.get('BASE_API')}/api/create-interview-summary"
response = requests.post(url=url,data=input_params)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Fehler beim erstellen des Termins: {str(e)}")
st.error(f"Something went wrong: {str(e)}", icon="🚨")
if "appointment_response" not in st.session_state:
st.session_state["appointment_response"] = None
if "subject_input" not in st.session_state:
st.session_state["subject_input"] = None
col1, col2 = st.columns([2, 1])
col1.title("Appointment Tool")
col2.image("https://www.workgenius.com/wp-content/uploads/2023/03/WorkGenius_navy-1.svg")
st.write("Please enter the date, time and duration for the appointment to be created.")
selected_date = st.date_input("Date of the appointment",format="DD/MM/YYYY")
now = datetime.now()
rounded_now = now + timedelta(minutes=30 - now.minute % 30)
selected_time = st.time_input("Starting time of the appointment", value=rounded_now)
selected_duration = st.select_slider("Duration of the appointment in minutes",[15,30,45,60],value=30)
subject_input = st.text_input("Enter the subject of the meeting")
recruiter_mail = st.text_input("Please enter the mail of the recruiter", key="recruiter_mail")
client_mail = st.text_input("Please enter the mail of the client", key="client_mail")
candidate_mail = st.text_input("Please enter the mail of the candidate", key="candidate_mail")
if not st.session_state["appointment_response"]:
if st.button("Create appointment") or st.session_state["appointment_response"]:
print("nach button appointment")
if subject_input:
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")
end_date = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S") + timedelta(minutes=selected_duration)
end_date_str = end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
with st.spinner("Creating the appointment..."):
request_params = json.dumps({
"appointment": {
"start_time": start_date_str,
"end_time": end_date_str
},
"subject": subject_input,
"recruiter": {
"email": st.session_state["recruiter_mail"],
"name": st.session_state["recruiter_mail"]
},
"client": {
"email": st.session_state["client_mail"],
"name": st.session_state["client_mail"]
},
"candidate": {
"email": st.session_state["candidate_mail"],
"name": st.session_state["candidate_mail"]
}
})
appointment_response = create_meeting(request_params)
# st.write(appointment_response)
if appointment_response:
st.success("The appointment was created correctly.")
st.write(appointment_response["calendar_event"]["onlineMeeting"]["joinUrl"])
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="ℹ️")
st.session_state["appointment_response"] = appointment_response
st.session_state["subject_input"] = subject_input
if st.button("Create Interview Summary"):
print("please")
st.rerun()
# print("nach btn summary")
# with st.spinner("Creating the summary..."):
# summary_response = get_summary({"interview_subject": subject_input})
# if summary_response:
# st.write(summary_response)
else:
st.warning("Please enter the subject of the meeting")
else:
with st.spinner("Creating the summary..."):
print(st.session_state["subject_input"])
print(isinstance(st.session_state["subject_input"],str))
print("bis hierhin gekommen")
summary_response = get_summary(json.dumps({"join_url": st.session_state["appointment_response"]["calendar_event"]["onlineMeeting"]["joinUrl"]}))
st.write(summary_response) |