mbosse99 commited on
Commit
de241f7
·
verified ·
1 Parent(s): e8dca67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +53 -5
app.py CHANGED
@@ -1,9 +1,11 @@
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()
@@ -19,6 +21,8 @@ def create_meeting(input_params: CreateParams) -> dict:
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)
@@ -55,10 +59,27 @@ def adjust_datetime(original_datetime_str, offset_option):
55
  adjusted_datetime_str = adjusted_datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
56
  return adjusted_datetime_str
57
 
 
 
 
 
 
 
 
 
 
58
  if "appointment_response" not in st.session_state:
59
  st.session_state["appointment_response"] = None
60
  if "subject_input" not in st.session_state:
61
  st.session_state["subject_input"] = None
 
 
 
 
 
 
 
 
62
 
63
  col1, col2 = st.columns([2, 1])
64
 
@@ -115,12 +136,39 @@ if not st.session_state["appointment_response"]:
115
  if appointment_response:
116
 
117
  st.success("The appointment was created correctly.")
118
- st.write(appointment_response["calendar_event"]["onlineMeeting"]["joinUrl"])
119
- 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="ℹ️")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  st.session_state["appointment_response"] = appointment_response
 
121
  st.session_state["subject_input"] = subject_input
122
  if st.button("Create Interview Summary"):
123
  print("please")
 
124
  st.rerun()
125
  # print("nach btn summary")
126
  # with st.spinner("Creating the summary..."):
@@ -135,5 +183,5 @@ else:
135
  print(st.session_state["subject_input"])
136
  print(isinstance(st.session_state["subject_input"],str))
137
  print("bis hierhin gekommen")
138
- summary_response = get_summary(json.dumps({"join_url": st.session_state["appointment_response"]["calendar_event"]["onlineMeeting"]["joinUrl"]}))
139
- st.write(summary_response)
 
1
  import requests
2
  import json
3
  import os
4
+ import uuid
5
  import streamlit as st
6
+ from azure.cosmos import CosmosClient
7
  from datetime import datetime, timedelta
8
+ from ParamClasses import CreateParams, AppointmentDBItem, Attendee
9
  from dotenv import load_dotenv
10
 
11
  load_dotenv()
 
21
  st.error("Something went wrong, please contact the site admin.", icon="🚨")
22
 
23
  def get_summary(input_params) -> dict:
24
+ print(input_params)
25
+ print("nach params print")
26
  try:
27
  url = f"{os.environ.get('BASE_API')}/api/create-interview-summary"
28
  response = requests.post(url=url,data=input_params)
 
59
  adjusted_datetime_str = adjusted_datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
60
  return adjusted_datetime_str
61
 
62
+ def write_appointment_db_object(interview_data: AppointmentDBItem):
63
+ print("hitesttest")
64
+ try:
65
+ st.session_state["cosmos_db"].create_item(body=interview_data.model_dump())
66
+ except Exception as e:
67
+ print(f"Fehler beim erstellen des DB items: {str(e)}")
68
+ st.error("Something went wrong, please contact the site admin.", icon="🚨")
69
+
70
+
71
  if "appointment_response" not in st.session_state:
72
  st.session_state["appointment_response"] = None
73
  if "subject_input" not in st.session_state:
74
  st.session_state["subject_input"] = None
75
+ if "cosmos_db" not in st.session_state:
76
+ # Cosmos DB Client erstellen
77
+ client = CosmosClient(os.environ.get('DB_CONNECTION'), os.environ.get('DB_KEY'))
78
+
79
+ # Datenbank und Container referenzieren
80
+ database = client.get_database_client(os.environ.get('DB_NAME'))
81
+ container = database.get_container_client(os.environ.get('DB_CONTAINER'))
82
+ st.session_state["cosmos_db"] = container
83
 
84
  col1, col2 = st.columns([2, 1])
85
 
 
136
  if appointment_response:
137
 
138
  st.success("The appointment was created correctly.")
139
+ st.write(appointment_response["zoom_meeting"]["start_url"])
140
+ db_item = AppointmentDBItem(
141
+ id=str(uuid.uuid4()),
142
+ job_title=subject_input,
143
+ start_time=start_date_str,
144
+ end_time=end_date_str,
145
+ meeting_url=appointment_response["zoom_meeting"]["start_url"],
146
+ environment=str(["us"]),
147
+ process_status="interview_scheduled",
148
+ recruiter=Attendee(
149
+ email=str(st.session_state["recruiter_mail"]),
150
+ name=str(st.session_state["recruiter_mail"])
151
+ ),
152
+ client=Attendee(
153
+ email=str(st.session_state["client_mail"]),
154
+ name=str(st.session_state["client_mail"])
155
+ ),
156
+ candidate=Attendee(
157
+ email=str(st.session_state["candidate_mail"]),
158
+ name=str(st.session_state["candidate_mail"])
159
+ ),
160
+ summary_recruiter="",
161
+ summary_client="",
162
+ summary_candidate=""
163
+ )
164
+ # write_appointment_db_object(db_item)
165
+ st.info("Once you have attended the meeting and it has ended, please wait about 10 minutes before requesting the meeting recording as it will take time to become available ", icon="ℹ️")
166
  st.session_state["appointment_response"] = appointment_response
167
+ print(appointment_response["zoom_meeting"]["id"])
168
  st.session_state["subject_input"] = subject_input
169
  if st.button("Create Interview Summary"):
170
  print("please")
171
+ print(st.session_state["appointment_response"]["zoom_meeting"]["id"])
172
  st.rerun()
173
  # print("nach btn summary")
174
  # with st.spinner("Creating the summary..."):
 
183
  print(st.session_state["subject_input"])
184
  print(isinstance(st.session_state["subject_input"],str))
185
  print("bis hierhin gekommen")
186
+ summary_response = get_summary(json.dumps({"meeting_id": str(st.session_state["appointment_response"]["zoom_meeting"]["id"])}))
187
+ st.write(summary_response)