File size: 1,508 Bytes
a5b3518
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Path: frontend/app.py
# Main application entry point, setting up the app and routing.
import sys
import os
from pathlib import Path

project_root = Path(__file__).resolve().parent
backend_dir = project_root / "backend"

if str(backend_dir) not in sys.path:
    sys.path.insert(0, str(backend_dir))

# if str(current_dir) not in sys.path:
#     sys.path.insert(0, str(current_dir))

import streamlit as st
from components.sidebar import render_sidebar
from components.chat import render_chat_interface

st.set_page_config(
    page_icon=":material/sql:",
    page_title="NL2SQL Assistant",
    layout="wide",
    initial_sidebar_state="expanded"
)

# def load_css():
#     """Load custom CSS file"""
#     css_path = os.path.join("assets", "styles.css")
#     if os.path.exists(css_path):
#         with open(css_path) as f:
#             st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)

def init_session_state():
    """Initialize global variables and authentication states"""
    if 'auth_stat' not in st.session_state:
        st.session_state.auth_stat = "guest"

    if 'username' not in st.session_state:
        st.session_state.username = "guest"

    if 'messages' not in st.session_state:
        st.session_state.messages = []
        
    if 'current_model' not in st.session_state:
        st.session_state.current_model = "default"

def main():
    # load_css()
    init_session_state()

    render_sidebar()
    render_chat_interface()

if __name__ == "__main__":
    main()