Spaces:
Sleeping
Sleeping
Updated app.py
Browse files
app.py
CHANGED
|
@@ -28,16 +28,43 @@ def get_client_names():
|
|
| 28 |
client_names.add(client_name)
|
| 29 |
return sorted(client_names)
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
def login():
|
| 32 |
st.markdown("""
|
| 33 |
<style>
|
| 34 |
.stApp {
|
| 35 |
-
background: linear-gradient(
|
| 36 |
-
125deg,
|
| 37 |
-
#F0F4F8 0%,
|
| 38 |
-
#D9E4F5 50%,
|
| 39 |
-
#E5EFF8 100%
|
| 40 |
-
);
|
| 41 |
background-size: 200% 200%;
|
| 42 |
animation: gradientMove 10s ease infinite;
|
| 43 |
}
|
|
@@ -54,46 +81,9 @@ def login():
|
|
| 54 |
margin-bottom: 3rem;
|
| 55 |
letter-spacing: 2px;
|
| 56 |
}
|
| 57 |
-
.login-form-container {
|
| 58 |
-
width: 400px;
|
| 59 |
-
margin: 0 auto;
|
| 60 |
-
padding: 2rem;
|
| 61 |
-
background: linear-gradient(
|
| 62 |
-
135deg,
|
| 63 |
-
rgba(0, 0, 0, 0.1) 0%,
|
| 64 |
-
rgba(0, 0, 0, 0.15) 100%
|
| 65 |
-
);
|
| 66 |
-
backdrop-filter: blur(15px);
|
| 67 |
-
border-radius: 24px;
|
| 68 |
-
box-shadow:
|
| 69 |
-
0 8px 32px rgba(31, 38, 135, 0.37),
|
| 70 |
-
inset -4px -4px 8px rgba(255, 255, 255, 0.1),
|
| 71 |
-
inset 4px 4px 8px rgba(0, 0, 0, 0.2);
|
| 72 |
-
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 73 |
-
}
|
| 74 |
-
.stSelectbox label, .stDateInput label {
|
| 75 |
-
color: #333333 !important;
|
| 76 |
-
font-weight: bold;
|
| 77 |
-
font-size: 1rem;
|
| 78 |
-
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
|
| 79 |
-
}
|
| 80 |
-
.stSelectbox > div > div, .stDateInput > div > div {
|
| 81 |
-
background: #2E3A47;
|
| 82 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 83 |
-
border-radius: 12px;
|
| 84 |
-
color: #FFFFFF;
|
| 85 |
-
font-weight: bold;
|
| 86 |
-
box-shadow:
|
| 87 |
-
inset 2px 2px 5px rgba(0, 0, 0, 0.3),
|
| 88 |
-
inset -2px -2px 5px rgba(255, 255, 255, 0.2);
|
| 89 |
-
}
|
| 90 |
.stButton > button {
|
| 91 |
width: 100%;
|
| 92 |
-
background: linear-gradient(
|
| 93 |
-
45deg,
|
| 94 |
-
#2563eb 0%,
|
| 95 |
-
#3b82f6 100%
|
| 96 |
-
);
|
| 97 |
color: white;
|
| 98 |
border: none;
|
| 99 |
border-radius: 16px;
|
|
@@ -102,45 +92,55 @@ def login():
|
|
| 102 |
font-weight: bold;
|
| 103 |
cursor: pointer;
|
| 104 |
margin-top: 2rem;
|
| 105 |
-
box-shadow:
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
inset 0 4px 8px rgba(255, 255, 255, 0.2);
|
| 109 |
transition: all 0.3s ease;
|
| 110 |
}
|
| 111 |
.stButton > button:hover {
|
| 112 |
transform: translateY(-3px) scale(1.03);
|
| 113 |
-
box-shadow:
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
background: linear-gradient(
|
| 118 |
-
45deg,
|
| 119 |
-
#1d4ed8 0%,
|
| 120 |
-
#2563eb 100%
|
| 121 |
-
);
|
| 122 |
}
|
| 123 |
</style>
|
| 124 |
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
st.markdown("<h1>KAP NOTES</h1>", unsafe_allow_html=True)
|
| 127 |
-
|
| 128 |
client_names = get_client_names()
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
submit_button = st.form_submit_button("Sign In")
|
| 135 |
|
| 136 |
-
if
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
st.
|
| 140 |
-
st.
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
if 'logged_in' not in st.session_state:
|
| 146 |
st.session_state.logged_in = False
|
|
@@ -148,9 +148,14 @@ if 'logged_in' not in st.session_state:
|
|
| 148 |
if not st.session_state.logged_in:
|
| 149 |
login()
|
| 150 |
else:
|
| 151 |
-
st.set_page_config(page_title="Kap Notes", layout="wide")
|
| 152 |
client_name = st.session_state.client_name
|
| 153 |
date = st.session_state.date
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
|
| 155 |
st.sidebar.markdown(f'''
|
| 156 |
<div class="client-name-container">
|
|
@@ -185,7 +190,7 @@ else:
|
|
| 185 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 186 |
}
|
| 187 |
.summary-box:hover, .keypoints-box:hover, .action-items-box:hover {
|
| 188 |
-
transform: translateY(-1px) scale(1.05);
|
| 189 |
box-shadow: 0px 12px 25px rgba(0, 0, 0, 0.25), 0px 18px 35px rgba(0, 0, 0, 0.2);
|
| 190 |
}
|
| 191 |
.summary-box {
|
|
@@ -357,9 +362,9 @@ else:
|
|
| 357 |
'''
|
| 358 |
st.markdown(css, unsafe_allow_html=True)
|
| 359 |
|
| 360 |
-
summary_blob_name = f"{client_name}/{date
|
| 361 |
-
transcription_blob_name = f"{client_name}/{date
|
| 362 |
-
audio_blob_name = f"{client_name}/{date
|
| 363 |
|
| 364 |
bucket = client.bucket(bucket_name)
|
| 365 |
|
|
@@ -369,9 +374,17 @@ else:
|
|
| 369 |
audio_blob = bucket.blob(audio_blob_name)
|
| 370 |
audio_url = audio_blob.generate_signed_url(expiration=timedelta(hours=1), method='GET')
|
| 371 |
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
|
| 376 |
transcription_blob = bucket.blob(transcription_blob_name)
|
| 377 |
with transcription_blob.open("r") as file:
|
|
@@ -524,5 +537,4 @@ else:
|
|
| 524 |
xaxis=dict(title="Time (in seconds)"),
|
| 525 |
yaxis=dict(title="Sentiment Score", range=[-1, 1]),
|
| 526 |
)
|
| 527 |
-
|
| 528 |
st.plotly_chart(fig)
|
|
|
|
| 28 |
client_names.add(client_name)
|
| 29 |
return sorted(client_names)
|
| 30 |
|
| 31 |
+
def validate_data(client_name, date, meeting):
|
| 32 |
+
summary_blob_name = f"{client_name}/{date}/{meeting}/summary.txt"
|
| 33 |
+
transcription_blob_name = f"{client_name}/{date}/{meeting}/transcription.txt"
|
| 34 |
+
audio_blob_name = f"{client_name}/{date}/{meeting}/audio.wav"
|
| 35 |
+
summary_blob = bucket.blob(summary_blob_name)
|
| 36 |
+
transcription_blob = bucket.blob(transcription_blob_name)
|
| 37 |
+
audio_blob = bucket.blob(audio_blob_name)
|
| 38 |
+
return summary_blob.exists() and transcription_blob.exists() and audio_blob.exists()
|
| 39 |
+
|
| 40 |
+
def get_meetings_for_date(client_name, date):
|
| 41 |
+
prefix = f"{client_name}/{date}/"
|
| 42 |
+
blobs = bucket.list_blobs(prefix=prefix)
|
| 43 |
+
meetings = set()
|
| 44 |
+
for blob in blobs:
|
| 45 |
+
parts = blob.name[len(prefix):].split('/')
|
| 46 |
+
if len(parts) > 1:
|
| 47 |
+
meetings.add(parts[0])
|
| 48 |
+
return sorted(meetings)
|
| 49 |
+
|
| 50 |
+
def get_dates_for_client(client_name):
|
| 51 |
+
client = storage.Client()
|
| 52 |
+
bucket_name = "kapnotes"
|
| 53 |
+
bucket = client.get_bucket(bucket_name)
|
| 54 |
+
prefix = f"{client_name}/"
|
| 55 |
+
blobs = bucket.list_blobs(prefix=prefix)
|
| 56 |
+
folder_names = set()
|
| 57 |
+
for blob in blobs:
|
| 58 |
+
parts = blob.name[len(prefix):].split('/')
|
| 59 |
+
if len(parts) > 1:
|
| 60 |
+
folder_names.add(parts[0])
|
| 61 |
+
return sorted(folder_names)
|
| 62 |
+
|
| 63 |
def login():
|
| 64 |
st.markdown("""
|
| 65 |
<style>
|
| 66 |
.stApp {
|
| 67 |
+
background: linear-gradient(125deg,rgb(253, 250, 220) 0%,rgb(214, 245, 255) 50%, #F8F8FF 100%);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
background-size: 200% 200%;
|
| 69 |
animation: gradientMove 10s ease infinite;
|
| 70 |
}
|
|
|
|
| 81 |
margin-bottom: 3rem;
|
| 82 |
letter-spacing: 2px;
|
| 83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
.stButton > button {
|
| 85 |
width: 100%;
|
| 86 |
+
background: linear-gradient(45deg, #2563eb 0%, #3b82f6 100%);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
color: white;
|
| 88 |
border: none;
|
| 89 |
border-radius: 16px;
|
|
|
|
| 92 |
font-weight: bold;
|
| 93 |
cursor: pointer;
|
| 94 |
margin-top: 2rem;
|
| 95 |
+
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4),
|
| 96 |
+
inset 0 -4px 8px rgba(0, 0, 0, 0.2),
|
| 97 |
+
inset 0 4px 8px rgba(255, 255, 255, 0.2);
|
|
|
|
| 98 |
transition: all 0.3s ease;
|
| 99 |
}
|
| 100 |
.stButton > button:hover {
|
| 101 |
transform: translateY(-3px) scale(1.03);
|
| 102 |
+
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5),
|
| 103 |
+
inset 0 -4px 8px rgba(0, 0, 0, 0.2),
|
| 104 |
+
inset 0 4px 8px rgba(255, 255, 255, 0.2);
|
| 105 |
+
background: linear-gradient(45deg, #1d4ed8 0%, #2563eb 100%);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
</style>
|
| 108 |
""", unsafe_allow_html=True)
|
| 109 |
+
|
| 110 |
+
if 'password' not in st.session_state:
|
| 111 |
+
st.session_state.password = ""
|
| 112 |
|
| 113 |
st.markdown("<h1>KAP NOTES</h1>", unsafe_allow_html=True)
|
| 114 |
+
|
| 115 |
client_names = get_client_names()
|
| 116 |
+
client_name = st.selectbox("Select Client", client_names)
|
| 117 |
+
|
| 118 |
+
if client_name:
|
| 119 |
+
available_dates = get_dates_for_client(client_name)
|
| 120 |
+
selected_date = st.selectbox(f"Available Dates for {client_name}", available_dates)
|
|
|
|
| 121 |
|
| 122 |
+
if selected_date:
|
| 123 |
+
available_meetings = get_meetings_for_date(client_name, selected_date)
|
| 124 |
+
selected_meeting = st.selectbox(f"Available Meetings for {selected_date}", available_meetings)
|
| 125 |
+
password = st.text_input("Enter Password", type="password", value=st.session_state.password)
|
| 126 |
+
sign_in_button = st.button("Sign In", key="sign_in")
|
| 127 |
+
if sign_in_button:
|
| 128 |
+
if password == "kapnotes12345":
|
| 129 |
+
if validate_data(client_name, selected_date, selected_meeting):
|
| 130 |
+
st.session_state.client_name = client_name
|
| 131 |
+
st.session_state.date = selected_date
|
| 132 |
+
st.session_state.meeting = selected_meeting
|
| 133 |
+
st.session_state.logged_in = True
|
| 134 |
+
st.session_state.password = password
|
| 135 |
+
st.rerun()
|
| 136 |
+
else:
|
| 137 |
+
st.error(f"No records available for {client_name} on {selected_date}. Please select another option.")
|
| 138 |
+
elif not password:
|
| 139 |
+
st.error("Please enter password.")
|
| 140 |
+
else:
|
| 141 |
+
st.error("Incorrect Password. Please try again.")
|
| 142 |
+
st.session_state.password = password
|
| 143 |
+
|
| 144 |
|
| 145 |
if 'logged_in' not in st.session_state:
|
| 146 |
st.session_state.logged_in = False
|
|
|
|
| 148 |
if not st.session_state.logged_in:
|
| 149 |
login()
|
| 150 |
else:
|
|
|
|
| 151 |
client_name = st.session_state.client_name
|
| 152 |
date = st.session_state.date
|
| 153 |
+
meeting = st.session_state.meeting
|
| 154 |
+
password= st.session_state.password
|
| 155 |
+
|
| 156 |
+
if st.sidebar.button("Back"):
|
| 157 |
+
st.session_state.logged_in = False
|
| 158 |
+
st.rerun()
|
| 159 |
|
| 160 |
st.sidebar.markdown(f'''
|
| 161 |
<div class="client-name-container">
|
|
|
|
| 190 |
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
| 191 |
}
|
| 192 |
.summary-box:hover, .keypoints-box:hover, .action-items-box:hover {
|
| 193 |
+
transform: translateY(-0.1px) scale(1.05);
|
| 194 |
box-shadow: 0px 12px 25px rgba(0, 0, 0, 0.25), 0px 18px 35px rgba(0, 0, 0, 0.2);
|
| 195 |
}
|
| 196 |
.summary-box {
|
|
|
|
| 362 |
'''
|
| 363 |
st.markdown(css, unsafe_allow_html=True)
|
| 364 |
|
| 365 |
+
summary_blob_name = f"{client_name}/{date}/{meeting}/summary.txt"
|
| 366 |
+
transcription_blob_name = f"{client_name}/{date}/{meeting}/transcription.txt"
|
| 367 |
+
audio_blob_name = f"{client_name}/{date}/{meeting}/audio.wav"
|
| 368 |
|
| 369 |
bucket = client.bucket(bucket_name)
|
| 370 |
|
|
|
|
| 374 |
audio_blob = bucket.blob(audio_blob_name)
|
| 375 |
audio_url = audio_blob.generate_signed_url(expiration=timedelta(hours=1), method='GET')
|
| 376 |
|
| 377 |
+
summary_match = re.search(r"Summary:\s*(.*?)(?=\nKey Points:)", summary_content, re.DOTALL)
|
| 378 |
+
summary = summary_match.group(1).strip() if summary_match else "Summary not found."
|
| 379 |
+
|
| 380 |
+
key_points_match = re.search(r"Key Points:\s*(.*?)(?=\nAction Items:)", summary_content, re.DOTALL)
|
| 381 |
+
key_points = re.findall(r"- (.*?)\n", key_points_match.group(1)) if key_points_match else ["Key points not found."]
|
| 382 |
+
|
| 383 |
+
action_items_match = re.search(r"Action Items:\s*(.*)", summary_content, re.DOTALL)
|
| 384 |
+
if action_items_match:
|
| 385 |
+
action_items = re.findall(r"- (.*?)(?=\n- |$)", action_items_match.group(1), re.DOTALL)
|
| 386 |
+
else:
|
| 387 |
+
action_items = ["Action items not found."]
|
| 388 |
|
| 389 |
transcription_blob = bucket.blob(transcription_blob_name)
|
| 390 |
with transcription_blob.open("r") as file:
|
|
|
|
| 537 |
xaxis=dict(title="Time (in seconds)"),
|
| 538 |
yaxis=dict(title="Sentiment Score", range=[-1, 1]),
|
| 539 |
)
|
|
|
|
| 540 |
st.plotly_chart(fig)
|