Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,10 +54,12 @@ import re
|
|
| 54 |
# Set up logging to suppress Streamlit warnings about experimental functions
|
| 55 |
logging.getLogger('streamlit').setLevel(logging.ERROR)
|
| 56 |
|
| 57 |
-
if "chat_history" not in st.session_state:
|
| 58 |
-
st.session_state["chat_history"] = []
|
| 59 |
if "documents" not in st.session_state:
|
| 60 |
st.session_state["documents"] = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
if "message_limit" not in st.session_state:
|
| 62 |
st.session_state["message_limit"] = 0
|
| 63 |
if "used_messages" not in st.session_state:
|
|
@@ -1960,7 +1962,16 @@ def handle_prompt(prompt):
|
|
| 1960 |
# Prevent duplicate messages in chat history
|
| 1961 |
if not any(msg["content"] == prompt for msg in st.session_state["chat_history"]):
|
| 1962 |
st.session_state.chat_history.append({"role": "user", "content": prompt})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1963 |
|
|
|
|
|
|
|
|
|
|
| 1964 |
|
| 1965 |
# Handle missing Trust Bucket if needed
|
| 1966 |
if st.session_state.get("missing_trustbucket_content") and not st.session_state["handled"]:
|
|
|
|
| 54 |
# Set up logging to suppress Streamlit warnings about experimental functions
|
| 55 |
logging.getLogger('streamlit').setLevel(logging.ERROR)
|
| 56 |
|
|
|
|
|
|
|
| 57 |
if "documents" not in st.session_state:
|
| 58 |
st.session_state["documents"] = {}
|
| 59 |
+
|
| 60 |
+
if "chat_history" not in st.session_state:
|
| 61 |
+
st.session_state["chat_history"] = []
|
| 62 |
+
|
| 63 |
if "message_limit" not in st.session_state:
|
| 64 |
st.session_state["message_limit"] = 0
|
| 65 |
if "used_messages" not in st.session_state:
|
|
|
|
| 1962 |
# Prevent duplicate messages in chat history
|
| 1963 |
if not any(msg["content"] == prompt for msg in st.session_state["chat_history"]):
|
| 1964 |
st.session_state.chat_history.append({"role": "user", "content": prompt})
|
| 1965 |
+
document_response = handle_document_query(prompt)
|
| 1966 |
+
if document_response:
|
| 1967 |
+
with st.chat_message("assistant"):
|
| 1968 |
+
st.markdown(document_response)
|
| 1969 |
+
st.session_state["handled"] = True # Mark as handled
|
| 1970 |
+
return
|
| 1971 |
|
| 1972 |
+
|
| 1973 |
+
|
| 1974 |
+
|
| 1975 |
|
| 1976 |
# Handle missing Trust Bucket if needed
|
| 1977 |
if st.session_state.get("missing_trustbucket_content") and not st.session_state["handled"]:
|