Spaces:
Sleeping
Sleeping
| """Main Streamlit application for LegisQA""" | |
| import logging | |
| import streamlit as st | |
| from legisqa_local.config.settings import STREAMLIT_CONFIG, setup_environment, inspect_chromadb | |
| from legisqa_local.core.vectorstore import initialize_vectorstore | |
| from legisqa_local.components.sidebar import render_sidebar | |
| from legisqa_local.tabs.rag_tab import RAGTab | |
| from legisqa_local.tabs.rag_sbs_tab import RAGSideBySideTab | |
| from legisqa_local.tabs.guide_tab import GuideTab | |
| # Configure logging (should be done once at application startup) | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | |
| force=True # Force reconfiguration if already configured | |
| ) | |
| logger = logging.getLogger(__name__) | |
| def main(): | |
| """Main application function""" | |
| logger.info("π Starting LegisQA application...") | |
| # Configure Streamlit | |
| st.set_page_config(**STREAMLIT_CONFIG) | |
| logger.info("β Streamlit configuration complete") | |
| # Setup environment | |
| logger.info("π§ Setting up environment...") | |
| setup_environment() | |
| logger.info("β Environment setup complete") | |
| # Setup ChromaDB (download if needed) - run once per session | |
| if "chromadb_inspected" not in st.session_state: | |
| logger.info("πΎ Inspecting ChromaDB...") | |
| inspect_chromadb() | |
| logger.info("β ChromaDB inspection complete") | |
| st.session_state.chromadb_inspected = True | |
| # Initialize vectorstore (load once and cache in session state) | |
| if "vectorstore" not in st.session_state: | |
| initialize_vectorstore() | |
| # Main content | |
| st.title(":classical_building: LegisQA :classical_building:") | |
| st.header("Query Congressional Bills") | |
| # Sidebar | |
| with st.sidebar: | |
| render_sidebar() | |
| # Create tab instances | |
| rag_tab = RAGTab() | |
| rag_sbs_tab = RAGSideBySideTab() | |
| guide_tab = GuideTab() | |
| # Create tabs | |
| query_rag_tab, query_rag_sbs_tab, guide_tab_ui = st.tabs([ | |
| rag_tab.name, | |
| rag_sbs_tab.name, | |
| guide_tab.name, | |
| ]) | |
| # Render tab content | |
| with query_rag_tab: | |
| rag_tab.render() | |
| with query_rag_sbs_tab: | |
| rag_sbs_tab.render() | |
| with guide_tab_ui: | |
| guide_tab.render() | |
| if __name__ == "__main__": | |
| main() | |