Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -126,11 +126,6 @@ def conversation(qa_chain, message, history):
|
|
126 |
st.error(f"Error in conversation: {e}")
|
127 |
return qa_chain, history, "", []
|
128 |
|
129 |
-
def download_history(chat_history):
|
130 |
-
formatted_chat_history = format_chat_history(chat_history)
|
131 |
-
history_text = "\n".join(formatted_chat_history)
|
132 |
-
st.download_button(label="Download Chat History", data=history_text, file_name="chat_history.txt", mime="text/plain")
|
133 |
-
|
134 |
def main():
|
135 |
st.sidebar.title("PDF Chatbot")
|
136 |
|
@@ -173,18 +168,16 @@ def main():
|
|
173 |
st.session_state['qa_chain'] = qa_chain
|
174 |
st.session_state['chat_history'] = chat_history
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
# Display the chat history in a chat-like interface
|
179 |
-
for i, (user_msg, bot_msg) in enumerate(st.session_state['chat_history']):
|
180 |
-
st.markdown(f"**User:** {user_msg}")
|
181 |
-
st.markdown(f"**Assistant:** {bot_msg}")
|
182 |
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
|
187 |
-
|
|
|
|
|
188 |
|
189 |
if __name__ == "__main__":
|
190 |
main()
|
|
|
126 |
st.error(f"Error in conversation: {e}")
|
127 |
return qa_chain, history, "", []
|
128 |
|
|
|
|
|
|
|
|
|
|
|
129 |
def main():
|
130 |
st.sidebar.title("PDF Chatbot")
|
131 |
|
|
|
168 |
st.session_state['qa_chain'] = qa_chain
|
169 |
st.session_state['chat_history'] = chat_history
|
170 |
|
171 |
+
st.markdown("### Chatbot Response")
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
+
# Display the chat history in a chat-like interface
|
174 |
+
for i, (user_msg, bot_msg) in enumerate(st.session_state['chat_history']):
|
175 |
+
st.markdown(f"**User:** {user_msg}")
|
176 |
+
st.markdown(f"**Assistant:** {bot_msg}")
|
177 |
|
178 |
+
with st.expander("Relevant context from the source document"):
|
179 |
+
for source in sources:
|
180 |
+
st.text_area(f"Source - Page {source['page']}", value=source["content"], height=100)
|
181 |
|
182 |
if __name__ == "__main__":
|
183 |
main()
|