cryogenic22 commited on
Commit
03e1db1
·
verified ·
1 Parent(s): 067ac7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -3
app.py CHANGED
@@ -6,6 +6,7 @@ from pathlib import Path
6
  from typing import Dict, List, Optional, Any
7
  from datetime import datetime
8
  from threading import Lock
 
9
 
10
  from utils.database import (
11
  # Base database operations
@@ -369,8 +370,9 @@ def main():
369
  with col2:
370
  st.title("SYNAPTYX - RFP Analysis Agent")
371
 
372
- # Sidebar with chat controls
373
  with st.sidebar:
 
374
  st.title("💬 Chat Controls")
375
 
376
  # New Chat button
@@ -381,9 +383,42 @@ def main():
381
 
382
  st.divider()
383
 
384
- # Collection management below
385
  st.title("📚 Document Manager")
386
- display_collection_sidebar()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
 
388
  # Main content area
389
  tab1, tab2 = st.tabs(["Chat", "Collections"])
@@ -401,6 +436,7 @@ def main():
401
  with tab2:
402
  from components.collection_manager import display_enhanced_collections
403
  display_enhanced_collections()
 
404
  # After collection operations, check if we need to reinitialize chat
405
  if st.session_state.get('reinitialize_chat'):
406
  initialize_chat_from_collection()
 
6
  from typing import Dict, List, Optional, Any
7
  from datetime import datetime
8
  from threading import Lock
9
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
10
 
11
  from utils.database import (
12
  # Base database operations
 
370
  with col2:
371
  st.title("SYNAPTYX - RFP Analysis Agent")
372
 
373
+ # Single sidebar implementation
374
  with st.sidebar:
375
+ # Chat Controls Section
376
  st.title("💬 Chat Controls")
377
 
378
  # New Chat button
 
383
 
384
  st.divider()
385
 
386
+ # Document Manager Section
387
  st.title("📚 Document Manager")
388
+
389
+ # Collection Creation Button
390
+ if st.button("➕ Create New Collection"):
391
+ st.session_state.show_collection_dialog = True
392
+
393
+ # Collection Selection
394
+ collections = get_collections(st.session_state.db_conn)
395
+ if collections:
396
+ upload_to = st.selectbox(
397
+ "Select Collection",
398
+ options=["Select Collection..."] + [c['name'] for c in collections],
399
+ key="upload_destination"
400
+ )
401
+
402
+ # Upload Section
403
+ st.header("Upload Documents")
404
+ uploaded_files = st.file_uploader(
405
+ "Upload PDF documents",
406
+ type=['pdf'],
407
+ accept_multiple_files=True,
408
+ help="Limit 200MB per file • PDF"
409
+ )
410
+
411
+ if uploaded_files and upload_to != "Select Collection...":
412
+ collection_id = next(
413
+ (c['id'] for c in collections if c['name'] == upload_to),
414
+ None
415
+ )
416
+ if collection_id:
417
+ handle_document_upload(uploaded_files, collection_id=collection_id)
418
+
419
+ # Show collection creation dialog if triggered
420
+ if st.session_state.get('show_collection_dialog', False):
421
+ show_collection_creation_dialog()
422
 
423
  # Main content area
424
  tab1, tab2 = st.tabs(["Chat", "Collections"])
 
436
  with tab2:
437
  from components.collection_manager import display_enhanced_collections
438
  display_enhanced_collections()
439
+
440
  # After collection operations, check if we need to reinitialize chat
441
  if st.session_state.get('reinitialize_chat'):
442
  initialize_chat_from_collection()