Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -89,10 +89,10 @@ def load_pdf(file_path):
|
|
89 |
return VectorStore
|
90 |
|
91 |
|
92 |
-
|
93 |
def load_chatbot():
|
94 |
return load_qa_chain(llm=OpenAI(), chain_type="stuff")
|
95 |
|
|
|
96 |
def main():
|
97 |
|
98 |
hide_streamlit_style = """
|
@@ -103,7 +103,6 @@ def main():
|
|
103 |
"""
|
104 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
105 |
|
106 |
-
|
107 |
# Main content
|
108 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
109 |
|
@@ -116,11 +115,7 @@ def main():
|
|
116 |
if "chat_history" not in st.session_state:
|
117 |
st.session_state['chat_history'] = []
|
118 |
|
119 |
-
|
120 |
-
for chat in chat_history:
|
121 |
-
background_color = "#FFA07A" if chat[2] == "new" else "#acf" if chat[0] == "User" else "#caf"
|
122 |
-
st.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
123 |
-
|
124 |
|
125 |
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
126 |
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
@@ -142,7 +137,7 @@ def display_chat_history(chat_history):
|
|
142 |
if st.button("Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"):
|
143 |
query = "Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"
|
144 |
if st.button("Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?"):
|
145 |
-
query =
|
146 |
|
147 |
|
148 |
if st.button("Ask") or (not st.session_state['chat_history'] and query) or (st.session_state['chat_history'] and query != st.session_state['chat_history'][-1][1]):
|
@@ -170,9 +165,6 @@ def display_chat_history(chat_history):
|
|
170 |
|
171 |
loading_message.empty()
|
172 |
|
173 |
-
display_chat_history(st.session_state['chat_history'])
|
174 |
-
|
175 |
-
|
176 |
# Clear the input field by setting the query variable to an empty string
|
177 |
query = ""
|
178 |
|
@@ -180,11 +172,10 @@ def display_chat_history(chat_history):
|
|
180 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
181 |
|
182 |
|
183 |
-
|
184 |
def display_chat_history(chat_history):
|
185 |
for chat in chat_history:
|
186 |
background_color = "#FFA07A" if chat[2] == "new" else "#acf" if chat[0] == "User" else "#caf"
|
187 |
st.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
188 |
|
189 |
if __name__ == "__main__":
|
190 |
-
main()
|
|
|
89 |
return VectorStore
|
90 |
|
91 |
|
|
|
92 |
def load_chatbot():
|
93 |
return load_qa_chain(llm=OpenAI(), chain_type="stuff")
|
94 |
|
95 |
+
|
96 |
def main():
|
97 |
|
98 |
hide_streamlit_style = """
|
|
|
103 |
"""
|
104 |
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
|
105 |
|
|
|
106 |
# Main content
|
107 |
st.title("Welcome to BinDocs ChatBot! 🤖")
|
108 |
|
|
|
115 |
if "chat_history" not in st.session_state:
|
116 |
st.session_state['chat_history'] = []
|
117 |
|
118 |
+
display_chat_history(st.session_state['chat_history'])
|
|
|
|
|
|
|
|
|
119 |
|
120 |
st.write("<!-- Start Spacer -->", unsafe_allow_html=True)
|
121 |
st.write("<div style='flex: 1;'></div>", unsafe_allow_html=True)
|
|
|
137 |
if st.button("Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"):
|
138 |
query = "Was sagt mir die Farbe der Balken der Bevölkerungsentwicklung?"
|
139 |
if st.button("Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?"):
|
140 |
+
query = "Ich habe mein Meta Password vergessen, wie kann ich es zurücksetzen?"
|
141 |
|
142 |
|
143 |
if st.button("Ask") or (not st.session_state['chat_history'] and query) or (st.session_state['chat_history'] and query != st.session_state['chat_history'][-1][1]):
|
|
|
165 |
|
166 |
loading_message.empty()
|
167 |
|
|
|
|
|
|
|
168 |
# Clear the input field by setting the query variable to an empty string
|
169 |
query = ""
|
170 |
|
|
|
172 |
st.session_state['chat_history'] = [(sender, msg, "old") for sender, msg, _ in st.session_state['chat_history']]
|
173 |
|
174 |
|
|
|
175 |
def display_chat_history(chat_history):
|
176 |
for chat in chat_history:
|
177 |
background_color = "#FFA07A" if chat[2] == "new" else "#acf" if chat[0] == "User" else "#caf"
|
178 |
st.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{chat[0]}: {chat[1]}</div>", unsafe_allow_html=True)
|
179 |
|
180 |
if __name__ == "__main__":
|
181 |
+
main()
|