cryogenic22 commited on
Commit
15e61e4
·
verified ·
1 Parent(s): 1cb9bbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -49
app.py CHANGED
@@ -183,36 +183,21 @@ def display_collection_sidebar():
183
  with st.sidebar:
184
  st.title("📚 Document Manager")
185
 
186
- # Collection Creation Section
187
- st.header("Collections")
188
- if st.button("➕ Create New Collection"):
189
- show_collection_creation_dialog()
190
 
191
- # Collection Selection
 
 
 
192
  collections = get_collections(st.session_state.db_conn)
193
  if collections:
194
- selected_collection = st.selectbox(
195
- "Select Collection",
196
- options=["All Documents"] + [c['name'] for c in collections],
197
- key="collection_selector"
198
  )
199
-
200
- if selected_collection != "All Documents":
201
- current_collection = next(
202
- (c for c in collections if c['name'] == selected_collection),
203
- None
204
- )
205
- if current_collection:
206
- st.session_state.current_collection = current_collection
207
- show_collection_details(current_collection)
208
-
209
- # Upload Section
210
- st.header("Upload Documents")
211
- upload_to = st.selectbox(
212
- "Upload to",
213
- options=["New Collection"] + [c['name'] for c in collections],
214
- key="upload_destination"
215
- )
216
 
217
  uploaded_files = st.file_uploader(
218
  "Upload PDF documents",
@@ -221,8 +206,17 @@ def display_collection_sidebar():
221
  help="Limit 200MB per file • PDF"
222
  )
223
 
224
- if uploaded_files:
225
- handle_uploads(uploaded_files, upload_to)
 
 
 
 
 
 
 
 
 
226
 
227
  def display_collection_dialog():
228
  """Display the create collection dialog."""
@@ -289,30 +283,27 @@ def display_chat_area():
289
  display_chat_interface()
290
 
291
  def main():
292
- st.set_page_config(
293
- layout="wide",
294
- page_title="SYNAPTYX - RFP Analysis Agent",
295
- initial_sidebar_state="expanded"
296
- )
297
 
298
- # Initialize database silently
299
- if not initialize_database():
300
- st.error("Failed to initialize database. Please contact support.")
301
- return
302
-
303
  initialize_session_state()
304
- # Display sidebar first
 
305
  display_collection_sidebar()
306
- display_top_bar()
307
-
308
- if st.session_state.chat_ready:
309
- display_chat_interface()
310
- else:
311
- display_welcome_screen()
312
-
313
- # Show collection creation dialog if needed
314
- if st.session_state.get('show_collection_dialog'):
315
- display_collection_dialog()
 
 
 
316
 
317
  if __name__ == "__main__":
318
  main()
 
183
  with st.sidebar:
184
  st.title("📚 Document Manager")
185
 
186
+ # Collection Creation Button
187
+ if st.button("➕ Create New Collection", use_container_width=True):
188
+ st.session_state.show_collection_dialog = True
 
189
 
190
+ # Upload Section
191
+ st.header("Upload Documents")
192
+
193
+ # Get collections for dropdown
194
  collections = get_collections(st.session_state.db_conn)
195
  if collections:
196
+ upload_to = st.selectbox(
197
+ "Upload to",
198
+ options=["Select Collection..."] + [c['name'] for c in collections],
199
+ key="upload_destination"
200
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  uploaded_files = st.file_uploader(
203
  "Upload PDF documents",
 
206
  help="Limit 200MB per file • PDF"
207
  )
208
 
209
+ if uploaded_files and upload_to != "Select Collection...":
210
+ collection_id = next(
211
+ (c['id'] for c in collections if c['name'] == upload_to),
212
+ None
213
+ )
214
+ if collection_id:
215
+ handle_document_upload(uploaded_files, collection_id=collection_id)
216
+
217
+ # Show collection creation dialog if triggered
218
+ if st.session_state.get('show_collection_dialog', False):
219
+ show_collection_creation_dialog()
220
 
221
  def display_collection_dialog():
222
  """Display the create collection dialog."""
 
283
  display_chat_interface()
284
 
285
  def main():
286
+ st.set_page_config(layout="wide")
 
 
 
 
287
 
288
+ # Initialize database and session state
289
+ initialize_database()
 
 
 
290
  initialize_session_state()
291
+
292
+ # Display sidebar
293
  display_collection_sidebar()
294
+
295
+ # Main content area tabs
296
+ tab1, tab2 = st.tabs(["Chat", "Collections"])
297
+
298
+ with tab1:
299
+ if st.session_state.chat_ready:
300
+ display_chat_interface()
301
+ else:
302
+ display_welcome_screen()
303
+
304
+ with tab2:
305
+ from components.collection_manager import display_enhanced_collections
306
+ display_enhanced_collections()
307
 
308
  if __name__ == "__main__":
309
  main()