Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,12 @@ def main():
|
|
29 |
if 'voo_answer' not in st.session_state:
|
30 |
st.session_state['voo_answer'] = None
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
if uploaded_files:
|
33 |
if st.sidebar.button("Add Docs to Data Bank"):
|
34 |
files_info = save_uploaded_files(uploaded_files)
|
@@ -48,6 +54,21 @@ def main():
|
|
48 |
st.sidebar.title("Page Navigation")
|
49 |
page = st.sidebar.radio("Select a page", tuple(pages.keys()))
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# Initialize session state for summarization results if not already set
|
52 |
if 'summaries' not in st.session_state:
|
53 |
st.session_state['summaries'] = {}
|
@@ -93,10 +114,9 @@ def page_qna(uploaded_files):
|
|
93 |
user_query = st.text_area("Enter your question here:", height=200)
|
94 |
if st.button('Get Answer'):
|
95 |
if user_query:
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
st.write(st.session_state['data_bank_answer'])
|
100 |
else:
|
101 |
st.error("Please enter a question to get an answer.")
|
102 |
# Display stored answer if it exists
|
@@ -109,10 +129,9 @@ def page_chat_with_uploaded_docs(uploaded_files):
|
|
109 |
user_query = st.text_area("Enter your question here:", height=200)
|
110 |
if st.button('Get Answer'):
|
111 |
if user_query:
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
st.write(st.session_state['uploaded_docs_answer'])
|
116 |
else:
|
117 |
st.error("Please enter a question to get an answer.")
|
118 |
# Display stored answer if it exists
|
@@ -132,10 +151,9 @@ def page_chat_with_voo(uploaded_files):
|
|
132 |
user_query = st.text_area("Enter your question here:", height=200)
|
133 |
if st.button('Get Answer'):
|
134 |
if user_query:
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
st.write(st.session_state['voo_answer'])
|
139 |
else:
|
140 |
st.error("Please enter a question to get an answer.")
|
141 |
# Display stored answer if it exists
|
|
|
29 |
if 'voo_answer' not in st.session_state:
|
30 |
st.session_state['voo_answer'] = None
|
31 |
|
32 |
+
# Initialize session state for tracking page navigation
|
33 |
+
if 'current_page' not in st.session_state:
|
34 |
+
st.session_state['current_page'] = None
|
35 |
+
if 'previous_page' not in st.session_state:
|
36 |
+
st.session_state['previous_page'] = None
|
37 |
+
|
38 |
if uploaded_files:
|
39 |
if st.sidebar.button("Add Docs to Data Bank"):
|
40 |
files_info = save_uploaded_files(uploaded_files)
|
|
|
54 |
st.sidebar.title("Page Navigation")
|
55 |
page = st.sidebar.radio("Select a page", tuple(pages.keys()))
|
56 |
|
57 |
+
# Update current page in session state
|
58 |
+
st.session_state['current_page'] = page
|
59 |
+
|
60 |
+
# Check if the user has navigated to a different page
|
61 |
+
if st.session_state['current_page'] != st.session_state['previous_page']:
|
62 |
+
# Display session state content if the user has navigated away and returned
|
63 |
+
if st.session_state['data_bank_answer'] and st.session_state['current_page'] == "Chat with RSCA":
|
64 |
+
st.write(st.session_state['data_bank_answer'])
|
65 |
+
if st.session_state['uploaded_docs_answer'] and st.session_state['current_page'] == "Chat with Uploaded Docs":
|
66 |
+
st.write(st.session_state['uploaded_docs_answer'])
|
67 |
+
if st.session_state['voo_answer'] and st.session_state['current_page'] == "Chat with VOO":
|
68 |
+
st.write(st.session_state['voo_answer'])
|
69 |
+
# Update the previous page to the current page
|
70 |
+
st.session_state['previous_page'] = st.session_state['current_page']
|
71 |
+
|
72 |
# Initialize session state for summarization results if not already set
|
73 |
if 'summaries' not in st.session_state:
|
74 |
st.session_state['summaries'] = {}
|
|
|
114 |
user_query = st.text_area("Enter your question here:", height=200)
|
115 |
if st.button('Get Answer'):
|
116 |
if user_query:
|
117 |
+
answer = handle_query(user_query)
|
118 |
+
st.session_state['data_bank_answer'] = answer # Store the answer in session state
|
119 |
+
st.write(answer)
|
|
|
120 |
else:
|
121 |
st.error("Please enter a question to get an answer.")
|
122 |
# Display stored answer if it exists
|
|
|
129 |
user_query = st.text_area("Enter your question here:", height=200)
|
130 |
if st.button('Get Answer'):
|
131 |
if user_query:
|
132 |
+
answer = handle_uploaded_docs_query(user_query, st.session_state['uploaded_collection_name'])
|
133 |
+
st.session_state['uploaded_docs_answer'] = answer # Store the answer in session state
|
134 |
+
st.write(answer)
|
|
|
135 |
else:
|
136 |
st.error("Please enter a question to get an answer.")
|
137 |
# Display stored answer if it exists
|
|
|
151 |
user_query = st.text_area("Enter your question here:", height=200)
|
152 |
if st.button('Get Answer'):
|
153 |
if user_query:
|
154 |
+
answer = handle_voo_query(user_query)
|
155 |
+
st.session_state['voo_answer'] = answer # Store the answer in session state
|
156 |
+
st.write(answer)
|
|
|
157 |
else:
|
158 |
st.error("Please enter a question to get an answer.")
|
159 |
# Display stored answer if it exists
|