-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllmapp.py
More file actions
116 lines (103 loc) · 3.33 KB
/
Copy pathllmapp.py
File metadata and controls
116 lines (103 loc) · 3.33 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import logging
import os
import streamlit as st
from streamlit_navigation_bar import st_navbar
# Patch StreamlitPage to handle missing script_run_ctx (when navbar creates pages outside script context)
from streamlit.navigation.page import StreamlitPage as _StreamlitPage
from streamlit.runtime.scriptrunner_utils.script_run_context import get_script_run_ctx
_original_init = _StreamlitPage.__init__
def _patched_init(self, page, *, title=None, icon=None, url_path=None, default=False, visibility="visible"):
# Call original init but catch early return when no script context
try:
_original_init(self, page, title=title, icon=icon, url_path=url_path, default=default, visibility=visibility)
except Exception:
pass
# If attributes weren't set (happens when no script_run_ctx), set them manually
if not hasattr(self, '_url_path') or self._url_path is None:
if url_path is not None:
self._url_path = url_path.strip().strip("/")
elif title is not None:
import re
path = re.sub(r"\s+", "_", title.lower())
path = re.sub(r"[&#?/\\:*\"<>|']", "", path)
path = path.strip("_")
path = re.sub(r"_+", "_", path)
self._url_path = path
else:
self._url_path = ""
if not hasattr(self, '_page'):
self._page = None
if not hasattr(self, '_title'):
self._title = title or ""
if not hasattr(self, '_icon'):
self._icon = icon or ""
if not hasattr(self, '_default'):
self._default = default
if not hasattr(self, '_visibility'):
self._visibility = visibility
if not hasattr(self, '_external_url'):
self._external_url = None
if not hasattr(self, '_can_be_called'):
self._can_be_called = False
_StreamlitPage.__init__ = _patched_init
from src.constants import NAVBAR_STYLE
from src.helpers import pop_page_from_url
from src.session import init_session_state
import views as pg
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
st.set_page_config(
page_title="LADM Composer",
page_icon="🏠",
layout="wide",
initial_sidebar_state="expanded",
)
init_session_state()
page = st_navbar(
[
"Assessment",
"Questions",
"UML",
"Output",
"Chat",
"Report",
"Files",
"UML Upload",
"Project",
"About",
],
styles=NAVBAR_STYLE,
options={"show_menu": False, "show_sidebar": False},
logo_path=os.path.join(os.path.dirname(os.path.abspath(__file__)), "logo.svg"),
)
logger.info(f"page={page}")
qp = pop_page_from_url()
if st.session_state.last_page != page:
st.session_state.last_page = page
st.query_params["page"] = page
effective_page = page
else:
effective_page = qp or page
logger.info(f"Effective page: {effective_page}")
if effective_page == "About":
pg.about()
elif effective_page == "Assessment":
pg.assessment()
elif effective_page == "Output":
pg.output()
elif effective_page == "UML":
pg.uml()
elif effective_page == "Chat":
pg.chat()
elif effective_page == "Questions":
pg.questions()
elif effective_page == "Report":
pg.report()
elif effective_page == "Files":
pg.files()
elif effective_page == "UML Upload":
pg.uml_upload()
elif effective_page == "Project":
pg.project()
else:
pg.home()