Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +38 -2
src/streamlit_app.py
CHANGED
@@ -4,6 +4,7 @@ import requests, time, regex, re
|
|
4 |
from datetime import datetime
|
5 |
from dotenv import load_dotenv
|
6 |
import certifi
|
|
|
7 |
|
8 |
load_dotenv()
|
9 |
|
@@ -18,12 +19,12 @@ from src.parameters import (
|
|
18 |
params,
|
19 |
display_chat_history,
|
20 |
stream_outputs,
|
|
|
21 |
wx_api_key,
|
22 |
wx_project_id,
|
23 |
wx_url,
|
24 |
)
|
25 |
from src.helper_functions import (
|
26 |
-
check_password,
|
27 |
setup_watsonxai_client,
|
28 |
initialize_session_state,
|
29 |
create_pdf_from_chat,
|
@@ -40,13 +41,48 @@ st.set_page_config(
|
|
40 |
)
|
41 |
initialize_session_state()
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
if not check_password():
|
44 |
st.stop()
|
45 |
|
46 |
if "current_page" not in st.session_state:
|
47 |
st.session_state.current_page = 0
|
48 |
|
49 |
-
|
50 |
wx_client = setup_watsonxai_client(
|
51 |
api_key=wx_api_key, project_id=wx_project_id, url=wx_url
|
52 |
)
|
|
|
4 |
from datetime import datetime
|
5 |
from dotenv import load_dotenv
|
6 |
import certifi
|
7 |
+
import os
|
8 |
|
9 |
load_dotenv()
|
10 |
|
|
|
19 |
params,
|
20 |
display_chat_history,
|
21 |
stream_outputs,
|
22 |
+
app_password
|
23 |
wx_api_key,
|
24 |
wx_project_id,
|
25 |
wx_url,
|
26 |
)
|
27 |
from src.helper_functions import (
|
|
|
28 |
setup_watsonxai_client,
|
29 |
initialize_session_state,
|
30 |
create_pdf_from_chat,
|
|
|
41 |
)
|
42 |
initialize_session_state()
|
43 |
|
44 |
+
|
45 |
+
def check_password():
|
46 |
+
def password_entered():
|
47 |
+
if st.session_state["password"] == app_password:
|
48 |
+
st.session_state["password_correct"] = True
|
49 |
+
del st.session_state["password"]
|
50 |
+
else:
|
51 |
+
st.session_state["password_correct"] = False
|
52 |
+
|
53 |
+
if "password_correct" not in st.session_state:
|
54 |
+
st.markdown("\n\n")
|
55 |
+
st.text_input(
|
56 |
+
"Enter the password",
|
57 |
+
type="password",
|
58 |
+
on_change=password_entered,
|
59 |
+
key="password",
|
60 |
+
)
|
61 |
+
st.divider()
|
62 |
+
st.info("Designed and developed by Milan Mrdenovic © IBM Norway 2025")
|
63 |
+
return False
|
64 |
+
elif not st.session_state["password_correct"]:
|
65 |
+
st.markdown("\n\n")
|
66 |
+
st.text_input(
|
67 |
+
"Enter the password",
|
68 |
+
type="password",
|
69 |
+
on_change=password_entered,
|
70 |
+
key="password",
|
71 |
+
)
|
72 |
+
st.divider()
|
73 |
+
st.info("Designed and developed by Milan Mrdenovic © IBM Norway 2025")
|
74 |
+
st.error("😕 Password incorrect")
|
75 |
+
return False
|
76 |
+
else:
|
77 |
+
return True
|
78 |
+
|
79 |
+
|
80 |
if not check_password():
|
81 |
st.stop()
|
82 |
|
83 |
if "current_page" not in st.session_state:
|
84 |
st.session_state.current_page = 0
|
85 |
|
|
|
86 |
wx_client = setup_watsonxai_client(
|
87 |
api_key=wx_api_key, project_id=wx_project_id, url=wx_url
|
88 |
)
|