Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,12 +29,6 @@ def main():
|
|
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,21 +48,6 @@ def main():
|
|
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'] = {}
|
@@ -111,12 +90,13 @@ def page_summarization(uploaded_files):
|
|
111 |
def page_qna(uploaded_files):
|
112 |
"""Page for Q&A functionality."""
|
113 |
st.title("Chat with RSCA")
|
114 |
-
user_query = st.text_area("Enter your question here:", height=
|
115 |
if st.button('Get Answer'):
|
116 |
if user_query:
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
120 |
else:
|
121 |
st.error("Please enter a question to get an answer.")
|
122 |
# Display stored answer if it exists
|
@@ -126,12 +106,13 @@ def page_qna(uploaded_files):
|
|
126 |
def page_chat_with_uploaded_docs(uploaded_files):
|
127 |
"""Page for chatting with uploaded documents."""
|
128 |
st.title("Chat with Uploaded Documents")
|
129 |
-
user_query = st.text_area("Enter your question here:", height=
|
130 |
if st.button('Get Answer'):
|
131 |
if user_query:
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
135 |
else:
|
136 |
st.error("Please enter a question to get an answer.")
|
137 |
# Display stored answer if it exists
|
@@ -148,12 +129,13 @@ def page_chat_with_uploaded_docs(uploaded_files):
|
|
148 |
def page_chat_with_voo(uploaded_files):
|
149 |
"""Page for chatting with VOO documents."""
|
150 |
st.title("Chat with VOO")
|
151 |
-
user_query = st.text_area("Enter your question here:", height=
|
152 |
if st.button('Get Answer'):
|
153 |
if user_query:
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
157 |
else:
|
158 |
st.error("Please enter a question to get an answer.")
|
159 |
# Display stored answer if it exists
|
|
|
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 |
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'] = {}
|
|
|
90 |
def page_qna(uploaded_files):
|
91 |
"""Page for Q&A functionality."""
|
92 |
st.title("Chat with RSCA")
|
93 |
+
user_query = st.text_area("Enter your question here:", height=300)
|
94 |
if st.button('Get Answer'):
|
95 |
if user_query:
|
96 |
+
if 'data_bank_answer' not in st.session_state or st.session_state['data_bank_answer'] is None:
|
97 |
+
answer = handle_query(user_query)
|
98 |
+
st.session_state['data_bank_answer'] = answer # Store the answer in session state
|
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
|
|
|
106 |
def page_chat_with_uploaded_docs(uploaded_files):
|
107 |
"""Page for chatting with uploaded documents."""
|
108 |
st.title("Chat with Uploaded Documents")
|
109 |
+
user_query = st.text_area("Enter your question here:", height=300)
|
110 |
if st.button('Get Answer'):
|
111 |
if user_query:
|
112 |
+
if 'uploaded_docs_answer' not in st.session_state or st.session_state['uploaded_docs_answer'] is None:
|
113 |
+
answer = handle_uploaded_docs_query(user_query, st.session_state['uploaded_collection_name'])
|
114 |
+
st.session_state['uploaded_docs_answer'] = answer # Store the answer in session state
|
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
|
|
|
129 |
def page_chat_with_voo(uploaded_files):
|
130 |
"""Page for chatting with VOO documents."""
|
131 |
st.title("Chat with VOO")
|
132 |
+
user_query = st.text_area("Enter your question here:", height=300)
|
133 |
if st.button('Get Answer'):
|
134 |
if user_query:
|
135 |
+
if 'voo_answer' not in st.session_state or st.session_state['voo_answer'] is None:
|
136 |
+
answer = handle_voo_query(user_query)
|
137 |
+
st.session_state['voo_answer'] = answer # Store the answer in session state
|
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
|