Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,16 @@ import os
|
|
12 |
|
13 |
# Sidebar contents
|
14 |
with st.sidebar:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
st.title(':orange_book: BinDoc GmbH')
|
16 |
st.markdown(
|
17 |
"Experience the future of document interaction with the revolutionary"
|
@@ -29,13 +39,7 @@ with st.sidebar:
|
|
29 |
add_vertical_space(3) # Add more vertical space between text blocks
|
30 |
st.write('Made with ❤️ by Anne')
|
31 |
|
32 |
-
|
33 |
-
api_key = st.text_input('Enter your OpenAI API Key:', type='password')
|
34 |
-
|
35 |
-
if api_key:
|
36 |
-
os.environ['OPENAI_API_KEY'] = api_key
|
37 |
-
else:
|
38 |
-
st.warning('API key is required to proceed.')
|
39 |
|
40 |
def load_pdf(file_path):
|
41 |
pdf_reader = PdfReader(file_path)
|
@@ -82,7 +86,7 @@ def main():
|
|
82 |
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
83 |
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
84 |
st.write("<!-- End Spacer -->", unsafe_allow_html=True)
|
85 |
-
|
86 |
new_messages_placeholder = st.empty()
|
87 |
loading_message = st.empty()
|
88 |
|
@@ -94,8 +98,8 @@ def main():
|
|
94 |
if st.button("Ask") or (query and query != st.session_state.get('last_input', '')):
|
95 |
st.session_state['last_input'] = query # Save the current query as the last input
|
96 |
st.session_state['chat_history'].append(("User", query, "new"))
|
97 |
-
|
98 |
-
loading_message.
|
99 |
|
100 |
VectorStore = load_pdf(pdf)
|
101 |
chain = load_chatbot()
|
@@ -122,5 +126,6 @@ def main():
|
|
122 |
# Mark all messages as old after displaying
|
123 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
124 |
|
|
|
125 |
if __name__ == "__main__":
|
126 |
main()
|
|
|
12 |
|
13 |
# Sidebar contents
|
14 |
with st.sidebar:
|
15 |
+
|
16 |
+
# API key input (this will not display the entered text)
|
17 |
+
api_key = st.text_input('Enter your OpenAI API Key:', type='password')
|
18 |
+
|
19 |
+
if api_key:
|
20 |
+
os.environ['OPENAI_API_KEY'] = api_key
|
21 |
+
else:
|
22 |
+
st.warning('API key is required to proceed.')
|
23 |
+
|
24 |
+
|
25 |
st.title(':orange_book: BinDoc GmbH')
|
26 |
st.markdown(
|
27 |
"Experience the future of document interaction with the revolutionary"
|
|
|
39 |
add_vertical_space(3) # Add more vertical space between text blocks
|
40 |
st.write('Made with ❤️ by Anne')
|
41 |
|
42 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
def load_pdf(file_path):
|
45 |
pdf_reader = PdfReader(file_path)
|
|
|
86 |
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
87 |
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
88 |
st.write("<!-- End Spacer -->", unsafe_allow_html=True)
|
89 |
+
|
90 |
new_messages_placeholder = st.empty()
|
91 |
loading_message = st.empty()
|
92 |
|
|
|
98 |
if st.button("Ask") or (query and query != st.session_state.get('last_input', '')):
|
99 |
st.session_state['last_input'] = query # Save the current query as the last input
|
100 |
st.session_state['chat_history'].append(("User", query, "new"))
|
101 |
+
|
102 |
+
loading_message.markdown("<div style='background-color: #FFA07A; padding: 10px; border-radius: 10px; margin: 10px;'>Bot is thinking...</div>", unsafe_allow_html=True)
|
103 |
|
104 |
VectorStore = load_pdf(pdf)
|
105 |
chain = load_chatbot()
|
|
|
126 |
# Mark all messages as old after displaying
|
127 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
128 |
|
129 |
+
|
130 |
if __name__ == "__main__":
|
131 |
main()
|