Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -233,6 +233,7 @@
|
|
| 233 |
# render_history()
|
| 234 |
|
| 235 |
|
|
|
|
| 236 |
# app.py
|
| 237 |
|
| 238 |
import os
|
|
@@ -248,7 +249,7 @@ from groq import Groq
|
|
| 248 |
|
| 249 |
# β
Hugging Face and GROQ secrets loaded via Hugging Face Spaces Secrets interface
|
| 250 |
|
| 251 |
-
#
|
| 252 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 253 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 254 |
KAGGLE_USERNAME = os.getenv("KAGGLE_USERNAME")
|
|
@@ -294,6 +295,8 @@ if "history" not in st.session_state:
|
|
| 294 |
st.session_state.history = []
|
| 295 |
if "audio_summary" not in st.session_state:
|
| 296 |
st.session_state.audio_summary = ""
|
|
|
|
|
|
|
| 297 |
|
| 298 |
# =======================
|
| 299 |
# Streamlit UI
|
|
@@ -408,9 +411,11 @@ def render_history():
|
|
| 408 |
if clear_btn:
|
| 409 |
st.session_state.history.clear()
|
| 410 |
st.session_state.audio_summary = ""
|
|
|
|
| 411 |
st.success("β
History cleared!")
|
| 412 |
|
| 413 |
if analyze_btn:
|
|
|
|
| 414 |
combined_text = text_input
|
| 415 |
if uploaded_file:
|
| 416 |
extracted = extract_text_from_file(uploaded_file)
|
|
@@ -442,9 +447,6 @@ if analyze_btn:
|
|
| 442 |
st.audio(f.read(), format="audio/mp3")
|
| 443 |
os.remove(audio_path)
|
| 444 |
|
| 445 |
-
if st.button("π€ Report to IT"):
|
| 446 |
-
st.success("π¨ Report sent to IT successfully.")
|
| 447 |
-
|
| 448 |
# Save history
|
| 449 |
st.session_state.history.append({
|
| 450 |
"input": combined_text,
|
|
@@ -465,5 +467,14 @@ if analyze_btn:
|
|
| 465 |
for term, definition in GLOSSARY.items():
|
| 466 |
st.markdown(f"**{term.capitalize()}**: {definition}")
|
| 467 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
render_history()
|
| 469 |
|
|
|
|
| 233 |
# render_history()
|
| 234 |
|
| 235 |
|
| 236 |
+
# app.py
|
| 237 |
# app.py
|
| 238 |
|
| 239 |
import os
|
|
|
|
| 249 |
|
| 250 |
# β
Hugging Face and GROQ secrets loaded via Hugging Face Spaces Secrets interface
|
| 251 |
|
| 252 |
+
# βͺ Access secrets securely from environment variables
|
| 253 |
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 254 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 255 |
KAGGLE_USERNAME = os.getenv("KAGGLE_USERNAME")
|
|
|
|
| 295 |
st.session_state.history = []
|
| 296 |
if "audio_summary" not in st.session_state:
|
| 297 |
st.session_state.audio_summary = ""
|
| 298 |
+
if "report_sent" not in st.session_state:
|
| 299 |
+
st.session_state.report_sent = False
|
| 300 |
|
| 301 |
# =======================
|
| 302 |
# Streamlit UI
|
|
|
|
| 411 |
if clear_btn:
|
| 412 |
st.session_state.history.clear()
|
| 413 |
st.session_state.audio_summary = ""
|
| 414 |
+
st.session_state.report_sent = False
|
| 415 |
st.success("β
History cleared!")
|
| 416 |
|
| 417 |
if analyze_btn:
|
| 418 |
+
st.session_state.report_sent = False
|
| 419 |
combined_text = text_input
|
| 420 |
if uploaded_file:
|
| 421 |
extracted = extract_text_from_file(uploaded_file)
|
|
|
|
| 447 |
st.audio(f.read(), format="audio/mp3")
|
| 448 |
os.remove(audio_path)
|
| 449 |
|
|
|
|
|
|
|
|
|
|
| 450 |
# Save history
|
| 451 |
st.session_state.history.append({
|
| 452 |
"input": combined_text,
|
|
|
|
| 467 |
for term, definition in GLOSSARY.items():
|
| 468 |
st.markdown(f"**{term.capitalize()}**: {definition}")
|
| 469 |
|
| 470 |
+
# β
Report to IT section - outside the expander and stable
|
| 471 |
+
st.markdown("---")
|
| 472 |
+
report_it = st.button("π€ Report to IT", key="report_it_btn")
|
| 473 |
+
if report_it:
|
| 474 |
+
st.session_state.report_sent = True
|
| 475 |
+
|
| 476 |
+
if st.session_state.report_sent:
|
| 477 |
+
st.success("π¨ Report sent to IT successfully.")
|
| 478 |
+
|
| 479 |
render_history()
|
| 480 |
|